git log alias 失败,但运行完整命令显式成功
我看到了其他几个相关问题并试图避免陷阱: https://stackoverflow.com/a/51886432/959179 https://stackoverflow.com/a/68079866/959179 但这些并没有解决问题。
所以在 ~/.gitconfig
我有:
[alias]
lf1= !git log --graph --abbrev-commit --decorate --format=format:'%x09%C(bold blue)%h%C(reset) - %C(bold cyan)%ai%C(reset) %C(bold green)(%ar)%C(reset) - %C(dim magenta)%an%C(reset) - %C(white)%s%C(reset) %C(bold yellow)%d%C(reset)'
这是一个单行 git log 打印输出。
当我单独使用它作为 git lf1 时,它可以正确地将 git 日志打印为单行代码。
但是当我尝试追踪特定文件的信息时,它不再起作用:
$ git lf1 7bddc5ead9 conf/distro/aos.conf
fatal: ambiguous argument 'conf/distro/aos.conf': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
如果我按照建议添加分隔符“--”,我将得到错误的打印输出 - 不是文件中的更改,包括给定提交的版本ID。
我发现这个 https://stackoverflow.com/a/39468026/959179 来帮助我调试别名,结果是相同:
$ git debug lf1 7bddc5ead9 conf/distro/aos.conf
00:37:57.610634 git.c:703 trace: exec: git-lf1 7bddc5ead9 conf/distro/aos.conf
00:37:57.610680 run-command.c:663 trace: run_command: git-lf1 7bddc5ead9 conf/distro/aos.conf
00:37:57.610964 run-command.c:663 trace: run_command: 'git log --graph --abbrev-commit --decorate --format=format:'\''%x09%C(bold blue)%h%C(reset) - %C(bold cyan)%ai%C(reset) %C(bold green)(%ar)%C(reset) - %C(dim magenta)%an%C(reset) - %C(white)%s%C(reset) %C(bold yellow)%d%C(reset)'\''' 7bddc5ead9 conf/distro/aos.conf
00:37:57.612841 git.c:439 trace: built-in: git log --graph --abbrev-commit --decorate '--format=format:%x09%C(bold blue)%h%C(reset) - %C(bold cyan)%ai%C(reset) %C(bold green)(%ar)%C(reset) - %C(dim magenta)%an%C(reset) - %C(white)%s%C(reset) %C(bold yellow)%d%C(reset)' 7bddc5ead9 conf/distro/aos.conf
fatal: ambiguous argument 'conf/distro/aos.conf': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
但是如果我复制最后一个跟踪行(即“00:37:57.612841 git.c:439 跟踪:内置:”,上面的“致命:不明确的参数...”)并在 CLI 中粘贴并运行它,我将得到预期的打印输出。
我在这里缺少什么并且别名在 CLI 中工作时失败了?
I have seen a couple other related questions and tried to avoid the pitfalls:
https://stackoverflow.com/a/51886432/959179
https://stackoverflow.com/a/68079866/959179
but these did not manage to fix the issue.
so in ~/.gitconfig
I have :
[alias]
lf1= !git log --graph --abbrev-commit --decorate --format=format:'%x09%C(bold blue)%h%C(reset) - %C(bold cyan)%ai%C(reset) %C(bold green)(%ar)%C(reset) - %C(dim magenta)%an%C(reset) - %C(white)%s%C(reset) %C(bold yellow)%d%C(reset)'
this is a one-liner git log printout.
when I use it on its own as git lf1
it works correctly printing the git log as one-liners.
but when I try to track down info for a specific file it no longer works:
$ git lf1 7bddc5ead9 conf/distro/aos.conf
fatal: ambiguous argument 'conf/distro/aos.conf': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
if I add a separator "--" as suggested I will get a wrong printout - not the changes in the file up to and including version with the given commit ID.
I found this https://stackoverflow.com/a/39468026/959179 to help me debug the alias and the result is the same:
$ git debug lf1 7bddc5ead9 conf/distro/aos.conf
00:37:57.610634 git.c:703 trace: exec: git-lf1 7bddc5ead9 conf/distro/aos.conf
00:37:57.610680 run-command.c:663 trace: run_command: git-lf1 7bddc5ead9 conf/distro/aos.conf
00:37:57.610964 run-command.c:663 trace: run_command: 'git log --graph --abbrev-commit --decorate --format=format:'\''%x09%C(bold blue)%h%C(reset) - %C(bold cyan)%ai%C(reset) %C(bold green)(%ar)%C(reset) - %C(dim magenta)%an%C(reset) - %C(white)%s%C(reset) %C(bold yellow)%d%C(reset)'\''' 7bddc5ead9 conf/distro/aos.conf
00:37:57.612841 git.c:439 trace: built-in: git log --graph --abbrev-commit --decorate '--format=format:%x09%C(bold blue)%h%C(reset) - %C(bold cyan)%ai%C(reset) %C(bold green)(%ar)%C(reset) - %C(dim magenta)%an%C(reset) - %C(white)%s%C(reset) %C(bold yellow)%d%C(reset)' 7bddc5ead9 conf/distro/aos.conf
fatal: ambiguous argument 'conf/distro/aos.conf': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
but then if I copy the last trace line (i.e. "00:37:57.612841 git.c:439 trace: built-in:" , the one just above "fatal: ambiguous argument ...") and paste and run it in CLI, I will get the expected printout.
what am I missing here and the alias fails when in CLI it works ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论