зеркало из https://github.com/microsoft/git.git
Merge branch 'sb/submodule-path-misc-bugs'
"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:
Коммит
6a0f105a21
|
@ -423,8 +423,8 @@ cmd_foreach()
|
||||||
die_if_unmatched "$mode"
|
die_if_unmatched "$mode"
|
||||||
if test -e "$sm_path"/.git
|
if test -e "$sm_path"/.git
|
||||||
then
|
then
|
||||||
displaypath=$(relative_path "$sm_path")
|
displaypath=$(relative_path "$prefix$sm_path")
|
||||||
say "$(eval_gettext "Entering '\$prefix\$displaypath'")"
|
say "$(eval_gettext "Entering '\$displaypath'")"
|
||||||
name=$(git submodule--helper name "$sm_path")
|
name=$(git submodule--helper name "$sm_path")
|
||||||
(
|
(
|
||||||
prefix="$prefix$sm_path/"
|
prefix="$prefix$sm_path/"
|
||||||
|
@ -444,7 +444,7 @@ cmd_foreach()
|
||||||
cmd_foreach "--recursive" "$@"
|
cmd_foreach "--recursive" "$@"
|
||||||
fi
|
fi
|
||||||
) <&3 3<&- ||
|
) <&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
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
@ -483,7 +483,7 @@ cmd_init()
|
||||||
die_if_unmatched "$mode"
|
die_if_unmatched "$mode"
|
||||||
name=$(git submodule--helper name "$sm_path") || exit
|
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
|
# Copy url setting when it is not set yet
|
||||||
if test -z "$(git config "submodule.$name.url")"
|
if test -z "$(git config "submodule.$name.url")"
|
||||||
|
@ -800,8 +800,8 @@ cmd_update()
|
||||||
;;
|
;;
|
||||||
!*)
|
!*)
|
||||||
command="${update_module#!}"
|
command="${update_module#!}"
|
||||||
die_msg="$(eval_gettext "Execution of '\$command \$sha1' failed in submodule path '\$prefix\$sm_path'")"
|
die_msg="$(eval_gettext "Execution of '\$command \$sha1' failed in submodule path '\$displaypath'")"
|
||||||
say_msg="$(eval_gettext "Submodule path '\$prefix\$sm_path': '\$command \$sha1'")"
|
say_msg="$(eval_gettext "Submodule path '\$displaypath': '\$command \$sha1'")"
|
||||||
must_die_on_failure=yes
|
must_die_on_failure=yes
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
@ -1157,6 +1157,7 @@ cmd_status()
|
||||||
(
|
(
|
||||||
prefix="$displaypath/"
|
prefix="$displaypath/"
|
||||||
sanitize_submodule_env
|
sanitize_submodule_env
|
||||||
|
wt_prefix=
|
||||||
cd "$sm_path" &&
|
cd "$sm_path" &&
|
||||||
eval cmd_status
|
eval cmd_status
|
||||||
) ||
|
) ||
|
||||||
|
|
|
@ -63,6 +63,10 @@ test_expect_success 'setup a submodule tree' '
|
||||||
git submodule add ../none none &&
|
git submodule add ../none none &&
|
||||||
test_tick &&
|
test_tick &&
|
||||||
git commit -m "none"
|
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="'";
|
apos="'";
|
||||||
test_expect_success 'submodule update does not fetch already present commits' '
|
test_expect_success 'submodule update does not fetch already present commits' '
|
||||||
(cd submodule &&
|
(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' '
|
test_expect_success 'submodule update - command in .git/config catches failure' '
|
||||||
(cd super &&
|
(cd super &&
|
||||||
git config submodule.submodule.update "!false"
|
git config submodule.submodule.update "!false"
|
||||||
) &&
|
) &&
|
||||||
(cd super/submodule &&
|
(cd super/submodule &&
|
||||||
git reset --hard HEAD^
|
git reset --hard $submodulesha1^
|
||||||
) &&
|
) &&
|
||||||
(cd super &&
|
(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' '
|
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
|
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
|
cat > expect <<EOF
|
||||||
nested1-nested1
|
nested1-nested1
|
||||||
nested2-nested2
|
nested2-nested2
|
||||||
|
@ -242,8 +262,12 @@ test_expect_success 'test "status --recursive"' '
|
||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
'
|
'
|
||||||
|
|
||||||
sed -e "/nested2 /s/.*/+$nested2sha1 nested1\/nested2 (file2~1)/;/sub[1-3]/d" < expect > expect2
|
cat > expect <<EOF
|
||||||
mv -f expect2 expect
|
$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' '
|
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
|
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' '
|
test_expect_success 'use "git clone --recursive" to checkout all submodules' '
|
||||||
git clone --recursive super clone4 &&
|
git clone --recursive super clone4 &&
|
||||||
(
|
(
|
||||||
|
|
Загрузка…
Ссылка в новой задаче