Re: tools for easily "uncommitting" parts of a patch I just commited?

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

 



On Sun, Oct 23, 2016 at 8:38 AM, Jeff King <peff@xxxxxxxx> wrote:
> On Sun, Oct 23, 2016 at 08:23:01AM +0700, Duy Nguyen wrote:
>
>> I hit the same problem sometimes, but in my case sometimes I
>> accidentally do "git add" after "git add -p" and a configuration in
>> "git commit -a" won't help me. I'd prefer we could undo changes in
>> index instead. Something like reflog but for index.
>
> An index write always writes the whole file from scratch, so you really
> just need to save a copy of the old file. Perhaps something like:
>
>   rm -f $GIT_DIR/index.old
>   ln $GIT_DIR/index.old $GIT_DIR/index
>   ... and then open $GIT_DIR/index.tmp ...
>   ... and then rename(index.tmp, index) ...
>
> could do it cheaply. It's a little more complicated if you want to save
> a sequence of versions, and eventually would take a lot of space, but
> presumably a handful of saved indexes would be sufficient.

Yeah. I had something [1] like that but never sorted out the UI for it :(

> Another option would be an index format that journals, and you could
> potentially walk back the journal to a point. That seems like a much
> bigger change (and has weird layering, because deciding when to fold in
> the journal is usually a performance thing, but obviously this would
> have user-visible impact about how far back you could undo).

v2 [2] goes in this direction (but not a full blown COW, the journal
does not take part in any core operations of the index)

[1] https://public-inbox.org/git/%3C1375597720-13236-1-git-send-email-pclouds@xxxxxxxxx%3E/
[2] https://public-inbox.org/git/1375966270-10968-1-git-send-email-pclouds@xxxxxxxxx/
-- 
Duy



[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]