How do I show full paths in git diff? One can use '--dst-prefix=$PWD' and '--src-prefix=$PWD' but this is fragile as it won't work in many cases, eg with --no-index, or when running the commond from a subdirectory without using --relative=realpath_to_cwd
Asked
Active
Viewed 2,066 times
1 Answers
1
It should be possible to:
- get the the path of the root folder of the repo: see "Is there a way to get the git root directory in one command?"
- use that path in the
--relative
,--dst-prefix
and--src-prefix
options.
That would be more robust than $PWD
.
-
14 years later ;) What command did you type? With which version of Git? – VonC Aug 23 '18 at 08:57
-
here's an example command (using git version 2.17.1 but irrelevant) "git diff --no-index `get_file1` `get_file2`" The cmd `get_file1` or ``get_file2` could return either absolute or relative path, so '--dst-prefix=$PWD' won't work (eg when path is already absolute) `git rev-parse --show-toplevel` makes no sense in the case of `--no-index` in general, since the files i'm comparing may not even be in a git repo. more info [here](https://public-inbox.org/git/CANri+ExMY9G9aSm2TumHd8a9p2ZVXqcBOV-H=7P-_Xh_ng=Cpg@mail.gmail.com/T/#rd4b7a754b4771346a4997b30f3e8c0b41964c0ac) – timotheecour Aug 24 '18 at 21:14