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

Re: [PATCH] unpack-trees.c: assume submodules are clean during check-out

From
ETEran Tromer <git2eran@tromer.org>
Date
Aug 6, 2007, 18:42 UTC
Message-ID
<46B76B8C.9050905@tromer.org>
In-Reply-To
<20070805144632.GB999MdfPADPa@greensroom.kotnet.org>
On 2007-08-05 10:46, Sven Verdoolaege wrote:
Show 17 quoted lines
>> $ git checkout experimental-death-ray
>> $ git submodules update
>> (return a week later, woozy from the vacation.)
>> $ git checkout master
> 
> Here, it'll warn that your submodule isn't up-to-date.
> 
>> (hack hack hack)
>> $ git commit -a -m "fixed typos"
> 
> And if you run "git status" first, it'll tell you that the submodule
> (still) isn't up-to-date.
> 
>> $ git push
>> (Oops. You've just accidentally committed the wrong submodule heads.)
> 
> You always have to be careful when doing "git commit -a".

Exactly. You now have to be very careful, whereas previously $ git checkout master && vi foo && git commit -a -m "fixed typos" was perfectly safe.

Worse yet, it could also be a script making similar assumptions. For example, consider the tree filter in git-filter-branch. It used to be fine, but will now corrupt the rewritten trees when submodules are involved. Here's the relevant code from git-filter-branch.sh:

-----------------------------------------------------------------
while read commit parents; do
...
		git read-tree -i -m $commit
...
		git checkout-index -f -u -a ||
			die "Could not checkout the index"
...
		eval "$filter_tree" < /dev/null ||
			die "tree filter failed: $filter_tree"
		git diff-index -r $commit | cut -f 2- | tr '\n' '\0' | \
			xargs -0 git update-index --add --replace --remove
...
	sh -c "$filter_commit" "git commit-tree" \
		$(git write-tree) $parentstr < ../message > ../map/$commit
done <../revs
-----------------------------------------------------------------
Show 5 quoted lines
>> Another approach is for pull, checkout etc. to automatically update the
>> submodule' head ref, but no more.
> 
> Then everything, including "git submodule update", would assume
> that the submodule is up-to-date.

With that approach, "git submodule update" would fetch the submodule's head commit (which could be missing), and then check it against the submodule's index (and maybe its work tree).

  Eran
Previous: Sven VerdoolaegeNext: Sven Verdoolaege
Message 11 of 16 in “unpack-trees.c: assume submodules are clean during check-out”
  1. unpack-trees.c: assume submodules are clean during check-outSven Verdoolaege, Jul 17, 2007
  2. Junio C HamanoJul 18, 2007
  3. Sven VerdoolaegeAug 1, 2007
  4. Junio C HamanoAug 4, 2007
  5. Lars HjemliAug 4, 2007
  6. Junio C HamanoAug 5, 2007
  7. Sven VerdoolaegeAug 5, 2007
  8. Eran TromerAug 4, 2007
  9. Junio C HamanoAug 5, 2007
  10. Sven VerdoolaegeAug 5, 2007
  11. Eran TromerAug 6, 2007
  12. Sven VerdoolaegeAug 6, 2007
  13. Eran TromerAug 7, 2007
  14. Sven VerdoolaegeAug 7, 2007
  15. Eran TromerAug 8, 2007
  16. Sven VerdoolaegeAug 8, 2007

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.