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

Re: Bug: stash staged file move loses original file deletion

From
Jeff King <peff@peff.net>
Date
Dec 6, 2016, 15:25 UTC
Message-ID
<20161206152530.snccf7buiosst3e4@sigill.intra.peff.net>
In-Reply-To
<CAFQpxx+PJ3FSoH9DFWyEw+ZLagji9Qou+aY9EB8A+=t+QX0o2A@mail.gmail.com>
On Tue, Dec 06, 2016 at 02:45:05PM +0000, Matthew Patey wrote:
Show 6 quoted lines
> Thanks for the reply! I agree that it is weird that applying a stash with a
> move only puts the addition back in the index, and thanks for the tip on
> "index" to properly apply that. For this case I was focusing on the
> behavior of the second stash/apply, with the first stash/apply as an
> example of how to get into a weird state that triggers the odd behavior of
> the second.
Oh, heh, I totally missed that.

I agree that the second stash not saving the deletion seems like a bug. Oddly, just stashing a deletion, like:

  rm a
  git stash
  git stash apply

does store it. So it's not like we can't represent the deletion. Somehow the presence of "b" in the index matters.

It looks like the culprit may be this part of create_stash():
  git diff --name-only -z HEAD -- >"$TMP-stagenames"

That is using the "git diff" porcelain, which will respect renames, and the --name-only bit mentions only "b".

If you run:
  git -c diff.renames=false stash
then it works.
-Peff
Previous: Jeff KingNext: Jeff King
Message 3 of 13 in “Bug: stash staged file move loses original file deletion”
  1. Matthew PateyDec 5, 2016
  2. Jeff KingDec 6, 2016
  3. Jeff KingDec 6, 2016
  4. stash: disable renames when calling git-diffJeff King, Dec 6, 2016
  5. Junio C HamanoDec 6, 2016
  6. Jeff KingDec 6, 2016
  7. Junio C HamanoDec 6, 2016
  8. Jeff KingDec 6, 2016
  9. Junio C HamanoDec 6, 2016
  10. Jeff KingDec 6, 2016
  11. Junio C HamanoDec 6, 2016
  12. Jeff KingDec 6, 2016
  13. Junio C HamanoDec 6, 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.