mirror of
https://github.com/git/git.git
synced 2024-11-28 12:34:08 +08:00
Merge branch 'sb/submodule-path-misc-bugs' into maint
"git submodule" reports the paths of submodules the command recurses into, but this was incorrect when the command was not run from the root level of the superproject. * sb/submodule-path-misc-bugs: t7407: make expectation as clear as possible submodule update: test recursive path reporting from subdirectory submodule update: align reporting path for custom command execution submodule status: correct path handling in recursive submodules submodule update --init: correct path handling in recursive submodules submodule foreach: correct path display in recursive submodules
This commit is contained in:
commit
cc601901a7
@ -413,8 +413,8 @@ cmd_foreach()
|
||||
die_if_unmatched "$mode"
|
||||
if test -e "$sm_path"/.git
|
||||
then
|
||||
displaypath=$(relative_path "$sm_path")
|
||||
say "$(eval_gettext "Entering '\$prefix\$displaypath'")"
|
||||
displaypath=$(relative_path "$prefix$sm_path")
|
||||
say "$(eval_gettext "Entering '\$displaypath'")"
|
||||
name=$(git submodule--helper name "$sm_path")
|
||||
(
|
||||
prefix="$prefix$sm_path/"
|
||||
@ -434,7 +434,7 @@ cmd_foreach()
|
||||
cmd_foreach "--recursive" "$@"
|
||||
fi
|
||||
) <&3 3<&- ||
|
||||
die "$(eval_gettext "Stopping at '\$prefix\$displaypath'; script returned non-zero status.")"
|
||||
die "$(eval_gettext "Stopping at '\$displaypath'; script returned non-zero status.")"
|
||||
fi
|
||||
done
|
||||
}
|
||||
@ -473,7 +473,7 @@ cmd_init()
|
||||
die_if_unmatched "$mode"
|
||||
name=$(git submodule--helper name "$sm_path") || exit
|
||||
|
||||
displaypath=$(relative_path "$sm_path")
|
||||
displaypath=$(relative_path "$prefix$sm_path")
|
||||
|
||||
# Copy url setting when it is not set yet
|
||||
if test -z "$(git config "submodule.$name.url")"
|
||||
@ -802,8 +802,8 @@ Maybe you want to use 'update --init'?")"
|
||||
;;
|
||||
!*)
|
||||
command="${update_module#!}"
|
||||
die_msg="$(eval_gettext "Execution of '\$command \$sha1' failed in submodule path '\$prefix\$sm_path'")"
|
||||
say_msg="$(eval_gettext "Submodule path '\$prefix\$sm_path': '\$command \$sha1'")"
|
||||
die_msg="$(eval_gettext "Execution of '\$command \$sha1' failed in submodule path '\$displaypath'")"
|
||||
say_msg="$(eval_gettext "Submodule path '\$displaypath': '\$command \$sha1'")"
|
||||
must_die_on_failure=yes
|
||||
;;
|
||||
*)
|
||||
@ -1159,6 +1159,7 @@ cmd_status()
|
||||
(
|
||||
prefix="$displaypath/"
|
||||
clear_local_git_env
|
||||
wt_prefix=
|
||||
cd "$sm_path" &&
|
||||
eval cmd_status
|
||||
) ||
|
||||
|
@ -63,6 +63,10 @@ test_expect_success 'setup a submodule tree' '
|
||||
git submodule add ../none none &&
|
||||
test_tick &&
|
||||
git commit -m "none"
|
||||
) &&
|
||||
git clone . recursivesuper &&
|
||||
( cd recursivesuper
|
||||
git submodule add ../super super
|
||||
)
|
||||
'
|
||||
|
||||
@ -95,6 +99,35 @@ test_expect_success 'submodule update from subdirectory' '
|
||||
)
|
||||
'
|
||||
|
||||
supersha1=$(git -C super rev-parse HEAD)
|
||||
mergingsha1=$(git -C super/merging rev-parse HEAD)
|
||||
nonesha1=$(git -C super/none rev-parse HEAD)
|
||||
rebasingsha1=$(git -C super/rebasing rev-parse HEAD)
|
||||
submodulesha1=$(git -C super/submodule rev-parse HEAD)
|
||||
pwd=$(pwd)
|
||||
|
||||
cat <<EOF >expect
|
||||
Submodule path '../super': checked out '$supersha1'
|
||||
Submodule 'merging' ($pwd/merging) registered for path '../super/merging'
|
||||
Submodule 'none' ($pwd/none) registered for path '../super/none'
|
||||
Submodule 'rebasing' ($pwd/rebasing) registered for path '../super/rebasing'
|
||||
Submodule 'submodule' ($pwd/submodule) registered for path '../super/submodule'
|
||||
Submodule path '../super/merging': checked out '$mergingsha1'
|
||||
Submodule path '../super/none': checked out '$nonesha1'
|
||||
Submodule path '../super/rebasing': checked out '$rebasingsha1'
|
||||
Submodule path '../super/submodule': checked out '$submodulesha1'
|
||||
EOF
|
||||
|
||||
test_expect_success 'submodule update --init --recursive from subdirectory' '
|
||||
git -C recursivesuper/super reset --hard HEAD^ &&
|
||||
(cd recursivesuper &&
|
||||
mkdir tmp &&
|
||||
cd tmp &&
|
||||
git submodule update --init --recursive ../super >../../actual
|
||||
) &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
apos="'";
|
||||
test_expect_success 'submodule update does not fetch already present commits' '
|
||||
(cd submodule &&
|
||||
@ -311,16 +344,59 @@ test_expect_success 'submodule update - command in .git/config' '
|
||||
)
|
||||
'
|
||||
|
||||
cat << EOF >expect
|
||||
Execution of 'false $submodulesha1' failed in submodule path 'submodule'
|
||||
EOF
|
||||
|
||||
test_expect_success 'submodule update - command in .git/config catches failure' '
|
||||
(cd super &&
|
||||
git config submodule.submodule.update "!false"
|
||||
) &&
|
||||
(cd super/submodule &&
|
||||
git reset --hard HEAD^
|
||||
git reset --hard $submodulesha1^
|
||||
) &&
|
||||
(cd super &&
|
||||
test_must_fail git submodule update submodule
|
||||
)
|
||||
test_must_fail git submodule update submodule 2>../actual
|
||||
) &&
|
||||
test_cmp actual expect
|
||||
'
|
||||
|
||||
cat << EOF >expect
|
||||
Execution of 'false $submodulesha1' failed in submodule path '../submodule'
|
||||
EOF
|
||||
|
||||
test_expect_success 'submodule update - command in .git/config catches failure -- subdirectory' '
|
||||
(cd super &&
|
||||
git config submodule.submodule.update "!false"
|
||||
) &&
|
||||
(cd super/submodule &&
|
||||
git reset --hard $submodulesha1^
|
||||
) &&
|
||||
(cd super &&
|
||||
mkdir tmp && cd tmp &&
|
||||
test_must_fail git submodule update ../submodule 2>../../actual
|
||||
) &&
|
||||
test_cmp actual expect
|
||||
'
|
||||
|
||||
cat << EOF >expect
|
||||
Execution of 'false $submodulesha1' failed in submodule path '../super/submodule'
|
||||
Failed to recurse into submodule path '../super'
|
||||
EOF
|
||||
|
||||
test_expect_success 'recursive submodule update - command in .git/config catches failure -- subdirectory' '
|
||||
(cd recursivesuper &&
|
||||
git submodule update --remote super &&
|
||||
git add super &&
|
||||
git commit -m "update to latest to have more than one commit in submodules"
|
||||
) &&
|
||||
git -C recursivesuper/super config submodule.submodule.update "!false" &&
|
||||
git -C recursivesuper/super/submodule reset --hard $submodulesha1^ &&
|
||||
(cd recursivesuper &&
|
||||
mkdir -p tmp && cd tmp &&
|
||||
test_must_fail git submodule update --recursive ../super 2>../../actual
|
||||
) &&
|
||||
test_cmp actual expect
|
||||
'
|
||||
|
||||
test_expect_success 'submodule init does not copy command into .git/config' '
|
||||
|
@ -177,6 +177,26 @@ test_expect_success 'test messages from "foreach --recursive"' '
|
||||
test_i18ncmp expect actual
|
||||
'
|
||||
|
||||
cat > expect <<EOF
|
||||
Entering '../nested1'
|
||||
Entering '../nested1/nested2'
|
||||
Entering '../nested1/nested2/nested3'
|
||||
Entering '../nested1/nested2/nested3/submodule'
|
||||
Entering '../sub1'
|
||||
Entering '../sub2'
|
||||
Entering '../sub3'
|
||||
EOF
|
||||
|
||||
test_expect_success 'test messages from "foreach --recursive" from subdirectory' '
|
||||
(
|
||||
cd clone2 &&
|
||||
mkdir untracked &&
|
||||
cd untracked &&
|
||||
git submodule foreach --recursive >../../actual
|
||||
) &&
|
||||
test_i18ncmp expect actual
|
||||
'
|
||||
|
||||
cat > expect <<EOF
|
||||
nested1-nested1
|
||||
nested2-nested2
|
||||
@ -242,8 +262,12 @@ test_expect_success 'test "status --recursive"' '
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
sed -e "/nested2 /s/.*/+$nested2sha1 nested1\/nested2 (file2~1)/;/sub[1-3]/d" < expect > expect2
|
||||
mv -f expect2 expect
|
||||
cat > expect <<EOF
|
||||
$nested1sha1 nested1 (heads/master)
|
||||
+$nested2sha1 nested1/nested2 (file2~1)
|
||||
$nested3sha1 nested1/nested2/nested3 (heads/master)
|
||||
$submodulesha1 nested1/nested2/nested3/submodule (heads/master)
|
||||
EOF
|
||||
|
||||
test_expect_success 'ensure "status --cached --recursive" preserves the --cached flag' '
|
||||
(
|
||||
@ -257,6 +281,27 @@ test_expect_success 'ensure "status --cached --recursive" preserves the --cached
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
nested2sha1=$(git -C clone3/nested1/nested2 rev-parse HEAD)
|
||||
|
||||
cat > expect <<EOF
|
||||
$nested1sha1 ../nested1 (heads/master)
|
||||
+$nested2sha1 ../nested1/nested2 (file2)
|
||||
$nested3sha1 ../nested1/nested2/nested3 (heads/master)
|
||||
$submodulesha1 ../nested1/nested2/nested3/submodule (heads/master)
|
||||
$sub1sha1 ../sub1 ($sub1sha1_short)
|
||||
$sub2sha1 ../sub2 ($sub2sha1_short)
|
||||
$sub3sha1 ../sub3 (heads/master)
|
||||
EOF
|
||||
|
||||
test_expect_success 'test "status --recursive" from sub directory' '
|
||||
(
|
||||
cd clone3 &&
|
||||
mkdir tmp && cd tmp &&
|
||||
git submodule status --recursive > ../../actual
|
||||
) &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'use "git clone --recursive" to checkout all submodules' '
|
||||
git clone --recursive super clone4 &&
|
||||
(
|
||||
|
Loading…
Reference in New Issue
Block a user