From: Jeff King <peff@peff.net>
To: Duy Nguyen <pclouds@gmail.com>
Cc: Lukas Fleischer <lfleischer@lfos.de>,
Git Mailing List <git@vger.kernel.org>
Subject: Re: tools for easily "uncommitting" parts of a patch I just commited?
Date: Sat, 22 Oct 2016 21:38:47 -0400 [thread overview]
Message-ID: <20161023013846.ct3olfabw2yhzio2@sigill.intra.peff.net> (raw)
In-Reply-To: <CACsJy8Bz-DhE+CkJH+3zsrZJUQfGYDN072MKawJ6dx5begfnMw@mail.gmail.com>
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.
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).
-Peff
next prev parent reply other threads:[~2016-10-23 1:38 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-19 22:26 tools for easily "uncommitting" parts of a patch I just commited? Jacob Keller
2016-10-19 22:42 ` Jeff King
2016-10-19 23:36 ` Jacob Keller
2016-10-20 2:13 ` Jeff King
2016-10-20 5:53 ` Jacob Keller
2016-10-20 16:30 ` Junio C Hamano
2016-10-20 17:27 ` Jacob Keller
2016-10-20 17:39 ` Junio C Hamano
2016-10-20 18:13 ` Jacob Keller
2016-10-20 18:41 ` Junio C Hamano
2016-10-20 20:03 ` Jacob Keller
2016-10-22 9:19 ` Lukas Fleischer
2016-10-23 1:07 ` Jacob Keller
2016-10-23 1:23 ` Duy Nguyen
2016-10-23 1:38 ` Jeff King [this message]
2016-10-23 10:27 ` Duy Nguyen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161023013846.ct3olfabw2yhzio2@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=lfleischer@lfos.de \
--cc=pclouds@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).