Skip to content

Commit b7ef931

Browse files
committed
Update several tests so they don't rely on a default for --git-prefixes
Assisted-by: Cursor
1 parent 44ef627 commit b7ef931

File tree

12 files changed

+283
-67
lines changed

12 files changed

+283
-67
lines changed

tests/fullheader1/run-test

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ index 5feceb9..dde7898 10644
2222
+be selected
2323
EOF
2424

25-
${LSDIFF} -n git-output 2>errors >index || exit 1
25+
${LSDIFF} --git-prefixes=strip -n git-output 2>errors >index || exit 1
2626
[ -s errors ] && exit 1
2727
cat <<"EOF" | cmp - index || exit 1
28-
1 a/ChangeLog
29-
8 a/otherfile
28+
1 ChangeLog
29+
8 otherfile
3030
EOF
3131

32-
${FILTERDIFF} -p1 -i otherfile git-output 2>errors >otherfile.patch || exit 1
32+
${FILTERDIFF} --git-prefixes=strip -i otherfile git-output 2>errors >otherfile.patch || exit 1
3333
[ -s errors ] && exit 1
3434
cat <<"EOF" | cmp - otherfile.patch || exit 1
3535
diff --git a/otherfile b/otherfile

tests/git-binary-formats/run-test

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ EOF
6262

6363
# Test filtering binary files with GIT binary patch format - should include binary content
6464
echo "Testing GIT binary patch format (include)..."
65-
${FILTERDIFF} -i "*/file1.bin" git-binary-patch.patch 2>errors1 >result1 || exit 1
65+
${FILTERDIFF} --git-prefixes=strip -i "file1.bin" git-binary-patch.patch 2>errors1 >result1 || exit 1
6666
[ -s errors1 ] && { echo "Unexpected errors in test 1:"; cat errors1; exit 1; }
6767

6868
cat << 'EOF' | cmp - result1 || { echo "Test 1 failed"; exit 1; }
@@ -78,7 +78,7 @@ EOF
7878

7979
# Test filtering binary files with literal format - should include binary content
8080
echo "Testing literal format (include)..."
81-
${FILTERDIFF} -i "*/file3.bin" literal-patch.patch 2>errors2 >result2 || exit 1
81+
${FILTERDIFF} --git-prefixes=strip -i "file3.bin" literal-patch.patch 2>errors2 >result2 || exit 1
8282
[ -s errors2 ] && { echo "Unexpected errors in test 2:"; cat errors2; exit 1; }
8383

8484
cat << 'EOF' | cmp - result2 || { echo "Test 2 failed"; exit 1; }
@@ -93,7 +93,7 @@ EOF
9393

9494
# Test filtering binary files with delta format - should include binary content
9595
echo "Testing delta format (include)..."
96-
${FILTERDIFF} -i "*/file5.bin" delta-patch.patch 2>errors3 >result3 || exit 1
96+
${FILTERDIFF} --git-prefixes=strip -i "file5.bin" delta-patch.patch 2>errors3 >result3 || exit 1
9797
[ -s errors3 ] && { echo "Unexpected errors in test 3:"; cat errors3; exit 1; }
9898

9999
cat << 'EOF' | cmp - result3 || { echo "Test 3 failed"; exit 1; }
@@ -108,7 +108,7 @@ EOF
108108

109109
# Test excluding binary files - should skip binary content
110110
echo "Testing binary patch exclusion..."
111-
${FILTERDIFF} -x "*/file1.bin" git-binary-patch.patch 2>errors4 >result4 || exit 1
111+
${FILTERDIFF} --git-prefixes=strip -x "file1.bin" git-binary-patch.patch 2>errors4 >result4 || exit 1
112112
[ -s errors4 ] && { echo "Unexpected errors in test 4:"; cat errors4; exit 1; }
113113

114114
cat << 'EOF' | cmp - result4 || { echo "Test 4 failed"; exit 1; }

tests/git-binary-issue57/run-test

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ index 0000000..abcdefg
2121
EOF
2222

2323
# Test that filterdiff includes binary files when they match
24-
${FILTERDIFF} -p 1 -i binary-file git-binary.patch 2>errors >result || exit 1
24+
${FILTERDIFF} --git-prefixes=strip -i binary-file git-binary.patch 2>errors >result || exit 1
2525
[ -s errors ] && exit 1
2626

2727
cat << EOF | cmp - result || exit 1
@@ -32,16 +32,16 @@ Binary files /dev/null and b/binary-file differ
3232
EOF
3333

3434
# Test that lsdiff shows binary files
35-
${LSDIFF} git-binary.patch 2>errors2 >result2 || exit 1
35+
${LSDIFF} --git-prefixes=strip git-binary.patch 2>errors2 >result2 || exit 1
3636
[ -s errors2 ] && exit 1
3737

3838
cat << EOF | cmp - result2 || exit 1
39-
a/binary-file
40-
b/text-file.txt
39+
binary-file
40+
text-file.txt
4141
EOF
4242

4343
# Test excluding binary files
44-
${FILTERDIFF} -p 1 -x binary-file git-binary.patch 2>errors3 >result3 || exit 1
44+
${FILTERDIFF} --git-prefixes=strip -x binary-file git-binary.patch 2>errors3 >result3 || exit 1
4545
[ -s errors3 ] && exit 1
4646

4747
cat << EOF | cmp - result3 || exit 1

tests/git-deleted-file/run-test

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,16 @@ index 222..0000000
4444
EOF
4545

4646
echo "=== Test 1: lsdiff with deleted file ==="
47-
${LSDIFF} -s git-deleted.patch 2>errors1 >result1 || exit 1
47+
${LSDIFF} --git-prefixes=strip -s git-deleted.patch 2>errors1 >result1 || exit 1
4848
[ -s errors1 ] && exit 1
4949

5050
# Should show file with '-' status
5151
cat << EOF | cmp - result1 || exit 1
52-
- a/deleted-file.txt
52+
- deleted-file.txt
5353
EOF
5454

5555
echo "=== Test 2: filterdiff include deleted file ==="
56-
${FILTERDIFF} -i "*/deleted*" git-deleted.patch 2>errors2 >result2 || exit 1
56+
${FILTERDIFF} --git-prefixes=strip -i "deleted*" git-deleted.patch 2>errors2 >result2 || exit 1
5757
[ -s errors2 ] && exit 1
5858

5959
# Should include the full diff
@@ -70,22 +70,22 @@ index abc123..0000000
7070
EOF
7171

7272
echo "=== Test 3: filterdiff exclude deleted file ==="
73-
${FILTERDIFF} -x "*/deleted*" git-deleted.patch 2>errors3 >result3 || exit 1
73+
${FILTERDIFF} --git-prefixes=strip -x "deleted*" git-deleted.patch 2>errors3 >result3 || exit 1
7474
[ -s errors3 ] && exit 1
7575

7676
# Should be empty
7777
[ -s result3 ] && exit 1
7878

7979
echo "=== Test 4: lsdiff with deleted file (no hunks) ==="
80-
${LSDIFF} -s git-deleted-no-hunks.patch 2>errors4 >result4 || exit 1
80+
${LSDIFF} --git-prefixes=strip -s git-deleted-no-hunks.patch 2>errors4 >result4 || exit 1
8181
[ -s errors4 ] && exit 1
8282

8383
cat << EOF | cmp - result4 || exit 1
84-
- a/removed.c
84+
- removed.c
8585
EOF
8686

8787
echo "=== Test 5: filterdiff with deleted file (no hunks) ==="
88-
${FILTERDIFF} -i "*/*.c" git-deleted-no-hunks.patch 2>errors5 >result5 || exit 1
88+
${FILTERDIFF} --git-prefixes=strip -i "*.c" git-deleted-no-hunks.patch 2>errors5 >result5 || exit 1
8989
[ -s errors5 ] && exit 1
9090

9191
cat << 'EOF' | cmp - result5 || exit 1
@@ -96,16 +96,16 @@ Binary files a/removed.c and /dev/null differ
9696
EOF
9797

9898
echo "=== Test 6: lsdiff with multiple deleted files ==="
99-
${LSDIFF} -s git-multiple-deleted.patch 2>errors6 >result6 || exit 1
99+
${LSDIFF} --git-prefixes=strip -s git-multiple-deleted.patch 2>errors6 >result6 || exit 1
100100
[ -s errors6 ] && exit 1
101101

102102
cat << EOF | cmp - result6 || exit 1
103-
- a/file1.txt
104-
- a/file2.txt
103+
- file1.txt
104+
- file2.txt
105105
EOF
106106

107107
echo "=== Test 7: filterdiff with pattern matching multiple deleted files ==="
108-
${FILTERDIFF} -i "*/file1*" git-multiple-deleted.patch 2>errors7 >result7 || exit 1
108+
${FILTERDIFF} --git-prefixes=strip -i "file1*" git-multiple-deleted.patch 2>errors7 >result7 || exit 1
109109
[ -s errors7 ] && exit 1
110110

111111
cat << 'EOF' | cmp - result7 || exit 1

tests/git-diff-duplication/run-test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ index 1111111..2222222 100644
2727
EOF
2828

2929
# Test that filterdiff preserves the output unchanged
30-
${FILTERDIFF} git-diff-bug.patch 2>errors >result || exit 1
30+
${FILTERDIFF} --git-prefixes=strip git-diff-bug.patch 2>errors >result || exit 1
3131
[ -s errors ] && exit 1
3232

3333
# The result should be identical to the input

tests/git-exclude-issue27/run-test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ index 1234567..abcdefg 100644
2424
EOF
2525

2626
# Test that excluding README.vin removes the entire git diff block
27-
${FILTERDIFF} -p 1 -x README.vin git-multi.patch 2>errors >result || exit 1
27+
${FILTERDIFF} --git-prefixes=strip -x README.vin git-multi.patch 2>errors >result || exit 1
2828
[ -s errors ] && exit 1
2929

3030
# The result should contain the complete autogen.sh diff, no orphaned headers
@@ -39,7 +39,7 @@ index 1234567..abcdefg 100644
3939
EOF
4040

4141
# Test that excluding both files results in empty output
42-
${FILTERDIFF} -p 1 -x README.vin -x autogen.sh git-multi.patch 2>errors2 >result2 || exit 1
42+
${FILTERDIFF} --git-prefixes=strip -x README.vin -x autogen.sh git-multi.patch 2>errors2 >result2 || exit 1
4343
[ -s errors2 ] && exit 1
4444

4545
# The result should be completely empty

tests/git-extended-headers/run-test

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ index 1234567..0000000
1818
-line 3
1919
EOF
2020

21-
${LSDIFF} deleted-file.patch 2>errors1a >result1a || exit 1
21+
${LSDIFF} --git-prefixes=strip deleted-file.patch 2>errors1a >result1a || exit 1
2222
[ -s errors1a ] && exit 1
2323

2424
cat << EOF | cmp - result1a || exit 1
25-
a/removed.txt
25+
removed.txt
2626
EOF
2727

28-
${FILTERDIFF} -i "a/removed.txt" deleted-file.patch 2>errors1a2 >result1a2 || exit 1
28+
${FILTERDIFF} --git-prefixes=strip -i "removed.txt" deleted-file.patch 2>errors1a2 >result1a2 || exit 1
2929
[ -s errors1a2 ] && exit 1
3030

3131
cat << EOF | cmp - result1a2 || exit 1
@@ -47,14 +47,14 @@ deleted file mode 100644
4747
index e69de29..0000000
4848
EOF
4949

50-
${LSDIFF} deleted-file-no-hunks.patch 2>errors1b >result1b || exit 1
50+
${LSDIFF} --git-prefixes=strip deleted-file-no-hunks.patch 2>errors1b >result1b || exit 1
5151
[ -s errors1b ] && exit 1
5252

5353
cat << EOF | cmp - result1b || exit 1
54-
a/empty-deleted.txt
54+
empty-deleted.txt
5555
EOF
5656

57-
${FILTERDIFF} -i "a/empty-deleted.txt" deleted-file-no-hunks.patch 2>errors1b2 >result1b2 || exit 1
57+
${FILTERDIFF} --git-prefixes=strip -i "empty-deleted.txt" deleted-file-no-hunks.patch 2>errors1b2 >result1b2 || exit 1
5858
[ -s errors1b2 ] && exit 1
5959

6060
cat << EOF | cmp - result1b2 || exit 1
@@ -76,14 +76,14 @@ index 0000000..abcdefg
7676
+new line 3
7777
EOF
7878

79-
${LSDIFF} new-file.patch 2>errors2a >result2a || exit 1
79+
${LSDIFF} --git-prefixes=strip new-file.patch 2>errors2a >result2a || exit 1
8080
[ -s errors2a ] && exit 1
8181

8282
cat << EOF | cmp - result2a || exit 1
83-
b/created.txt
83+
created.txt
8484
EOF
8585

86-
${FILTERDIFF} -i "b/created.txt" new-file.patch 2>errors2a2 >result2a2 || exit 1
86+
${FILTERDIFF} --git-prefixes=strip -i "created.txt" new-file.patch 2>errors2a2 >result2a2 || exit 1
8787
[ -s errors2a2 ] && exit 1
8888

8989
cat << EOF | cmp - result2a2 || exit 1
@@ -105,14 +105,14 @@ new file mode 100644
105105
index 0000000..e69de29
106106
EOF
107107

108-
${LSDIFF} new-file-no-hunks.patch 2>errors2b >result2b || exit 1
108+
${LSDIFF} --git-prefixes=strip new-file-no-hunks.patch 2>errors2b >result2b || exit 1
109109
[ -s errors2b ] && exit 1
110110

111111
cat << EOF | cmp - result2b || exit 1
112-
a/empty-new.txt
112+
empty-new.txt
113113
EOF
114114

115-
${FILTERDIFF} -i "a/empty-new.txt" new-file-no-hunks.patch 2>errors2b2 >result2b2 || exit 1
115+
${FILTERDIFF} --git-prefixes=strip -i "empty-new.txt" new-file-no-hunks.patch 2>errors2b2 >result2b2 || exit 1
116116
[ -s errors2b2 ] && exit 1
117117

118118
cat << EOF | cmp - result2b2 || exit 1
@@ -129,14 +129,14 @@ index e69de29..0000000
129129
Binary files a/pure-deleted.txt and /dev/null differ
130130
EOF
131131

132-
${LSDIFF} deleted-file-binary.patch 2>errors1c >result1c || exit 1
132+
${LSDIFF} --git-prefixes=strip deleted-file-binary.patch 2>errors1c >result1c || exit 1
133133
[ -s errors1c ] && exit 1
134134

135135
cat << EOF | cmp - result1c || exit 1
136-
a/pure-deleted.txt
136+
pure-deleted.txt
137137
EOF
138138

139-
${FILTERDIFF} -i "a/pure-deleted.txt" deleted-file-binary.patch 2>errors1c2 >result1c2 || exit 1
139+
${FILTERDIFF} --git-prefixes=strip -i "pure-deleted.txt" deleted-file-binary.patch 2>errors1c2 >result1c2 || exit 1
140140
[ -s errors1c2 ] && exit 1
141141

142142
cat << EOF | cmp - result1c2 || exit 1
@@ -181,14 +181,14 @@ index abc1234..def5678 100644
181181
+}
182182
EOF
183183

184-
${LSDIFF} dissimilar-file.patch 2>errors3a >result3a || exit 1
184+
${LSDIFF} --git-prefixes=strip dissimilar-file.patch 2>errors3a >result3a || exit 1
185185
[ -s errors3a ] && exit 1
186186

187187
cat << EOF | cmp - result3a || exit 1
188-
a/rewritten.c
188+
rewritten.c
189189
EOF
190190

191-
${FILTERDIFF} -i "a/rewritten.c" dissimilar-file.patch 2>errors3a2 >result3a2 || exit 1
191+
${FILTERDIFF} --git-prefixes=strip -i "rewritten.c" dissimilar-file.patch 2>errors3a2 >result3a2 || exit 1
192192
[ -s errors3a2 ] && exit 1
193193

194194
grep -q "dissimilarity index 95%" result3a2 || exit 1
@@ -288,32 +288,32 @@ index old123..new456 100644
288288
EOF
289289

290290
# Test lsdiff shows all files
291-
${LSDIFF} mixed-extended.patch 2>errors4 >result4 || exit 1
291+
${LSDIFF} --git-prefixes=strip mixed-extended.patch 2>errors4 >result4 || exit 1
292292
[ -s errors4 ] && exit 1
293293

294294
cat << EOF | cmp - result4 || exit 1
295-
a/old.txt
296-
a/template.h
295+
old.txt
296+
template.h
297297
config.conf
298-
a/script.sh
299-
b/brand-new.py
300-
a/completely-rewritten.java
298+
script.sh
299+
brand-new.py
300+
completely-rewritten.java
301301
EOF
302302

303303
# Test filtering works with all header types
304-
${FILTERDIFF} -i "b/*.py" mixed-extended.patch 2>errors5 >result5 || exit 1
304+
${FILTERDIFF} --git-prefixes=strip -i "*.py" mixed-extended.patch 2>errors5 >result5 || exit 1
305305
[ -s errors5 ] && exit 1
306306

307307
grep -q "brand-new.py" result5 || exit 1
308308
grep -q "new file mode 100755" result5 || exit 1
309309

310-
${FILTERDIFF} -i "a/*.java" mixed-extended.patch 2>errors6 >result6 || exit 1
310+
${FILTERDIFF} --git-prefixes=strip -i "*.java" mixed-extended.patch 2>errors6 >result6 || exit 1
311311
[ -s errors6 ] && exit 1
312312

313313
grep -q "completely-rewritten.java" result6 || exit 1
314314
grep -q "dissimilarity index 98%" result6 || exit 1
315315

316-
${FILTERDIFF} -i "a/old.txt" mixed-extended.patch 2>errors7 >result7 || exit 1
316+
${FILTERDIFF} --git-prefixes=strip -i "old.txt" mixed-extended.patch 2>errors7 >result7 || exit 1
317317
[ -s errors7 ] && exit 1
318318

319319
grep -q "deleted file mode 100644" result7 || exit 1
@@ -337,7 +337,7 @@ index abc123..def456 100755
337337
printf("Hello");
338338
EOF
339339

340-
${FILTERDIFF} -i "*complex*.c" multiple-headers.patch 2>errors8 >result8 || exit 1
340+
${FILTERDIFF} --git-prefixes=strip -i "*complex*.c" multiple-headers.patch 2>errors8 >result8 || exit 1
341341
[ -s errors8 ] && exit 1
342342

343343
grep -q "similarity index 75%" result8 || exit 1

0 commit comments

Comments
 (0)