Re: [PATCH v3] submodule: Allow tracking of the newest revision of a branch in a submodule
- From
- Lars Hjemli <hjemli@gmail.com>
- Date
- Dec 12, 2008, 00:31 UTC
- Message-ID
- <8c5c35580812111631k54657bdcme8f048c77b6765eb@mail.gmail.com>
- In-Reply-To
- <7vbpvicuk2.fsf@gitster.siamese.dyndns.org>
On Thu, Dec 11, 2008 at 21:42, Junio C Hamano <gitster@pobox.com> wrote:
> I wonder if you can just set "assume unchanged" bit for the subproject > gitlink in the index to achieve the same goal.
Using assume-unchanged works, in the sense that the modification to the submodule is not detected in the containing repo. But running `git submodule update` will checkout the sha1 recorded in HEAD, and I suspect Fabian wants something like the hypothetical command `git submodule update -b [branch]` which could do `(cd sub && git fetch && git reset --hard origin/$branch)`.
> > Or is there more to it? >
Something like this (probably mangled) patch is needed for 'submodule status' to behave sensibly when the assume-unchanged bit is turned on for a submodule path.
diff --git a/git-submodule.sh b/git-submodule.sh index 2f47e06..375dfbf 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -588,21 +588,21 @@ cmd_status() do name=$(module_name "$path") || exit url=$(git config submodule."$name".url) + orgsha1=$(git ls-tree HEAD "$path" | cut -d ' ' -f 3 | cut -f 1) if test -z "$url" || ! test -d "$path"/.git -o -f "$path"/.git then say "-$sha1 $path" continue; fi + if test -z "$cached" + then + sha1=$(unset GIT_DIR; cd "$path" && git rev-parse --verify HEAD) + fi set_name_rev "$path" "$sha1" - if git diff-files --quiet -- "$path" + if test "$sha1" = "$orgsha1" then say " $sha1 $path$revname" else - if test -z "$cached" - then - sha1=$(unset GIT_DIR; cd "$path" && git rev-parse --verify HEAD) - set_name_rev "$path" "$sha1" - fi say "+$sha1 $path$revname" fi done