Skip to content

git-submodule add: Add --local-branch option

W. Trevor King git 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v4 Latest4 patches 12 repliesIn review

Changes in v4 from the cover letter

* --record=… is now --local-branch=…
* Dropped patches 2 ($submodule_ export) and 3 (motivating documentation)
* Added local git-config overrides of .gitmodules' submodule.<name>.branch
* Added submodule update --branch

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4git-submodule add: Add --local-branch optionDocumentation/git-submodule.txt Documentation/gitmodules.txt git-submodule.sh +1 more+58 -30 replies
2/4git-submodule init: Record submodule.<name>.branch in repository config.Documentation/config.txt git-submodule.sh t/t7400-submodule-basic.sh+30 -42 replies
3/4git-submodule update: Add --branch optionDocumentation/git-submodule.txt git-submodule.sh t/t7406-submodule-update.sh+98 -205 replies
4/4Hack fix for 'submodule update does not fetch already present commits'git-submodule.sh+1 -11 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v4 yet.

Read the v4 thread

Cover letter [PATCH v4 0/4] git-submodule add: Add --local-branch option

From: "W. Trevor King" <[email protected]>

Quoted 10 lines · W. Trevor King

We could add

  $ git submodule update --branch

to checkout the gitlinked SHA1 as submodule.<name>.branch in each of the submodules, leaving the submodules on the .gitmodules-configured branch. Effectively (for each submodule):

  $ git branch -f $branch $sha1
  $ git checkout $branch

I haven't gotten any feedback on this as an idea, but perhaps someone will comment on it as a patch series ;).

Changes since v3:

* --record=… is now --local-branch=…
* Dropped patches 2 ($submodule_ export) and 3 (motivating documentation)
* Added local git-config overrides of .gitmodules' submodule.<name>.branch
* Added submodule update --branch

Because you need to recurse through submodules for update --branch even if "$subsha1" == "$sha1", I had to amend the conditional controlling that block. This broke one of the existing tests, which I "fixed" in patch 4. I think a proper fix would involve rewriting

  (clear_local_git_env; cd "$sm_path" &&
   ( (rev=$(git rev-list -n 1 $sha1 --not --all 2>/dev/null) &&
    test -z "$rev") || git-fetch)) ||
  die "$(eval_gettext "Unable to fetch in submodule path '\$sm_path'")"

but I'm not familiar enough with rev-list to want to dig into that yet. If feedback for the earlier three patches is positive, I'll work up a clean fix and resubmit.

W. Trevor King (4):
git-submodule add: Add --local-branch option git-submodule init: Record submodule.<name>.branch in repository
config.
git-submodule update: Add --branch option
Hack fix for 'submodule update does not fetch already present
commits'

 Documentation/config.txt        |  9 ++---
 Documentation/git-submodule.txt | 32 ++++++++++++-----
 Documentation/gitmodules.txt    |  5 +++
 git-submodule.sh                | 76 +++++++++++++++++++++++++++++++++--------
 t/t7400-submodule-basic.sh      | 43 +++++++++++++++++++++++
 t/t7406-submodule-update.sh     | 50 ++++++++++++++++++++++++++-
 6 files changed, 187 insertions(+), 28 deletions(-)
Signature · 1 line
1.8.0.3.g95edff1.dirty