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

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

From
Duy Nguyen <pclouds@gmail.com>
Date
Oct 23, 2016, 10:27 UTC
Message-ID
<CACsJy8A2Q=cPhYtTexA+CS4mzyx-vHzNH033JFHDih=ohtucVw@mail.gmail.com>
In-Reply-To
<20161023013846.ct3olfabw2yhzio2@sigill.intra.peff.net>
On Sun, Oct 23, 2016 at 8:38 AM, Jeff King <peff@peff.net> wrote:
Show 18 quoted lines
> 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 :(
Show 5 quoted lines
> 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@gmail.com%3E/ [2] https://public-inbox.org/git/1375966270-10968-1-git-send-email-pclouds@gmail.com/

-- 
Duy
Previous: Jeff King
Message 16 of 16 in “tools for easily "uncommitting" parts of a patch I just commited?”
  1. Jacob KellerOct 19, 2016
  2. Jeff KingOct 19, 2016
  3. Jacob KellerOct 19, 2016
  4. Jeff KingOct 20, 2016
  5. Jacob KellerOct 20, 2016
  6. Junio C HamanoOct 20, 2016
  7. Jacob KellerOct 20, 2016
  8. Junio C HamanoOct 20, 2016
  9. Jacob KellerOct 20, 2016
  10. Junio C HamanoOct 20, 2016
  11. Jacob KellerOct 20, 2016
  12. Lukas FleischerOct 22, 2016
  13. Jacob KellerOct 23, 2016
  14. Duy NguyenOct 23, 2016
  15. Jeff KingOct 23, 2016
  16. Duy NguyenOct 23, 2016

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.