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

stash pop results in conflict after stash --keep-index with the same file in index and working directory

From
JDJakub Dąbek <jakub.dabek@gmail.com>
Date
May 12, 2020, 11:45 UTC
Message-ID
<CAAop36+Qg1vEsOoJehNBDDAvxYQO4cba9g2j9-sKbrxsuoJk5A@mail.gmail.com>

I was trying to write a pre-commit hook for testing using stash to keep irrelevant changes, but pop couldn't apply changes automatically when the same file with different changes was in index and working directory at the same time.

Reproduction:
  mkdir git-stash-test && cd git-stash-test
  git init
  echo foo > foo.txt
  git add . && git commit -m 'init'
  echo foo2 > foo.txt
  git add foo.txt
  echo foo3 > foo.txt
  git status # (*)
  git stash push --keep-index
  git status
  # do testing
  git stash pop
Expected result: same state as before push (*); actual result:
  Auto-merging foo.txt
  CONFLICT (content): Merge conflict in foo.txt
  The stash entry is kept in case you need it again.
--index option doesn't help when used with pop.

My assumption is that pop should be the reverse of push when nothing has changed in between, but I don't know if this is a bug or unexpected behaviour. (git version 2.26.2)

Message 1 of 1 in “stash pop results in conflict after stash --keep-index with the same file in index and working directory”
  1. Jakub DąbekMay 12, 2020

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.