# Re: [RFC] New command: 'git snapshot'.

3 messages from 2009-02-10 to 2009-02-11. Participants: Ulrik Sverdrup, Nanako Shiraishi.
Thread: https://gitlist.dev/t/17711

## Ulrik Sverdrup, 2009-02-10 23:58

Subject: Re: [RFC] New command: 'git snapshot'.
Message-ID: <a1b6cb1b0902101558s7df025c7hfe078638452413c@mail.gmail.com>
URL: https://gitlist.dev/e/a1b6cb1b0902101558s7df025c7hfe078638452413c%40mail.gmail.com

```
> On Tue, Feb 10, 2009 at 3:08 PM, Junio C Hamano <gitster@pobox.com> wrote:
> > Jeff King <peff@peff.net> writes:
> > How is it different from "git stash create"?
>
> Git stash doesn't touch untracked files, whereas git snapshot would.
> Take another closer look at the table in the original post titled
> "What are the differences between 'git stash' and 'git snapshot'?"
>
> -Geoffrey Lee

I'm understanding this just as I read this, but it seems that implementing a
git snapshot (I'm myself interested), could be done quickly with a new git.
(When was git stash create introduced? I don't know it?)

Something like this:
cp .git/index .git/tmp-index
GIT_INDEX_FILE=.git/tmp-index
git add -N .
git stash create

So we use add -N to put all files into tracked but unstaged by default, but we
keep our old index. Now stash is ready to save off the working directory, and
further logic has to be applied on the returned commit to save it off..


Ulrik Sverdrup

```

## Ulrik Sverdrup, 2009-02-11 00:05

Subject: Re: [RFC] New command: 'git snapshot'.
Message-ID: <a1b6cb1b0902101605l75c17e64qf9b919264b8d550d@mail.gmail.com>
URL: https://gitlist.dev/e/a1b6cb1b0902101605l75c17e64qf9b919264b8d550d%40mail.gmail.com
In-Reply-To: <a1b6cb1b0902101558s7df025c7hfe078638452413c@mail.gmail.com>

```
On Wed, Feb 11, 2009 at 12:58 AM, Ulrik Sverdrup
<ulrik.sverdrup@gmail.com> wrote:
>> On Tue, Feb 10, 2009 at 3:08 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> > Jeff King <peff@peff.net> writes:
>> > How is it different from "git stash create"?
>>
>> Git stash doesn't touch untracked files, whereas git snapshot would.
>> Take another closer look at the table in the original post titled
>> "What are the differences between 'git stash' and 'git snapshot'?"
>>
>> -Geoffrey Lee
>
> I'm understanding this just as I read this, but it seems that implementing a
> git snapshot (I'm myself interested), could be done quickly with a new git.
> (When was git stash create introduced? I don't know it?)
>
> Something like this:
> cp .git/index .git/tmp-index
> GIT_INDEX_FILE=.git/tmp-index
> git add -N .
> git stash create

Ok I didn't test this. Stash creation fails because the add -N status
is not quite "tracked but no content staged", but rather you _have_ to
stage the files at a later point. git add -N is just a reminder thing?

Error output:
plugin-gui.log: not added yet
fatal: git-write-tree: error building trees
Cannot save the current index state

Shame, I wish the above script worked.

Ulrik Sverdrup


>
> So we use add -N to put all files into tracked but unstaged by default, but we
> keep our old index. Now stash is ready to save off the working directory, and
> further logic has to be applied on the returned commit to save it off..
>
>
> Ulrik Sverdrup
>

```

## Nanako Shiraishi, 2009-02-11 00:08

Subject: Re: [RFC/PATCH] shortstatus v1
Message-ID: <20090211090856.6117@nanako3.lavabit.com>
URL: https://gitlist.dev/e/20090211090856.6117%40nanako3.lavabit.com
In-Reply-To: <a1b6cb1b0902101558s7df025c7hfe078638452413c@mail.gmail.com>

```
Quoting Ulrik Sverdrup <ulrik.sverdrup@gmail.com>:

>> On Tue, Feb 10, 2009 at 3:08 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> > Jeff King <peff@peff.net> writes:
>> > How is it different from "git stash create"?
>>
>> Git stash doesn't touch untracked files, whereas git snapshot would.
>> Take another closer look at the table in the original post titled
>> "What are the differences between 'git stash' and 'git snapshot'?"
>>
>> -Geoffrey Lee
>
> I'm understanding this just as I read this, but it seems that implementing a
> git snapshot (I'm myself interested), could be done quickly with a new git.
> (When was git stash create introduced? I don't know it?)

I did the initial git-stash at the end of June 2007; git-stash create was done by Junio about a week later and was released as a part of v1.5.4.

> Something like this:
> cp .git/index .git/tmp-index
> GIT_INDEX_FILE=.git/tmp-index
> git add -N .
> git stash create
>
> So we use add -N to put all files into tracked but unstaged by default, but we
> keep our old index. Now stash is ready to save off the working directory, and
> further logic has to be applied on the returned commit to save it off..

git-add -N came much later, late August 2008, and is available only in v1.6.1 and later.

I think you want to export GIT_INDEX_FILE you set to the temporary file before running these two commands.

-- 
Nanako Shiraishi
http://ivory.ap.teacup.com/nanako3/

```
