使用 Git 的外部比较工具时,如何获取要传递给工具的完整路径而不是相对路径



我正在尝试使用 shell 脚本和 .gitconfig 在使用 git 比较文件时打开 p4merge(在 Mac 上)。

它几乎可以工作,但是传递给p4merge的"正确"文件(第二个文件)上的相对路径出现问题:

~> git diff <absolute path>/django/templates/pagination.html 
output: 
/<absolute path to prev version>//jtpgjm_pagination.html django/templates/pagination.html
Incorrect parameters: 'django/templates/pagination.html' is (or points to) an invalid file.
完整路径在第一个参数上展开

,但不在第二个参数上展开。我可以做些什么来触发第二个文件的完整文件路径?

使用这个:

readlink -f django/templates/pagination.html

作为命令的参数,例如:

echo $(readlink -f django/templates/pagination.html)

最新更新