Merge branch 'km/submodule-add-errmsg'
Improve error message generation for "git submodule add". * km/submodule-add-errmsg: submodule add: show 'add --dry-run' stderr when aborting
This commit is contained in:
commit
25794d6ce9
@ -241,13 +241,15 @@ cmd_add()
|
|||||||
die "$(eval_gettext "'\$sm_path' does not have a commit checked out")"
|
die "$(eval_gettext "'\$sm_path' does not have a commit checked out")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test -z "$force" &&
|
if test -z "$force"
|
||||||
! git add --dry-run --ignore-missing --no-warn-embedded-repo "$sm_path" > /dev/null 2>&1
|
|
||||||
then
|
then
|
||||||
eval_gettextln "The following path is ignored by one of your .gitignore files:
|
dryerr=$(git add --dry-run --ignore-missing --no-warn-embedded-repo "$sm_path" 2>&1 >/dev/null)
|
||||||
\$sm_path
|
res=$?
|
||||||
Use -f if you really want to add it." >&2
|
if test $res -ne 0
|
||||||
exit 1
|
then
|
||||||
|
echo >&2 "$dryerr"
|
||||||
|
exit $res
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test -n "$custom_name"
|
if test -n "$custom_name"
|
||||||
|
@ -156,9 +156,9 @@ test_expect_success 'submodule add to .gitignored path fails' '
|
|||||||
(
|
(
|
||||||
cd addtest-ignore &&
|
cd addtest-ignore &&
|
||||||
cat <<-\EOF >expect &&
|
cat <<-\EOF >expect &&
|
||||||
The following path is ignored by one of your .gitignore files:
|
The following paths are ignored by one of your .gitignore files:
|
||||||
submod
|
submod
|
||||||
Use -f if you really want to add it.
|
Use -f if you really want to add them.
|
||||||
EOF
|
EOF
|
||||||
# Does not use test_commit due to the ignore
|
# Does not use test_commit due to the ignore
|
||||||
echo "*" > .gitignore &&
|
echo "*" > .gitignore &&
|
||||||
@ -191,6 +191,17 @@ test_expect_success 'submodule add to reconfigure existing submodule with --forc
|
|||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'submodule add relays add --dry-run stderr' '
|
||||||
|
test_when_finished "rm -rf addtest/.git/index.lock" &&
|
||||||
|
(
|
||||||
|
cd addtest &&
|
||||||
|
: >.git/index.lock &&
|
||||||
|
! git submodule add "$submodurl" sub-while-locked 2>output.err &&
|
||||||
|
test_i18ngrep "^fatal: .*index\.lock" output.err &&
|
||||||
|
test_path_is_missing sub-while-locked
|
||||||
|
)
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'submodule add --branch' '
|
test_expect_success 'submodule add --branch' '
|
||||||
echo "refs/heads/initial" >expect-head &&
|
echo "refs/heads/initial" >expect-head &&
|
||||||
cat <<-\EOF >expect-heads &&
|
cat <<-\EOF >expect-heads &&
|
||||||
|
Loading…
Reference in New Issue
Block a user