Skip to content

Commit 1b4735d

Browse files
olsonsegitster
authored andcommitted
submodule: no [--merge|--rebase] when newly cloned
"git submodule update" can be run with either the "--merge" or "--rebase" option, or submodule.<name>.update configuration variable can be set to "merge" or "rebase, to cause local work to get integrated when updating the submodule. When a submodule is newly cloned, however, it does not have a check out when a rebase or merge is attempted, leading to a failure. For newly cloned submodules, simply check out the appropriate revision. There is no local work to integrate with for them. Signed-off-by: Spencer E. Olson <[email protected]> Acked-by: Jens Lehmann <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7ed863a commit 1b4735d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

git-submodule.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ cmd_update()
423423
cmd_init "--" "$@" || return
424424
fi
425425

426+
cloned_modules=
426427
module_list "$@" |
427428
while read mode sha1 stage path
428429
do
@@ -442,6 +443,7 @@ cmd_update()
442443
if ! test -d "$path"/.git -o -f "$path"/.git
443444
then
444445
module_clone "$path" "$url" "$reference"|| exit
446+
cloned_modules="$cloned_modules;$name"
445447
subsha1=
446448
else
447449
subsha1=$(clear_local_git_env; cd "$path" &&
@@ -469,6 +471,13 @@ cmd_update()
469471
die "Unable to fetch in submodule path '$path'"
470472
fi
471473

474+
# Is this something we just cloned?
475+
case ";$cloned_modules;" in
476+
*";$name;"*)
477+
# then there is no local change to integrate
478+
update_module= ;;
479+
esac
480+
472481
case "$update_module" in
473482
rebase)
474483
command="git rebase"

0 commit comments

Comments
 (0)