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

[PATCH 0/2] reset -p and unborn branches

From
Jeff King <peff@peff.net>
Date
Oct 25, 2013, 06:51 UTC
Message-ID
<20131025065117.GA15192@sigill.intra.peff.net>
In-Reply-To
<CANiSa6iYLp-iNdcv_qbFTitrfFxaDBVUy9YyUAF4QKM+-35P4A@mail.gmail.com>
On Thu, Oct 24, 2013 at 10:42:52PM -0700, Martin von Zweigbergk wrote:
Show 8 quoted lines
> > I think that's the correct fix for the regression.  You are restoring
> > the original, pre-166ec2e9 behavior for just the HEAD case. I do not
> > think add--interactive does any other magic between a symbolic rev and
> > its sha1, except for recognizing HEAD specially. However, if you wanted
> > to minimize the potential impact of 166ec2e9, you could pass the sha1
> > _only_ in the unborn case, like this:
> 
> Plus, the end result is more readable, IMHO.

Agreed. Unfortunately it is slightly wrong, because for the non-patch cases, we may look at "rev" later, and we would want it to still say "HEAD" rather than a sha1. This is fixed in my patches below.

Show 11 quoted lines
> >   1. Pass the head/not-head flag as a separate option.
> >
> >   2. Pass HEAD even in the unborn case; teach add--interactive to
> >      convert an unborn HEAD to the empty tree.
> >
> >   3. Teach add--interactive to recognize the empty tree sha1 as an
> >      "unstage" path.
> [...]
> Makes sense to me. I'm sure others can implement that much faster than
> I can, but I feel a little guilty, so I'm happy to do it if no one
> else wants to, as long as we agree this is the way we want to go.

As it turns out, add--interactive already _does_ know how to handle an unborn HEAD. It just didn't use it for this particular code path. So I think doing (2) makes the most sense, and the result is that the patch in reset.c ends up nice and simple.

  [1/2]: add-interactive: handle unborn branch in patch mode
  [2/2]: reset: pass real rev name to add--interactive
-Peff
Previous: Martin von ZweigbergkNext: Jeff King
Message 6 of 9 in “Fwd: Bug report: reset -p HEAD”
  1. Maarten de VriesOct 24, 2013
  2. Maarten de VriesOct 24, 2013
  3. Re* Bug report: reset -p HEADJunio C Hamano, Oct 25, 2013
  4. Jeff KingOct 25, 2013
  5. Martin von ZweigbergkOct 25, 2013
  6. 0/2 reset -p and unborn branchesJeff King, Oct 25, 2013
  7. 1/2 add-interactive: handle unborn branch in patch modeJeff King, Oct 25, 2013
  8. 2/2 reset: pass real rev name to add--interactiveJeff King, Oct 25, 2013
  9. Junio C HamanoOct 25, 2013

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.