Skip to content

Commit

Permalink
Merge branch 'so/submodule-no-update-first-time' into maint
Browse files Browse the repository at this point in the history
* so/submodule-no-update-first-time:
  t7406: "git submodule update {--merge|--rebase]" with new submodules
  submodule: no [--merge|--rebase] when newly cloned
  • Loading branch information
Junio C Hamano committed Mar 21, 2011
2 parents eec8a51 + b200021 commit 106040f
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
9 changes: 9 additions & 0 deletions git-submodule.sh
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ cmd_update()
cmd_init "--" "$@" || return
fi

cloned_modules=
module_list "$@" |
while read mode sha1 stage path
do
Expand All @@ -442,6 +443,7 @@ cmd_update()
if ! test -d "$path"/.git -o -f "$path"/.git
then
module_clone "$path" "$url" "$reference"|| exit
cloned_modules="$cloned_modules;$name"
subsha1=
else
subsha1=$(clear_local_git_env; cd "$path" &&
Expand Down Expand Up @@ -469,6 +471,13 @@ cmd_update()
die "Unable to fetch in submodule path '$path'"
fi

# Is this something we just cloned?
case ";$cloned_modules;" in
*";$name;"*)
# then there is no local change to integrate
update_module= ;;
esac

case "$update_module" in
rebase)
command="git rebase"
Expand Down
52 changes: 52 additions & 0 deletions t/t7406-submodule-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,56 @@ test_expect_success 'submodule init picks up merge' '
)
'

test_expect_success 'submodule update --merge - ignores --merge for new submodules' '
(cd super &&
rm -rf submodule &&
git submodule update submodule &&
git status -s submodule >expect &&
rm -rf submodule &&
git submodule update --merge submodule &&
git status -s submodule >actual &&
test_cmp expect actual
)
'

test_expect_success 'submodule update --rebase - ignores --rebase for new submodules' '
(cd super &&
rm -rf submodule &&
git submodule update submodule &&
git status -s submodule >expect &&
rm -rf submodule &&
git submodule update --rebase submodule &&
git status -s submodule >actual &&
test_cmp expect actual
)
'

test_expect_success 'submodule update ignores update=merge config for new submodules' '
(cd super &&
rm -rf submodule &&
git submodule update submodule &&
git status -s submodule >expect &&
rm -rf submodule &&
git config submodule.submodule.update merge &&
git submodule update submodule &&
git status -s submodule >actual &&
git config --unset submodule.submodule.update &&
test_cmp expect actual
)
'

test_expect_success 'submodule update ignores update=rebase config for new submodules' '
(cd super &&
rm -rf submodule &&
git submodule update submodule &&
git status -s submodule >expect &&
rm -rf submodule &&
git config submodule.submodule.update rebase &&
git submodule update submodule &&
git status -s submodule >actual &&
git config --unset submodule.submodule.update &&
test_cmp expect actual
)
'

test_done

0 comments on commit 106040f

Please sign in to comment.