@matheusbsbs / matheus-bagliano / commits / 1b4735d9f3
Fork 0

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 <olsonse@umich.edu> Acked-by: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Spencer E. Olson committed Feb 17, 2011 at 09:18 UTC 1b4735d9f3e0b7ea62c7c22f0afcb45e10c46c7e
1 file changed +9
git-submodule.sh
+9
@@ -423,6 +423,7 @@ cmd_update()
423 cmd_init "--" "$@" || return
424 fi
425
426 + cloned_modules=
427 module_list "$@" |
428 while read mode sha1 stage path
429 do
@@ -442,6 +443,7 @@ cmd_update()
443 if ! test -d "$path"/.git -o -f "$path"/.git
444 then
445 module_clone "$path" "$url" "$reference"|| exit
446 + cloned_modules="$cloned_modules;$name"
447 subsha1=
448 else
449 subsha1=$(clear_local_git_env; cd "$path" &&
@@ -469,6 +471,13 @@ cmd_update()
471 die "Unable to fetch in submodule path '$path'"
472 fi
473
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 +
481 case "$update_module" in
482 rebase)
483 command="git rebase"