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

Re: How do I resolve conflict after popping stash without adding the file to index?

From
Jeff King <peff@peff.net>
Date
Apr 22, 2015, 19:55 UTC
Message-ID
<20150422195513.GC27656@peff.net>
In-Reply-To
<xmqq8udkdk1a.fsf@gitster.dls.corp.google.com>
On Wed, Apr 22, 2015 at 12:45:21PM -0700, Junio C Hamano wrote:
Show 11 quoted lines
> Jeff King <peff@peff.net> writes:
> 
> > Ironically, the message before e0e2a9c actually recommends staging
> > changes before applying the stash, which would lead to this exact
> > situation!
> 
> The ancient history is hazy to me, but did we fall back to three-way
> merge in old days (or did anything to the index for that matter), I
> wonder?  In a world "git stash apply" only applied the change to the
> working tree via "git apply", that old recommendation would make
> perfect sense.

Hmm, that advice came in 2a79d2f (Clarify how the user can satisfy stash's 'dirty state' check., 2008-09-29), at which point it looks like we were already running merge-recursive. So I think it was simply bad advice. ;)

> But obviously we do not live in such a world right now.  And because
> we are doing "merge-recursive", we should insist on a clean index;
> otherwise there is no way to "undo" its effect without losing the
> changes by the end-user.
Yeah, agreed.
Show 6 quoted lines
> > but it makes me wonder if somebody would find it annoying that they
> > cannot apply a stash into their work-in-progress (i.e., it _might_ cause
> > annoyance, but most of the time it will be convenient to do so).
> 
> They can always do "git stash show -p stash@{n} | git apply" if they
> want to build changes incrementally X-<, but it would be annoying.

I think the best thing to do is introduce this safety, let it cook for a while, and see what comes up. Perhaps we could add a "--force" or similar, but I'd rather see if anybody ever actually runs into the situation first.

Show 5 quoted lines
> > So probably we'd want to refactor that into two separate functions, and
> > only call the require_clean_index part.
> 
> Hmph, but what would that helper do, other than a single "diff-index
> --quiet --cached HEAD" call?

I was wanting to keep the error message and the flags we feed to diff-index consistent. But yeah, there is little enough duplicate material and enough added boilerplate that I do not think it is worth it (see the series I just posted).

-Peff
Previous: Junio C Hamano
Message 14 of 14 in “How do I resolve conflict after popping stash without adding the file to index?”
  1. Dmitry GutovApr 20, 2015
  2. Junio C HamanoApr 20, 2015
  3. Dmitry GutovApr 20, 2015
  4. Jeff KingApr 21, 2015
  5. Dmitry GutovApr 21, 2015
  6. Jeff KingApr 21, 2015
  7. Junio C HamanoApr 22, 2015
  8. Jeff KingApr 22, 2015
  9. Jeff KingApr 22, 2015
  10. 1/3 t3903: stop hard-coding commit sha1sJeff King, Apr 22, 2015
  11. 2/3 t3903: avoid applying onto dirty indexJeff King, Apr 22, 2015
  12. 3/3 stash: require a clean index to applyJeff King, Apr 22, 2015
  13. Junio C HamanoApr 22, 2015
  14. Jeff KingApr 22, 2015

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.