delta eats first character of absolute file pathπ
delta eats first character of absolute file paths, thereby making them look like relative paths.
Repro Steps
-
seq 1 >fileA -
seq 2 >/tmp/fileB - Invoke
deltaas follows:
$ delta fileA /tmp/fileB
fileA βΆ tmp/fileB
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββββ
1: β
ββββ
1
2
Observed Behavior
Observe the following within the header:
fileA βΆ tmp/fileB
Notice that the leading / is missing.
Expected Behavior
fileA βΆ /tmp/fileB
$ delta --version
delta 0.12.1
Hi @salmankhilji, thanks again! I hadn't noticed that. And that's a bit unfortunate: delta a b uses git diff under the hood, but git diff produces identical output on the relative and absolute paths:
$ git -P diff --no-index /tmp/a /tmp/b
diff --git a/tmp/a b/tmp/b
index 7898192..6178079 100644
--- a/tmp/a
+++ b/tmp/b
@@ -1 +1 @@
-a
+b
$ delta <(git -P diff --no-index tmp/a tmp/b) <(git -P diff --no-index /tmp/a /tmp/b); echo $?
0
I was hoping that the solution might be git diff --no-prefix but in fact, it seems to be git that is stripping the leading /:
$ git -P diff --no-prefix --no-index /tmp/a /tmp/b
diff --git tmp/a tmp/b
index 7898192..6178079 100644
--- tmp/a
+++ tmp/b
@@ -1 +1 @@
-a
+b
Any ideas how we should solve this? (Maybe delta will have to "fix" git's output, since delta knows the original paths?)
Here's a quick attempt at fixing it: https://github.com/dandavison/delta/pull/1016
Any ideas how we should solve this? (Maybe delta will have to "fix" git's output, since delta knows the original paths?)
Not knowing Rust, I can not comment on the proposed changes to address this issue. At a high-level, it appears that yes, patching git's output would be the way to do. We, however, have to be careful as not to break pipe mode where delta may have been invoked without filenames, reading its input from stdin.
BTW, this is not a must fix IMHO. If its risky to fix, you may also choose to leave it as-is. At least delta is being consistent with git, which is much more widely used .