Skip to contentSkip to conversation

patman: Support absolute and ~user-relative alias files

PATCH In review Brian Norris 3 participants 4 messages Jan 8, 2022 – Jan 13, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 patman: Support absolute and ~user-relative alias files

Python doesn't naturally support tilde (~) as a user-home marker in paths, but git-config does. So we need to resolve it before continuing.

We also shouldn't blindly join the top-level tree with the aliasesfile path, because it might be an absolute path.

This resolves warnings like the following:

Warning: Cannot find alias file '/path/to/source/tree/~/.git-email'

Seen when git-config is like:

  $ git config sendemail.aliasesfile
  ~/.git-email

---

 tools/patman/gitutil.py | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
tools/patman/gitutil.py +8 -3
index 5e4c1128dcb5..e1ef96df22ec 100644
@@ -616,9 +616,14 @@ def GetAliasFile():
     """
     fname = command.OutputOneLine('git', 'config', 'sendemail.aliasesfile',
             raise_on_error=False)
-    if fname:
-        fname = os.path.join(GetTopLevel(), fname.strip())
-    return fname
+    if not fname:
+        return None
+
+    fname = os.path.expanduser(fname.strip())
+    if os.path.isabs(fname):
+        return fname
+
+    return os.path.join(GetTopLevel(), fname)
 
 def GetDefaultUserName():
     """Gets the user.name from .gitconfig file.
Signature · 1 line
2.34.1.575.g55b058a8bb-goog
Reviewed-by on v1 1/1
#1 lore raw
Quoted 13 lines · Brian Norris

Python doesn't naturally support tilde (~) as a user-home marker in paths, but git-config does. So we need to resolve it before continuing.

We also shouldn't blindly join the top-level tree with the aliasesfile path, because it might be an absolute path.

This resolves warnings like the following:

Warning: Cannot find alias file '/path/to/source/tree/~/.git-email'

Seen when git-config is like:

Quoted 8 lines
  $ git config sendemail.aliasesfile
  ~/.git-email

---

 tools/patman/gitutil.py | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

+Otavio Salvador to check this one

Reviewed-by
#2 lore raw

Em qua., 12 de jan. de 2022 às 18:22, Simon Glass <[email protected]> escreveu:

Quoted 20 lines · Brian Norris
Quoted 19 lines

Python doesn't naturally support tilde (~) as a user-home marker in paths, but git-config does. So we need to resolve it before continuing.

We also shouldn't blindly join the top-level tree with the aliasesfile path, because it might be an absolute path.

This resolves warnings like the following:

Warning: Cannot find alias file '/path/to/source/tree/~/.git-email'

Seen when git-config is like:

  $ git config sendemail.aliasesfile
  ~/.git-email

---

Quoted 6 lines
Quoted 2 lines
 tools/patman/gitutil.py | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

+Otavio Salvador to check this one

Some use-case of mine.

Signature · 3 lines
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9 9981-7854          Mobile: +1 (347) 903-9750
Reviewed-by Otavio Salvador
#3 lore raw

Em qua., 12 de jan. de 2022 às 18:22, Simon Glass <[email protected]> escreveu:

Quoted 20 lines · Brian Norris
Quoted 19 lines

Python doesn't naturally support tilde (~) as a user-home marker in paths, but git-config does. So we need to resolve it before continuing.

We also shouldn't blindly join the top-level tree with the aliasesfile path, because it might be an absolute path.

This resolves warnings like the following:

Warning: Cannot find alias file '/path/to/source/tree/~/.git-email'

Seen when git-config is like:

  $ git config sendemail.aliasesfile
  ~/.git-email

---

Quoted 6 lines
Quoted 2 lines
 tools/patman/gitutil.py | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

+Otavio Salvador to check this one

Some use-case of mine.

Signature · 5 lines
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9 9981-7854          Mobile: +1 (347) 903-9750

Applied to u-boot-dm, thanks!