-
Notifications
You must be signed in to change notification settings - Fork 445
Description
Git has special flags and configuration variables for git log
, git show
, git diff
, git diff-tree
, git diff-index
, git diff-tree
, and git format-patch
to detect copies as well as renames.
These add "copy from"/"copy to" lines in the diff header when Git detects a new file is in fact copied from an existing file. Currently delta shows these as renames, which is confusing. It would be nice if they would show up correctly as copies.
An example from the same issue for diff-so-fancy:
@ scottchiefbaker this setting tells git how to display renamed (same or similar content, new name, old file is missing) and copied (same or similar content, new name, old file present) files. By default git only detects renames, any copy is shown as new file.
diff.renames copies
works also for second case.To illustrate this one can create dummy repository as
git init echo "hurr-durr" > first_file git add . git commit -m "first"
After that copy and stage (or commit) some file:
cp first_file copied_file git add .
And inspect this change:
❯ git --no-pager diff --staged diff --git a/copied_file b/copied_file new file mode 100644 index 0000000..d7b6a5e --- /dev/null +++ b/copied_file @@ -0,0 +1 @@ +hurr-durr /tmp/copy-example master* ❯ git --no-pager diff -C --staged # -C has the same meaning diff --git a/first_file b/copied_file similarity index 100% copy from first_file copy to copied_file
I hope this narrowed down example helps better than original ones.
Looks like fancy just doesn't know how to parsecopy from/to
headers in diff.
Relevant parts of the Git documentation: