File tree 2 files changed +21
-8
lines changed
2 files changed +21
-8
lines changed Original file line number Diff line number Diff line change @@ -241,13 +241,15 @@ cmd_add()
241
241
die " $( eval_gettext " '\$ sm_path' does not have a commit checked out" ) "
242
242
fi
243
243
244
- if test -z " $force " &&
245
- ! git add --dry-run --ignore-missing --no-warn-embedded-repo " $sm_path " > /dev/null 2>&1
244
+ if test -z " $force "
246
245
then
247
- eval_gettextln " The following path is ignored by one of your .gitignore files:
248
- \$ sm_path
249
- Use -f if you really want to add it." >&2
250
- exit 1
246
+ dryerr=$( git add --dry-run --ignore-missing --no-warn-embedded-repo " $sm_path " 2>&1 > /dev/null)
247
+ res=$?
248
+ if test $res -ne 0
249
+ then
250
+ echo >&2 " $dryerr "
251
+ exit $res
252
+ fi
251
253
fi
252
254
253
255
if test -n " $custom_name "
Original file line number Diff line number Diff line change @@ -156,9 +156,9 @@ test_expect_success 'submodule add to .gitignored path fails' '
156
156
(
157
157
cd addtest-ignore &&
158
158
cat <<-\EOF >expect &&
159
- The following path is ignored by one of your .gitignore files:
159
+ The following paths are ignored by one of your .gitignore files:
160
160
submod
161
- Use -f if you really want to add it .
161
+ Use -f if you really want to add them .
162
162
EOF
163
163
# Does not use test_commit due to the ignore
164
164
echo "*" > .gitignore &&
@@ -191,6 +191,17 @@ test_expect_success 'submodule add to reconfigure existing submodule with --forc
191
191
)
192
192
'
193
193
194
+ test_expect_success ' submodule add relays add --dry-run stderr' '
195
+ test_when_finished "rm -rf addtest/.git/index.lock" &&
196
+ (
197
+ cd addtest &&
198
+ : >.git/index.lock &&
199
+ ! git submodule add "$submodurl" sub-while-locked 2>output.err &&
200
+ test_i18ngrep "^fatal: .*index\.lock" output.err &&
201
+ test_path_is_missing sub-while-locked
202
+ )
203
+ '
204
+
194
205
test_expect_success ' submodule add --branch' '
195
206
echo "refs/heads/initial" >expect-head &&
196
207
cat <<-\EOF >expect-heads &&
You can’t perform that action at this time.
0 commit comments