summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2020-07-07 05:09:17 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-07-07 05:09:17 (GMT)
commit0ac0947b1470b2157fd4c085a1fd0b207d94b40b (patch)
tree51c2bb419ef22e3ac3309ebe6523e422e403b90c
parent11cbda2add5d3eb7c415f1f6dd8186181a7f9874 (diff)
parent3080c5098049228cd561f08ee4cc31839251d579 (diff)
downloadgit-0ac0947b1470b2157fd4c085a1fd0b207d94b40b.zip
git-0ac0947b1470b2157fd4c085a1fd0b207d94b40b.tar.gz
git-0ac0947b1470b2157fd4c085a1fd0b207d94b40b.tar.bz2
Merge branch 'js/diff-files-i-t-a-fix-for-difftool'
"git difftool" has trouble dealing with paths added to the index with the intent-to-add bit. * js/diff-files-i-t-a-fix-for-difftool: difftool -d: ensure that intent-to-add files are handled correctly diff-files --raw: show correct post-image of intent-to-add files
-rw-r--r--diff-lib.c3
-rwxr-xr-xt/t2203-add-intent.sh5
-rwxr-xr-xt/t7800-difftool.sh8
3 files changed, 11 insertions, 5 deletions
diff --git a/diff-lib.c b/diff-lib.c
index 61812f4..25fd2de 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -220,8 +220,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
} else if (revs->diffopt.ita_invisible_in_index &&
ce_intent_to_add(ce)) {
diff_addremove(&revs->diffopt, '+', ce->ce_mode,
- the_hash_algo->empty_tree, 0,
- ce->name, 0);
+ &null_oid, 0, ce->name, 0);
continue;
}
diff --git a/t/t2203-add-intent.sh b/t/t2203-add-intent.sh
index 8a5d550..cf0175a 100755
--- a/t/t2203-add-intent.sh
+++ b/t/t2203-add-intent.sh
@@ -240,7 +240,6 @@ test_expect_success 'i-t-a files shown as new for "diff", "diff-files"; not-new
hash_e=$(git hash-object empty) &&
hash_n=$(git hash-object not-empty) &&
- hash_t=$(git hash-object -t tree /dev/null) &&
cat >expect.diff_p <<-EOF &&
diff --git a/empty b/empty
@@ -259,8 +258,8 @@ test_expect_success 'i-t-a files shown as new for "diff", "diff-files"; not-new
create mode 100644 not-empty
EOF
cat >expect.diff_a <<-EOF &&
- :000000 100644 0000000 $(git rev-parse --short $hash_t) A$(printf "\t")empty
- :000000 100644 0000000 $(git rev-parse --short $hash_t) A$(printf "\t")not-empty
+ :000000 100644 0000000 0000000 A$(printf "\t")empty
+ :000000 100644 0000000 0000000 A$(printf "\t")not-empty
EOF
git add -N empty not-empty &&
diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh
index 29b9290..524f30f 100755
--- a/t/t7800-difftool.sh
+++ b/t/t7800-difftool.sh
@@ -720,6 +720,14 @@ test_expect_success SYMLINKS 'difftool --dir-diff handles modified symlinks' '
test_cmp expect actual
'
+test_expect_success 'add -N and difftool -d' '
+ test_when_finished git reset --hard &&
+
+ test_write_lines A B C >intent-to-add &&
+ git add -N intent-to-add &&
+ git difftool --dir-diff --extcmd ls
+'
+
test_expect_success 'outside worktree' '
echo 1 >1 &&
echo 2 >2 &&