patman: Support absolute and ~user-relative alias files
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
@@ -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
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-emailSigned-off-by Brian Norris <[email protected]>---
tools/patman/gitutil.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
+Otavio Salvador to check this one
Otavio Salvador
Reviewed-byEm 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-emailSigned-off-by Brian Norris <[email protected]>---
Quoted 6 lines
Quoted 2 lines
tools/patman/gitutil.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)+Otavio Salvador to check this one
Reviewed-by Simon Glass <[email protected]>
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
Simon Glass
Reviewed-by Otavio SalvadorEm 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-emailSigned-off-by Brian Norris <[email protected]>---
Quoted 6 lines
Quoted 2 lines
tools/patman/gitutil.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)+Otavio Salvador to check this one
Reviewed-by Simon Glass <[email protected]>
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!