Re: [DRAFT] Create stash from index state

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

 



Hi,

On Sat, 14 Feb 2009, Adeodato Simó wrote:

> I've always missed a way to do what `bzr shelve` does: interactive
> stash, where you just select hunks à-la `add -p`, and then those gets
> stashed away.

I recently wrote this in my blog:

-- snip --
I think something like an interactive stash is needed. A method to 
specify what you want to keep in the working directory, the rest should 
be stashed. The idea would be something like this:

   1. Add the desired changes into a temporary index.
   2. Put the rest of the changes in another temporary index.
   3. Stash the latter index.
   4. Synchronize the working directory with the first index.
   5. Clean up temporary indices. 

Or in code:

$ cp .git/index .git/interactive-stash-1
$ GIT_INDEX_FILE=.git/interactive-stash-1 git add -i
$ cp .git/index .git/interactive-stash-2
$ GIT_INDEX_FILE=.git/interactive-stash-1 git diff -R |
        (GIT_INDEX_FILE=.git/interactive-stash-2 git apply--index)
$ tree=$(GIT_INDEX_FILE=.git/index git write-tree)
$ commit=$(echo Current index | git commit-tree $tree -p HEAD)
$ tree=$(GIT_INDEX_FILE=.git/interactive-stash-2 git write-tree)
$ commit=$(echo Edited out | git commit-tree $tree -p HEAD -p $commit)
$ git update-ref refs/stash $commit
$ GIT_INDEX_FILE=.git/interactive-stash-1 git checkout-index -a -f
$ rm .git/interactive-stash-1 .git/interactive-stash-2

This should probably go into git-stash.sh, maybe even with a switch to 
start git-gui to do the interactive adding instead of git-add.
-- snap --

Now, the main reason I did not implement this already is that I am not 
quite sure if you should select the changes you _want_ to keep (which 
would seem the more natural way to say what needs stashing), or if it 
would be better to select the changes you do _not_ want to keep (this 
would seem more consistent, as "git add -i" is about selecting what goes 
into the index, so "git stash -i" should be about selecting what goes into 
the stash).

Maybe you want to give it a try?

Ciao,
Dscho

[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