@@ -91,58 +91,67 @@ test_expect_success 'difftool forwards arguments to diff' '
91
91
rm for-diff
92
92
'
93
93
94
- test_expect_success ' difftool ignores exit code' '
95
- test_config difftool.error.cmd false &&
96
- git difftool -y -t error branch
97
- '
94
+ for opt in ' ' ' --dir-diff'
95
+ do
96
+ test_expect_success " difftool ${opt} ignores exit code" "
97
+ test_config difftool.error.cmd false &&
98
+ git difftool ${opt} -y -t error branch
99
+ "
98
100
99
- test_expect_success ' difftool forwards exit code with --trust-exit-code' '
100
- test_config difftool.error.cmd false &&
101
- test_must_fail git difftool -y --trust-exit-code -t error branch
102
- '
101
+ test_expect_success " difftool ${opt} forwards exit code with --trust-exit-code" "
102
+ test_config difftool.error.cmd false &&
103
+ test_must_fail git difftool ${opt} -y --trust-exit-code -t error branch
104
+ "
103
105
104
- test_expect_success ' difftool forwards exit code with --trust-exit-code for built-ins' '
105
- test_config difftool.vimdiff.path false &&
106
- test_must_fail git difftool -y --trust-exit-code -t vimdiff branch
107
- '
106
+ test_expect_success " difftool ${opt} forwards exit code with --trust-exit-code for built-ins" "
107
+ test_config difftool.vimdiff.path false &&
108
+ test_must_fail git difftool ${opt} -y --trust-exit-code -t vimdiff branch
109
+ "
108
110
109
- test_expect_success ' difftool honors difftool.trustExitCode = true' '
110
- test_config difftool.error.cmd false &&
111
- test_config difftool.trustExitCode true &&
112
- test_must_fail git difftool -y -t error branch
113
- '
111
+ test_expect_success " difftool ${opt} honors difftool.trustExitCode = true" "
112
+ test_config difftool.error.cmd false &&
113
+ test_config difftool.trustExitCode true &&
114
+ test_must_fail git difftool ${opt} -y -t error branch
115
+ "
114
116
115
- test_expect_success ' difftool honors difftool.trustExitCode = false' '
116
- test_config difftool.error.cmd false &&
117
- test_config difftool.trustExitCode false &&
118
- git difftool -y -t error branch
119
- '
117
+ test_expect_success " difftool ${opt} honors difftool.trustExitCode = false" "
118
+ test_config difftool.error.cmd false &&
119
+ test_config difftool.trustExitCode false &&
120
+ git difftool ${opt} -y -t error branch
121
+ "
120
122
121
- test_expect_success ' difftool ignores exit code with --no-trust-exit-code' '
122
- test_config difftool.error.cmd false &&
123
- test_config difftool.trustExitCode true &&
124
- git difftool -y --no-trust-exit-code -t error branch
125
- '
123
+ test_expect_success " difftool ${opt} ignores exit code with --no-trust-exit-code" "
124
+ test_config difftool.error.cmd false &&
125
+ test_config difftool.trustExitCode true &&
126
+ git difftool ${opt} -y --no-trust-exit-code -t error branch
127
+ "
126
128
127
- test_expect_success ' difftool stops on error with --trust-exit-code' '
128
- test_when_finished " rm -f for-diff .git/fail-right-file" &&
129
- test_when_finished " git reset -- for-diff" &&
130
- write_script .git/fail-right-file <<-\EOF &&
131
- echo failed
132
- exit 1
133
- EOF
134
- >for-diff &&
135
- git add for-diff &&
136
- test_must_fail git difftool -y --trust-exit-code \
137
- --extcmd .git/fail-right-file branch >actual &&
138
- test_line_count = 1 actual
139
- '
129
+ test_expect_success " difftool ${opt} stops on error with --trust-exit-code" "
130
+ test_when_finished ' rm -f for-diff .git/fail-right-file' &&
131
+ test_when_finished ' git reset -- for-diff' &&
132
+ write_script .git/fail-right-file <<-\EOF &&
133
+ echo failed
134
+ exit 1
135
+ EOF
136
+ >for-diff &&
137
+ git add for-diff &&
138
+ test_must_fail git difftool ${opt} -y --trust-exit-code \
139
+ --extcmd .git/fail-right-file branch >actual &&
140
+ test_line_count = 1 actual
141
+ "
140
142
141
- test_expect_success ' difftool honors exit status if command not found' '
142
- test_config difftool.nonexistent.cmd i-dont-exist &&
143
- test_config difftool.trustExitCode false &&
144
- test_must_fail git difftool -y -t nonexistent branch
145
- '
143
+ test_expect_success " difftool ${opt} honors exit status if command not found" "
144
+ test_config difftool.nonexistent.cmd i-dont-exist &&
145
+ test_config difftool.trustExitCode false &&
146
+ if test " ${opt} " = '--dir-diff'
147
+ then
148
+ expected_code=127
149
+ else
150
+ expected_code=128
151
+ fi &&
152
+ test_expect_code \$ {expected_code} git difftool ${opt} -y -t nonexistent branch
153
+ "
154
+ done
146
155
147
156
test_expect_success ' difftool honors --gui' '
148
157
difftool_test_setup &&
0 commit comments