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

Re: Fwd: Re: git checkout -f branch doesn't remove extra files

From
Sergey Vlasov <vsu@altlinux.ru>
Date
Aug 13, 2005, 12:10 UTC
Message-ID
<20050813161053.29593972.vsu@altlinux.ru>
In-Reply-To
<20050813110050.GA5608@pasky.ji.cz>
On Sat, 13 Aug 2005 13:00:51 +0200 Petr Baudis wrote:
> Dear diary, on Sat, Aug 13, 2005 at 07:05:11AM CEST, I got a letter
> where Linus Torvalds <torvalds@osdl.org> told me that...
[...]
Show 14 quoted lines
> > 	snap=git-snapshot-$(date +"%Y%m%d")
> > 	git-tar-tree HEAD $snap | gzip -9 > $snap.tar.gz
> > 
> > which is even easier, and a hell of a lot more efficient.
> 
> To put my two cents too, Cogito has cg-export for this:
> 
> 	cg-export tmp-dir
> 
> to export to a temporary directory and
> 
> 	cg-export git-snapshot.tar.gz
> 
> to export to a gzipped tarball (it can also do .tar, .tgz and .tar.bz2).

However, cg-export is buggy - if you use the second argument (cg-export DESTFILE TREE_ID), the resulting tar file is different from what git-tar-tree produces for the same TREE_ID (unless that TREE_ID actually points to a tree - but in practice a commit or even tag ID is typically used).

The problem is in this line:
id=$(tree-id "$2")

This converts the passed commit or tag to the underlying tree, which is then passed to git-tar-tree. However, git-tar-tree can follow such links itself, and, what's more important, it actually uses some information from the passed commit (it writes the commit ID to the tar file as an extended header, and sets timestamp of all archive members to the time of the commit). Therefore reducing the ID passed to git-tar-tree to a plain tree ID is wrong - if a commit ID is available, it should be used.

-- 
Sergey Vlasov
Previous: Petr BaudisNext: Petr Baudis
Message 7 of 8 in “Fwd: Re: git checkout -f branch doesn't remove extra files”
  1. Dave JonesAug 13, 2005
  2. Linus TorvaldsAug 13, 2005
  3. Dave JonesAug 13, 2005
  4. Linus TorvaldsAug 13, 2005
  5. Linus TorvaldsAug 13, 2005
  6. Petr BaudisAug 13, 2005
  7. Sergey VlasovAug 13, 2005
  8. Petr BaudisAug 13, 2005

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.