All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jakub Dąbek" <jakub.dabek@gmail.com>
To: git@vger.kernel.org
Subject: stash pop results in conflict after stash --keep-index with the same file in index and working directory
Date: Tue, 12 May 2020 13:45:54 +0200	[thread overview]
Message-ID: <CAAop36+Qg1vEsOoJehNBDDAvxYQO4cba9g2j9-sKbrxsuoJk5A@mail.gmail.com> (raw)

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)

                 reply	other threads:[~2020-05-12 11:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=CAAop36+Qg1vEsOoJehNBDDAvxYQO4cba9g2j9-sKbrxsuoJk5A@mail.gmail.com \
    --to=jakub.dabek@gmail.com \
    --cc=git@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.