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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Dec 9, 2008 at 01:57, Fabian Franz <git@xxxxxxxxxxxxxxx> wrote:
> Technically the gitlink code was changed to read .git/HEAD.gitlink
> if it exists instead of the normal HEAD. If you add 0000* as sha1
> sum to .git/HEAD.gitlink the submodule code will always fetch HEAD.

This feels like the porcelain "fooling" the plumbing. How about
something like this instead:

diff --git a/read-cache.c b/read-cache.c
index 8579663..cfacea7 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -137,6 +137,8 @@ static int ce_compare_gitlink(struct cache_entry *ce)
         */
        if (resolve_gitlink_ref(ce->name, "HEAD", sha1) < 0)
                return 0;
+       if (is_null_sha1(ce->sha1))
+               return 0;
        return hashcmp(sha1, ce->sha1);
 }

This should make the plumbing happy no matter which commit is actually
checked out in the submodule (not actually tested...). Then,
cmd_update() can check if the requested sha1 is all '0' and
fetch+checkout latest HEAD (or some branch) without playing games with
.git/HEAD.gitlink. Finally, cmd_add() needs to update the index in the
containing repository with the magic '0*' sha1 if '--track' is
specifed. This can be achieved by replacing 'git add $path' with 'echo
$mode $sha1\t$path | git update-index --index-info'.

What do you think?

> @@ -327,10 +335,14 @@ cmd_update()
>                        say "Maybe you want to use 'update --init'?"
>                        continue
>                fi
> +               track=$(git config -f .gitmodules submodule."$name".track)

I'm pretty certain that we don't want to use info from .gitmodules in
cmd_update(). Instead, cmd_init() probably should move the info from
.gitmodules into .git/config and cmd_update() should check the latter.

Btw: cmd_status() probably also needs some modifications to handle
this special case.

--
larsh
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux