Re: [PATCH] submodule: Respect reqested branch on all clones
- From
Francesco Pretto <ceztko@gmail.com>
- Date
- Jan 5, 2014, 03:53 UTC
- Message-ID
- <CALas-ii90x07Kbxzy_siBJV_RHPkvBw7spFBD9vi6o43mU1k6g@mail.gmail.com>
- In-Reply-To
- <dad947caba9e1c49d691ffccc868cfdce7d04e82.1388772192.git.wking@tremily.us>
Thanks for adding your contribute. My comments below:
2014/1/3 W. Trevor King <wking@tremily.us>:
Show 21 quoted lines
> > The previous code only checked out the requested branch in cmd_add. > This commit moves the branch-checkout logic into module_clone, where > it can be shared by cmd_add and cmd_update. I also update the initial > checkout command to use 'rebase' to preserve branches setup during > module_clone. > [...] > @@ -306,7 +307,14 @@ module_clone() > echo "gitdir: $rel/$a" >"$sm_path/.git" > > rel=$(echo $a | sed -e 's|[^/][^/]*|..|g') > - (clear_local_git_env; cd "$sm_path" && GIT_WORK_TREE=. git config core.worktree "$rel/$b") > + ( > + clear_local_git_env > + cd "$sm_path" && > + GIT_WORK_TREE=. git config core.worktree "$rel/$b" && > + if test -n "$branch"; then > + git checkout -f -q -B "$branch" "origin/$branch" && echo "checked out $branch" > + fi > + ) || die "$(eval_gettext "Unable to setup cloned submodule '\$sm_path'")" > }
If I understand it correctly, looking at your intervention in module_clone and cmd_update, when "submodule.<module>.branch" is set during "update" the resulting first clone will always be a branch checkout (cause $branch is filled with "branch" property). I believe this will break a lot of tests, as the the documentation says that in this configuration the HEAD should be detached. Also it could break some users that rely on the current behavior.