git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Stash during incomplete merge
@ 2012-02-26 18:36 Phil Hord
  2012-02-28 20:22 ` Neal Kreitzinger
  0 siblings, 1 reply; 4+ messages in thread
From: Phil Hord @ 2012-02-26 18:36 UTC (permalink / raw)
  To: git@vger.kernel.org; +Cc: Phil Hord

Hi list,

I was cherry-picking changes from an old branch recently when I ran into
unexpected behavior with git stash pop.  When I git-stash-save after
resolving a  merge-conflict, the subsequent git-stash-pop does not
restore my index.

I think it is the same problem being asked about here:
http://stackoverflow.com/questions/9009354/git-stash-during-a-merge-conflict

Is this expected behavior or a bug?

<http://stackoverflow.com/questions/9009354/git-stash-during-a-merge-conflict>Here's
a script the demonstrates the anomaly, but my actual encounter involved
more files, some of which I added to the index and some I did not:

# Create a sample merge-conflict
git init  tmp-repo && cd tmp-repo
echo foo > foo.txt && git add foo.txt && git commit -m "foo"
git checkout -b A master && echo foo-A > foo.txt && git commit -am "foo-A"
git checkout -b B master && echo foo-B > foo.txt && git commit -am "foo-B"
git merge A
git status
# Resolve the conflict
echo foo-AB > foo.txt && git add foo.txt
git status
git stash
# test test test...  Resume...
git stash pop






Here's some of the final output:

$ git merge A
Auto-merging foo.txt
CONFLICT (content): Merge conflict in foo.txt
Recorded preimage for 'foo.txt'
Automatic merge failed; fix conflicts and then commit the result.

$ git status
# On branch B
# Unmerged paths:
#   (use "git add/rm <file>..." as appropriate to mark resolution)
#
#       both modified:      foo.txt
#
no changes added to commit (use "git add" and/or "git commit -a")

$ # Resolve the conflict
$ echo foo-AB > foo.txt && git add foo.txt
$ git status
# On branch B
# Changes to be committed:
#
#       modified:   foo.txt
#

$ # Now foo.txt is in my index.  But I have to test something before I
commit.
$ git stash
Saved working directory and index state WIP on B: 80f2a13 foo-B
HEAD is now at 80f2a13 foo-B

$ # test test test...  Resume...
$ git stash pop

# On branch B
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working
directory)
#
#       modified:   foo.txt
#
no changes added to commit (use "git add" and/or "git commit -a")
Dropped refs/stash@{0} (460a6d5c67a3db613fd27f1854ecc7b89eeaa207)

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-02-29 19:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-26 18:36 Stash during incomplete merge Phil Hord
2012-02-28 20:22 ` Neal Kreitzinger
2012-02-28 22:24   ` Neal Kreitzinger
2012-02-29 19:34     ` Neal Kreitzinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).