From 32b25aded0c4e30c68ac3ab75f4cbb63302ca147 Mon Sep 17 00:00:00 2001 From: Anders Ro Date: Fri, 28 Nov 2014 01:39:37 +0100 Subject: [PATCH 1/2] git-submodule.sh: pin submodule when branch name is '@' Setting branch name to '@' for a submodule will disable 'git submodule update --remote' calls for that specific submodule. I.e. instead of follow the unspecified default choice of master, nothing is being updated. This is useful when multiple submodules exist but not all should follow the remote branch head. Signed-off-by: Anders Ro --- Documentation/git-submodule.txt | 3 ++- git-submodule.sh | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt index f17687e..bd0cced 100644 --- a/Documentation/git-submodule.txt +++ b/Documentation/git-submodule.txt @@ -289,7 +289,8 @@ OPTIONS The remote branch used defaults to `master`, but the branch name may be overridden by setting the `submodule..branch` option in either `.gitmodules` or `.git/config` (with `.git/config` taking - precedence). + precedence). Setting the branch name to the invalid branch name '@' + disables this option, i.e. pins the submodule at the recorded SHA-1. + This works for any of the supported update procedures (`--checkout`, `--rebase`, etc.). The only change is the source of the target SHA-1. diff --git a/git-submodule.sh b/git-submodule.sh index 25b1ddf..1bb2bb1 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -843,7 +843,8 @@ Maybe you want to use 'update --init'?")" die "$(eval_gettext "Unable to find current revision in submodule path '\$displaypath'")" fi - if test -n "$remote" + # Fetch latest in remote unless branch name in config is '@' + if test -n "$remote" -a "$branch" != "@" then if test -z "$nofetch" then @@ -857,6 +858,12 @@ Maybe you want to use 'update --init'?")" die "$(eval_gettext "Unable to find current ${remote_name}/${branch} revision in submodule path '\$sm_path'")" fi + # Inform that the current sm is pinned and use of '--remote' ignored + if test -n "$remote" -a "$branch" = "@" + then + say "$(eval_gettext "Submodule path '\$displaypath' pinned, remote update ignored")" + fi + if test "$subsha1" != "$sha1" || test -n "$force" then subforce=$force -- 2.1.4