t3903: abstract away SHA-1-specific constants
Abstract away the SHA-1-specific constants by sanitizing diff output to remove the index lines, since it's clear from the assertions in question that we are not interested in the specific object IDs. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
brian m. carlson committed
Aug 26, 2019 at 01:43 UTC
c78481507374af87844e14b4b3b8220bba9f2c9a
1 file changed
+22
-10
t/t3903-stash.sh
+22
-10
@@ -7,6 +7,18 @@ test_description='Test git stash'
7
8
. ./test-lib.sh
9
10
+diff_cmp () {
11
+ for i in "$1" "$2"
12
+ do
13
+ sed -e 's/^index 0000000\.\.[0-9a-f]*/index 0000000..1234567/' \
14
+ -e 's/^index [0-9a-f]*\.\.[0-9a-f]*/index 1234567..89abcde/' \
15
+ -e 's/^index [0-9a-f]*,[0-9a-f]*\.\.[0-9a-f]*/index 1234567,7654321..89abcde/' \
16
+ "$i" >"$i.compare" || return 1
17
+ done &&
18
+ test_cmp "$1.compare" "$2.compare" &&
19
+ rm -f "$1.compare" "$2.compare"
20
+}
21
+
22
test_expect_success 'stash some dirty working directory' '
23
echo 1 >file &&
24
git add file &&
@@ -36,7 +48,7 @@ EOF
48
test_expect_success 'parents of stash' '
49
test $(git rev-parse stash^) = $(git rev-parse HEAD) &&
50
git diff stash^2..stash >output &&
39
- test_cmp expect output
51
+ diff_cmp expect output
52
'
53
54
test_expect_success 'applying bogus stash does nothing' '
@@ -210,13 +222,13 @@ test_expect_success 'stash branch' '
222
test refs/heads/stashbranch = $(git symbolic-ref HEAD) &&
223
test $(git rev-parse HEAD) = $(git rev-parse master^) &&
224
git diff --cached >output &&
213
- test_cmp expect output &&
225
+ diff_cmp expect output &&
226
git diff >output &&
215
- test_cmp expect1 output &&
227
+ diff_cmp expect1 output &&
228
git add file &&
229
git commit -m alternate\ second &&
230
git diff master..stashbranch >output &&
219
- test_cmp output expect2 &&
231
+ diff_cmp output expect2 &&
232
test 0 = $(git stash list | wc -l)
233
'
234
@@ -577,7 +589,7 @@ test_expect_success 'stash show -p - stashes on stack, stash-like argument' '
589
+bar
590
EOF
591
git stash show -p ${STASH_ID} >actual &&
580
- test_cmp expected actual
592
+ diff_cmp expected actual
593
'
594
595
test_expect_success 'stash show - no stashes on stack, stash-like argument' '
@@ -609,7 +621,7 @@ test_expect_success 'stash show -p - no stashes on stack, stash-like argument' '
621
+foo
622
EOF
623
git stash show -p ${STASH_ID} >actual &&
612
- test_cmp expected actual
624
+ diff_cmp expected actual
625
'
626
627
test_expect_success 'stash show --patience shows diff' '
@@ -627,7 +639,7 @@ test_expect_success 'stash show --patience shows diff' '
639
+foo
640
EOF
641
git stash show --patience ${STASH_ID} >actual &&
630
- test_cmp expected actual
642
+ diff_cmp expected actual
643
'
644
645
test_expect_success 'drop: fail early if specified stash is not a stash ref' '
@@ -791,7 +803,7 @@ test_expect_success 'stash where working directory contains "HEAD" file' '
803
git diff-index --cached --quiet HEAD &&
804
test "$(git rev-parse stash^)" = "$(git rev-parse HEAD)" &&
805
git diff stash^..stash >output &&
794
- test_cmp expect output
806
+ diff_cmp expect output
807
'
808
809
test_expect_success 'store called with invalid commit' '
@@ -847,7 +859,7 @@ test_expect_success 'stash list implies --first-parent -m' '
859
+working
860
EOF
861
git stash list --format=%gd -p >actual &&
850
- test_cmp expect actual
862
+ diff_cmp expect actual
863
'
864
865
test_expect_success 'stash list --cc shows combined diff' '
@@ -864,7 +876,7 @@ test_expect_success 'stash list --cc shows combined diff' '
876
++working
877
EOF
878
git stash list --format=%gd -p --cc >actual &&
867
- test_cmp expect actual
879
+ diff_cmp expect actual
880
'
881
882
test_expect_success 'stash is not confused by partial renames' '