git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v3] submodule: Allow tracking of the newest revision of a branch in a submodule

From
LHLars 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
Previous: Junio C HamanoNext: Junio C Hamano
Message 5 of 6 in “submodule: Allow tracking of the newest revision of a branch in a submodule”
  1. submodule: Allow tracking of the newest revision of a branch in a submoduleFabian Franz, Dec 11, 2008
  2. Junio C HamanoDec 11, 2008
  3. Fabian FranzDec 12, 2008
  4. Junio C HamanoDec 12, 2008
  5. Lars HjemliDec 12, 2008
  6. Junio C HamanoDec 12, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.