summaryrefslogtreecommitdiffstats
path: root/t/t4044-diff-index-unique-abbrev.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 14:47:53 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 14:47:53 +0000
commitc8bae7493d2f2910b57f13ded012e86bdcfb0532 (patch)
tree24e09d9f84dec336720cf393e156089ca2835791 /t/t4044-diff-index-unique-abbrev.sh
parentInitial commit. (diff)
downloadgit-c8bae7493d2f2910b57f13ded012e86bdcfb0532.tar.xz
git-c8bae7493d2f2910b57f13ded012e86bdcfb0532.zip
Adding upstream version 1:2.39.2.upstream/1%2.39.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 't/t4044-diff-index-unique-abbrev.sh')
-rwxr-xr-xt/t4044-diff-index-unique-abbrev.sh57
1 files changed, 57 insertions, 0 deletions
diff --git a/t/t4044-diff-index-unique-abbrev.sh b/t/t4044-diff-index-unique-abbrev.sh
new file mode 100755
index 0000000..29e49d2
--- /dev/null
+++ b/t/t4044-diff-index-unique-abbrev.sh
@@ -0,0 +1,57 @@
+#!/bin/sh
+
+test_description='test unique sha1 abbreviation on "index from..to" line'
+
+TEST_PASSES_SANITIZE_LEAK=true
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+ test_oid_cache <<-EOF &&
+ val1 sha1:4827
+ val1 sha256:5664
+
+ val2 sha1:11742
+ val2 sha256:10625
+
+ hash1 sha1:51d2738463ea4ca66f8691c91e33ce64b7d41bb1
+ hash1 sha256:ae31dfff0af93b2c62b0098a039b38569c43b0a7e97b873000ca42d128f27350
+
+ hasht1 sha1:51d27384
+ hasht1 sha256:ae31dfff
+
+ hash2 sha1:51d2738efb4ad8a1e40bed839ab8e116f0a15e47
+ hash2 sha256:ae31dffada88a46fd5f53c7ed5aa25a7a8951f1d5e88456c317c8d5484d263e5
+
+ hasht2 sha1:51d2738e
+ hasht2 sha256:ae31dffa
+ EOF
+
+ cat >expect_initial <<-EOF &&
+ 100644 blob $(test_oid hash1) foo
+ EOF
+
+ cat >expect_update <<-EOF &&
+ 100644 blob $(test_oid hash2) foo
+ EOF
+
+ echo "$(test_oid val1)" > foo &&
+ git add foo &&
+ git commit -m "initial" &&
+ git cat-file -p HEAD: > actual &&
+ test_cmp expect_initial actual &&
+ echo "$(test_oid val2)" > foo &&
+ git commit -a -m "update" &&
+ git cat-file -p HEAD: > actual &&
+ test_cmp expect_update actual
+'
+
+cat >expect <<EOF
+index $(test_oid hasht1)..$(test_oid hasht2) 100644
+EOF
+
+test_expect_success 'diff does not produce ambiguous index line' '
+ git diff HEAD^..HEAD | grep index > actual &&
+ test_cmp expect actual
+'
+
+test_done