git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Surprise at git stash pop
@ 2011-07-25 15:45 Péter András Felvégi
  2011-07-25 17:55 ` Brandon Casey
  0 siblings, 1 reply; 3+ messages in thread
From: Péter András Felvégi @ 2011-07-25 15:45 UTC (permalink / raw)
  To: git

Hello,

'git stash pop' erased my local modifications, but not all of them.
Here is the dump of my terminal window with comments:

1) 1 item in the stash:

petschy@stormbringer:~/...$ git stash list
stash@{0}: WIP on 20110207-oracle: 089709b Merge branch
'20110207-oracle' of ssh:.... into 20110207-oracle

2) the status of the working tree

petschy@stormbringer:~/...$ git status
# On branch 20110207-oracle
# Your branch is ahead of 'origin/20110207-oracle' by 2 commits.
#
# 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:   SQLQueryCache.cpp
#    modified:   SQLQueryCache.hpp
#    modified:   ../../server/plugins-src/ads/AdsPlugin.cpp
#    modified:   ../../server/plugins-src/ads/AdsPlugin.hpp

3) querying the details of the stashed item

petschy@stormbringer:~/...$ git stash show stash@{0}
 build-configs.def |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

4) popping it, naively

petschy@stormbringer:~/...$ git stash pop
Auto-merging build-configs.def
CONFLICT (content): Merge conflict in build-configs.def

5) surprise, surprise!

petschy@stormbringer:~/...$ git status
# On branch 20110207-oracle
# Your branch is ahead of 'origin/20110207-oracle' by 2 commits.
#
# Unmerged paths:
#   (use "git reset HEAD <file>..." to unstage)
#   (use "git add/rm <file>..." as appropriate to mark resolution)
#
#    both modified:      ../../build-configs.def
#
# 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:  SQLQueryCache.cpp

ALL of the local modifications to SQLQueryCache.hpp, AdsPlugin.cpp/hpp
simply disappeared! Is this the expected behaviour? I don't think so.
Since the stash contained only one file, which had nothing to do with
the pending modifications, I thought it's safe to pop. And even if the
local modifications and the stashed files overlap, I'd expect a
warning, at least. Half day's work gone. And if this is business as
usual, why not all my local modifications were wiped?

Regards, Peter

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

* Re: Surprise at git stash pop
  2011-07-25 15:45 Surprise at git stash pop Péter András Felvégi
@ 2011-07-25 17:55 ` Brandon Casey
  2011-07-26  9:26   ` Péter András Felvégi
  0 siblings, 1 reply; 3+ messages in thread
From: Brandon Casey @ 2011-07-25 17:55 UTC (permalink / raw)
  To: Péter András Felvégi; +Cc: git

On 07/25/2011 10:45 AM, Péter András Felvégi wrote:
> Hello,
> 
> 'git stash pop' erased my local modifications, but not all of them.

Hi,

I cannot reproduce this.  What version of git are you using?

Can you produce a test case?  This could be a test repo that
you can share or a sequence of commands to produce such a
repo like:

   git init &&
   echo 'Some content' >build-configs.def &&
   mkdir -p 'server/plugins-src/ads' &&
   echo 'Some other content' >server/plugins-src/ads/AdsPlugin.hpp &&
   ...
   git add . &&
   git commit -m 'initial commit' &&
   echo 'Some new content for build-configs' >>build-configs.def &&
   ...
   git stash pop
   # Error situation

Thanks,
-Brandon

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

* Re: Surprise at git stash pop
  2011-07-25 17:55 ` Brandon Casey
@ 2011-07-26  9:26   ` Péter András Felvégi
  0 siblings, 0 replies; 3+ messages in thread
From: Péter András Felvégi @ 2011-07-26  9:26 UTC (permalink / raw)
  To: git; +Cc: Brandon Casey

Hello,

2011/7/25 Brandon Casey <brandon.casey.ctr@nrlssc.navy.mil>:
> On 07/25/2011 10:45 AM, Péter András Felvégi wrote:
>> Hello,
>>
>> 'git stash pop' erased my local modifications, but not all of them.
>
> Hi,
>
> I cannot reproduce this.  What version of git are you using?

git 1.7.5.4 on Debian Wheezy AMD64

>
> Can you produce a test case?  This could be a test repo that
> you can share or a sequence of commands to produce such a
> repo like:

Not likely, but I will try. My repo started as CVS, then converted to
SVN, and about a year ago, I switched to GIT. It has 5+ years of
history, 9k+ commits, multiple branches, merges.

What I checked so far is that:
- the stash on 089709b I was popping is of 2011.03.01
- since then, a lot of commits and fast forward merges were done on the branch
- there were some rebase -i's to squash commits together, but I was
careful not to alter commits already pushed to the central repo

Since yesterday, I found out that my branch diverged:

# Your branch and 'origin/20110207-oracle' have diverged,
# and have 11 and 9 different commit(s) each, respectively.

I don't know how can this happen, because I only pull/push to/from the
central repo, and noone else is using it.

When I pulled, there were merge conflicts, earlier versions of the
files showing up. There were 3 files, SQLQueryCache cpp/hpp and
AdsPlugin.cpp. I resolved the commits by keeping the HEAD versions.

What is interesting is that the stash item that caused the problems is
still there, despite that it was popped:

$ git stash list
stash@{0}: WIP on 20110207-oracle: 089709b Merge branch
'20110207-oracle' of ssh://... into 20110207-oracle

$ git stash show
 build-configs.def |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

I made a copy of my local repo, and the central one, too, but I don't
really know what to do now. The state of the repo before the pop is
lost, unfortunately.

Is there some option for git to log its actions, so that in cases like
this one could check on the inner workings?

Regards, Peter

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

end of thread, other threads:[~2011-07-26  9:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-25 15:45 Surprise at git stash pop Péter András Felvégi
2011-07-25 17:55 ` Brandon Casey
2011-07-26  9:26   ` Péter András Felvégi

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).