Browse Source

Merge branch 'fg/submodule-keep-updating'

* fg/submodule-keep-updating:
  git-submodule.sh: clarify the "should we die now" logic
  submodule update: continue when a checkout fails
  git-sh-setup: add die_with_status

Conflicts:
	git-submodule.sh
maint
Junio C Hamano 14 years ago
parent
commit
ff968f03e6
  1. 12
      git-sh-setup.sh
  2. 49
      git-submodule.sh
  3. 144
      t/t7406-submodule-update.sh

12
git-sh-setup.sh

@ -39,9 +39,15 @@ git_broken_path_fix () { @@ -39,9 +39,15 @@ git_broken_path_fix () {

# @@BROKEN_PATH_FIX@@

die() {
echo >&2 "$@"
exit 1
die () {
die_with_status 1 "$@"
}

die_with_status () {
status=$1
shift
echo >&2 "$*"
exit "$status"
}

GIT_QUIET=

49
git-submodule.sh

@ -448,7 +448,8 @@ cmd_update() @@ -448,7 +448,8 @@ cmd_update()
fi

cloned_modules=
module_list "$@" |
module_list "$@" | {
err=
while read mode sha1 stage path
do
if test "$stage" = U
@ -511,16 +512,19 @@ Maybe you want to use 'update --init'?")" @@ -511,16 +512,19 @@ Maybe you want to use 'update --init'?")"
update_module= ;;
esac

must_die_on_failure=
case "$update_module" in
rebase)
command="git rebase"
die_msg="$(eval_gettext "Unable to rebase '\$sha1' in submodule path '\$path'")"
say_msg="$(eval_gettext "Submodule path '\$path': rebased into '\$sha1'")"
must_die_on_failure=yes
;;
merge)
command="git merge"
die_msg="$(eval_gettext "Unable to merge '\$sha1' in submodule path '\$path'")"
say_msg="$(eval_gettext "Submodule path '\$path': merged in '\$sha1'")"
must_die_on_failure=yes
;;
*)
command="git checkout $subforce -q"
@ -529,16 +533,51 @@ Maybe you want to use 'update --init'?")" @@ -529,16 +533,51 @@ Maybe you want to use 'update --init'?")"
;;
esac

(clear_local_git_env; cd "$path" && $command "$sha1") || die $die_msg
say $say_msg
if (clear_local_git_env; cd "$path" && $command "$sha1")
then
say "$say_msg"
elif test -n "$must_die_on_failure"
then
die_with_status 2 "$die_msg"
else
err="${err};$die_msg"
continue
fi
fi

if test -n "$recursive"
then
(clear_local_git_env; cd "$path" && eval cmd_update "$orig_flags") ||
die "$(eval_gettext "Failed to recurse into submodule path '\$path'")"
(clear_local_git_env; cd "$path" && eval cmd_update "$orig_flags")
res=$?
if test $res -gt 0
then
die_msg="$(eval_gettext "Failed to recurse into submodule path '\$path'")"
if test $res -eq 1
then
err="${err};$die_msg"
continue
else
die_with_status $res "$die_msg"
fi
fi
fi
done

if test -n "$err"
then
OIFS=$IFS
IFS=';'
for e in $err
do
if test -n "$e"
then
echo >&2 "$e"
fi
done
IFS=$OIFS
exit 1
fi
}
}

set_name_rev () {

144
t/t7406-submodule-update.sh

@ -298,4 +298,148 @@ test_expect_success 'submodule update ignores update=rebase config for new submo @@ -298,4 +298,148 @@ test_expect_success 'submodule update ignores update=rebase config for new submo
)
'

test_expect_success 'submodule update continues after checkout error' '
(cd super &&
git reset --hard HEAD &&
git submodule add ../submodule submodule2 &&
git submodule init &&
git commit -am "new_submodule" &&
(cd submodule2 &&
git rev-parse --max-count=1 HEAD > ../expect
) &&
(cd submodule &&
test_commit "update_submodule" file
) &&
(cd submodule2 &&
test_commit "update_submodule2" file
) &&
git add submodule &&
git add submodule2 &&
git commit -m "two_new_submodule_commits" &&
(cd submodule &&
echo "" > file
) &&
git checkout HEAD^ &&
test_must_fail git submodule update &&
(cd submodule2 &&
git rev-parse --max-count=1 HEAD > ../actual
) &&
test_cmp expect actual
)
'
test_expect_success 'submodule update continues after recursive checkout error' '
(cd super &&
git reset --hard HEAD &&
git checkout master &&
git submodule update &&
(cd submodule &&
git submodule add ../submodule subsubmodule &&
git submodule init &&
git commit -m "new_subsubmodule"
) &&
git add submodule &&
git commit -m "update_submodule" &&
(cd submodule &&
(cd subsubmodule &&
test_commit "update_subsubmodule" file
) &&
git add subsubmodule &&
test_commit "update_submodule_again" file &&
(cd subsubmodule &&
test_commit "update_subsubmodule_again" file
) &&
test_commit "update_submodule_again_again" file
) &&
(cd submodule2 &&
git rev-parse --max-count=1 HEAD > ../expect &&
test_commit "update_submodule2_again" file
) &&
git add submodule &&
git add submodule2 &&
git commit -m "new_commits" &&
git checkout HEAD^ &&
(cd submodule &&
git checkout HEAD^ &&
(cd subsubmodule &&
echo "" > file
)
) &&
test_must_fail git submodule update --recursive &&
(cd submodule2 &&
git rev-parse --max-count=1 HEAD > ../actual
) &&
test_cmp expect actual
)
'

test_expect_success 'submodule update exit immediately in case of merge conflict' '
(cd super &&
git checkout master &&
git reset --hard HEAD &&
(cd submodule &&
(cd subsubmodule &&
git reset --hard HEAD
)
) &&
git submodule update --recursive &&
(cd submodule &&
test_commit "update_submodule_2" file
) &&
(cd submodule2 &&
test_commit "update_submodule2_2" file
) &&
git add submodule &&
git add submodule2 &&
git commit -m "two_new_submodule_commits" &&
(cd submodule &&
git checkout master &&
test_commit "conflict" file &&
echo "conflict" > file
) &&
git checkout HEAD^ &&
(cd submodule2 &&
git rev-parse --max-count=1 HEAD > ../expect
) &&
git config submodule.submodule.update merge &&
test_must_fail git submodule update &&
(cd submodule2 &&
git rev-parse --max-count=1 HEAD > ../actual
) &&
test_cmp expect actual
)
'
test_expect_success 'submodule update exit immediately after recursive rebase error' '
(cd super &&
git checkout master &&
git reset --hard HEAD &&
(cd submodule &&
git reset --hard HEAD &&
git submodule update --recursive
) &&
(cd submodule &&
test_commit "update_submodule_3" file
) &&
(cd submodule2 &&
test_commit "update_submodule2_3" file
) &&
git add submodule &&
git add submodule2 &&
git commit -m "two_new_submodule_commits" &&
(cd submodule &&
git checkout master &&
test_commit "conflict2" file &&
echo "conflict" > file
) &&
git checkout HEAD^ &&
(cd submodule2 &&
git rev-parse --max-count=1 HEAD > ../expect
) &&
git config submodule.submodule.update rebase &&
test_must_fail git submodule update &&
(cd submodule2 &&
git rev-parse --max-count=1 HEAD > ../actual
) &&
test_cmp expect actual
)
'
test_done

Loading…
Cancel
Save