git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Jakub Narebski <jnareb@gmail.com>,
	Sverre Rabbelier <srabbelier@gmail.com>,
	Jonathan Nieder <jrnieder@gmail.com>,
	Git List <git@vger.kernel.org>
Subject: Re: non-empty index with git commit -a
Date: Wed, 16 Feb 2011 17:34:51 -0500	[thread overview]
Message-ID: <20110216223450.GA5617@sigill.intra.peff.net> (raw)
In-Reply-To: <7v39nnirfq.fsf@alter.siamese.dyndns.org>

On Wed, Feb 16, 2011 at 01:46:01PM -0800, Junio C Hamano wrote:

> > Also it would be not as easy as reflogs - you would have either to save
> > copy of index, or create a tree out of it and save reference in reflog.
> 
> Also note that "Create a tree out of it" is not always a useful way to
> save the state of the index.  The "stash" shares the same issue, but you
> would need an equivalent of a tarball that consists of the index file
> (with conflicted state) and the files in the working tree that corresponds
> to index entries with conflicted states if you want to be useful for
> storing a state away in case you botch the conflict resolution you are
> attempting.

I had assumed it would be a reflog of trees (or more likely parentless
commits), just keeping track of useful states. But the usage there isn't
very intuitive. You can do "git show index@{5.minutes.ago}:foo.c >bar.c"
to recover the state of a file, or even "git read-tree index@{1}" to
get a whole state. And those would be enough for the basic "oops, I just
want to go back to where I was".

But probably you should be able to do a three-way merge with where you
are now, with the HEAD at the time of save as a pseudo-parent. IOW,
treat the index state as if you had committed it and put it on a reflog.
And in the case that you are at the same HEAD, then a merge collapses
into a "fast-forward" to the index state you were at (I put
"fast-forward" in quotes because we are obviously not interested in
moving HEAD to the pseudo-commit at all, but just what ends up in the
index).

I dunno. I haven't thought all that hard about it, so maybe there is a
more clever way of doing it. Certainly the porcelain support for "reset
to this index, but don't move my HEAD" is not good, nor for "merge this
index, but nevermind about recording anything about the commit".  They
are both conceptually easy to implement in terms of plumbing, but the
commands to run them are a little unintuitive.

-Peff

  reply	other threads:[~2011-02-16 22:35 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-15 22:43 non-empty index with git commit -a Sverre Rabbelier
2011-02-16  2:36 ` Jeff King
2011-02-16  3:20   ` Jonathan Nieder
2011-02-16  3:27     ` Jeff King
2011-02-16  8:18     ` Sverre Rabbelier
2011-02-16  8:29       ` Nguyen Thai Ngoc Duy
2011-02-16  8:44         ` Jonathan Nieder
2011-02-16  8:51       ` Jeff King
2011-02-16  9:52         ` Sverre Rabbelier
2011-02-16  9:54           ` Jeff King
2011-02-16  9:58             ` Sverre Rabbelier
2011-02-16 10:06               ` Jeff King
2011-02-16 14:41                 ` Michael J Gruber
2011-02-16 19:29                   ` Jeff King
2011-02-16 18:51                 ` Junio C Hamano
2011-02-16 19:36                   ` Jeff King
2011-02-16 19:55                     ` Junio C Hamano
2011-02-16 19:59                       ` Jeff King
2011-02-16 21:03                         ` Jakub Narebski
2011-02-16 21:46                           ` Junio C Hamano
2011-02-16 22:34                             ` Jeff King [this message]
2011-02-16 10:28             ` Matthieu Moy
2011-02-16 19:48               ` Jeff King
2011-02-16 18:47           ` Junio C Hamano
2011-02-16  9:05     ` Matthieu Moy

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110216223450.GA5617@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jnareb@gmail.com \
    --cc=jrnieder@gmail.com \
    --cc=srabbelier@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.
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 NNTP newsgroup(s).