Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2021-09-21 01:20:44 +0300
committerJunio C Hamano <gitster@pobox.com>2021-09-21 01:20:44 +0300
commite78db9d3037eba812591857e7b44e69b97b329f4 (patch)
tree593a950db49acb905707c472d185f0fae1ce7c0b /git-submodule.sh
parent1b8bd2243e7fd7878cdfadb9cc7678ae0bb1a30a (diff)
parentc51f8f94e5b3d6a8d190d9901ea0c5b83e30c3aa (diff)
Merge branch 'ar/submodule-run-update-procedure'
Reimplementation of parts of "git submodule" in C continues. * ar/submodule-run-update-procedure: submodule--helper: run update procedures from C
Diffstat (limited to 'git-submodule.sh')
-rwxr-xr-xgit-submodule.sh106
1 files changed, 33 insertions, 73 deletions
diff --git a/git-submodule.sh b/git-submodule.sh
index 1070540525..27efdc5774 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -251,13 +251,6 @@ cmd_deinit()
git ${wt_prefix:+-C "$wt_prefix"} submodule--helper deinit ${GIT_QUIET:+--quiet} ${force:+--force} ${deinit_all:+--all} -- "$@"
}
-is_tip_reachable () (
- sanitize_submodule_env &&
- cd "$1" &&
- rev=$(git rev-list -n 1 "$2" --not --all 2>/dev/null) &&
- test -z "$rev"
-)
-
# usage: fetch_in_submodule <module_path> [<depth>] [<sha1>]
# Because arguments are positional, use an empty string to omit <depth>
# but include <sha1>.
@@ -401,14 +394,13 @@ cmd_update()
git submodule--helper ensure-core-worktree "$sm_path" || exit 1
- update_module=$(git submodule--helper update-module-mode $just_cloned "$sm_path" $update)
-
displaypath=$(git submodule--helper relative-path "$prefix$sm_path" "$wt_prefix")
if test $just_cloned -eq 1
then
subsha1=
else
+ just_cloned=
subsha1=$(sanitize_submodule_env; cd "$sm_path" &&
git rev-parse --verify HEAD) ||
die "fatal: $(eval_gettext "Unable to find current revision in submodule path '\$displaypath'")"
@@ -429,70 +421,38 @@ cmd_update()
die "fatal: $(eval_gettext "Unable to find current \${remote_name}/\${branch} revision in submodule path '\$sm_path'")"
fi
- if test "$subsha1" != "$sha1" || test -n "$force"
- then
- subforce=$force
- # If we don't already have a -f flag and the submodule has never been checked out
- if test -z "$subsha1" && test -z "$force"
- then
- subforce="-f"
- fi
-
- if test -z "$nofetch"
- then
- # Run fetch only if $sha1 isn't present or it
- # is not reachable from a ref.
- is_tip_reachable "$sm_path" "$sha1" ||
- fetch_in_submodule "$sm_path" $depth ||
- say "$(eval_gettext "Unable to fetch in submodule path '\$displaypath'; trying to directly fetch \$sha1:")"
-
- # Now we tried the usual fetch, but $sha1 may
- # not be reachable from any of the refs
- is_tip_reachable "$sm_path" "$sha1" ||
- fetch_in_submodule "$sm_path" "$depth" "$sha1" ||
- die "fatal: $(eval_gettext "Fetched in submodule path '\$displaypath', but it did not contain \$sha1. Direct fetching of that commit failed.")"
- fi
-
- must_die_on_failure=
- case "$update_module" in
- checkout)
- command="git checkout $subforce -q"
- die_msg="fatal: $(eval_gettext "Unable to checkout '\$sha1' in submodule path '\$displaypath'")"
- say_msg="$(eval_gettext "Submodule path '\$displaypath': checked out '\$sha1'")"
- ;;
- rebase)
- command="git rebase ${GIT_QUIET:+--quiet}"
- die_msg="fatal: $(eval_gettext "Unable to rebase '\$sha1' in submodule path '\$displaypath'")"
- say_msg="$(eval_gettext "Submodule path '\$displaypath': rebased into '\$sha1'")"
- must_die_on_failure=yes
- ;;
- merge)
- command="git merge ${GIT_QUIET:+--quiet}"
- die_msg="fatal: $(eval_gettext "Unable to merge '\$sha1' in submodule path '\$displaypath'")"
- say_msg="$(eval_gettext "Submodule path '\$displaypath': merged in '\$sha1'")"
- must_die_on_failure=yes
- ;;
- !*)
- command="${update_module#!}"
- die_msg="fatal: $(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
- ;;
- *)
- die "fatal: $(eval_gettext "Invalid update mode '$update_module' for submodule path '$path'")"
- esac
-
- if (sanitize_submodule_env; cd "$sm_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
+ out=$(git submodule--helper run-update-procedure \
+ ${wt_prefix:+--prefix "$wt_prefix"} \
+ ${GIT_QUIET:+--quiet} \
+ ${force:+--force} \
+ ${just_cloned:+--just-cloned} \
+ ${nofetch:+--no-fetch} \
+ ${depth:+"$depth"} \
+ ${update:+--update "$update"} \
+ ${prefix:+--recursive-prefix "$prefix"} \
+ ${sha1:+--oid "$sha1"} \
+ ${subsha1:+--suboid "$subsha1"} \
+ "--" \
+ "$sm_path")
+
+ # exit codes for run-update-procedure:
+ # 0: update was successful, say command output
+ # 1: update procedure failed, but should not die
+ # 2 or 128: subcommand died during execution
+ # 3: no update procedure was run
+ res="$?"
+ case $res in
+ 0)
+ say "$out"
+ ;;
+ 1)
+ err="${err};fatal: $out"
+ continue
+ ;;
+ 2|128)
+ die_with_status $res "fatal: $out"
+ ;;
+ esac
if test -n "$recursive"
then