Skip to content

Commit b006968

Browse files
Denton-Lgitster
authored andcommitted
t4108: remove git command upstream of pipe
Before, the output of `git diff HEAD` would always be piped to sanitize_conflicted_diff(). However, since the Git command was upstream of the pipe, in case the Git command fails, the return code would be lost. Rewrite into separate statements so that the return code is no longer lost. Since only the command `git diff HEAD` was being piped to sanitize_conflicted_diff(), move the command into the function and rename it to print_sanitized_conflicted_diff(). Signed-off-by: Denton Liu <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fa87b81 commit b006968

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

t/t4108-apply-threeway.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ test_description='git apply --3way'
44

55
. ./test-lib.sh
66

7-
sanitize_conflicted_diff () {
7+
print_sanitized_conflicted_diff () {
8+
git diff HEAD >diff.raw &&
89
sed -e '
910
/^index /d
1011
s/^\(+[<>][<>][<>][<>]*\) .*/\1/
11-
'
12+
' diff.raw
1213
}
1314

1415
test_expect_success setup '
@@ -54,14 +55,14 @@ test_expect_success 'apply with --3way' '
5455
git checkout master^0 &&
5556
test_must_fail git merge --no-commit side &&
5657
git ls-files -s >expect.ls &&
57-
git diff HEAD | sanitize_conflicted_diff >expect.diff &&
58+
print_sanitized_conflicted_diff >expect.diff &&
5859
5960
# should fail to apply
6061
git reset --hard &&
6162
git checkout master^0 &&
6263
test_must_fail git apply --index --3way P.diff &&
6364
git ls-files -s >actual.ls &&
64-
git diff HEAD | sanitize_conflicted_diff >actual.diff &&
65+
print_sanitized_conflicted_diff >actual.diff &&
6566
6667
# The result should resemble the corresponding merge
6768
test_cmp expect.ls actual.ls &&
@@ -114,7 +115,7 @@ test_expect_success 'apply -3 with add/add conflict setup' '
114115
git checkout adder^0 &&
115116
test_must_fail git merge --no-commit another &&
116117
git ls-files -s >expect.ls &&
117-
git diff HEAD | sanitize_conflicted_diff >expect.diff
118+
print_sanitized_conflicted_diff >expect.diff
118119
'
119120

120121
test_expect_success 'apply -3 with add/add conflict' '
@@ -124,7 +125,7 @@ test_expect_success 'apply -3 with add/add conflict' '
124125
test_must_fail git apply --index --3way P.diff &&
125126
# ... and leave conflicts in the index and in the working tree
126127
git ls-files -s >actual.ls &&
127-
git diff HEAD | sanitize_conflicted_diff >actual.diff &&
128+
print_sanitized_conflicted_diff >actual.diff &&
128129
129130
# The result should resemble the corresponding merge
130131
test_cmp expect.ls actual.ls &&

0 commit comments

Comments
 (0)