From: Mark Lodato Date: Sat, 13 Feb 2010 15:13:45 GMT Subject: Re: Individual file snapshots Message-ID: In-Reply-To: <7v6362c672.fsf@alter.siamese.dyndns.org> On Fri, Feb 12, 2010 at 7:47 PM, Junio C Hamano wrote: > Mark Lodato writes: > >> The basic steps are: >> >> backup .git/index >> git add -a >> git write-tree >> git commit-tree >> restore .git/index > > Instead of doing that, you might want to consider > >        GIT_INDEX_FILE=...some-temporary-file... >        export GIT_INDEX_FILE > > and run everything as if that is the index throughout your script.  That > way, if your script ever failed in the middle, you won't have to worry > about a broken index file. In the actual script, I copied the index file back if any error occured. Still, your idea sounds better, so I just updated it to use this variable instead. I still remove the temporary file on error, but if something goes wrong, at least the index won't be hosed. On Sat, Feb 13, 2010 at 2:01 AM, Ron Garret wrote: > Moving the index around seems kinda hacky. You probably want git-mktree. git-mktree is way too complicated. I would have to parse the index and call git-mktree for each directory. There is already a program to do this: git-write-tree :) Besides, using GIT_INDEX_FILE as suggested by Junio allows me to leave the original index file intact. -- Mark