[infinispan-dev] Stashed changes could be dropped when running git sync script

Galder Zamarreño galder at redhat.com
Mon Nov 15 06:12:17 EST 2010


Actually, there's another odd thing going on.

After doing 'git stash apply', I run the script again and it seems like pop has been applied in my local master:

Switched to branch 'master'
# On branch master
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#	modified:   tools/src/main/java/org/infinispan/tools/jopr/RhqPluginXmlGenerator.java
#
no changes added to commit (use "git add" and/or "git commit -a")
Dropped refs/stash@{0} (e7f330c1479d51788022a69c7a9d8b4120d469f8)

However, if I go to my local topic branch for the jira, I see:

[z at dhcp-144-240:~/Go/code/galder.infinispan.git]% gco ispn770_master 
M	tools/src/main/java/org/infinispan/tools/jopr/RhqPluginXmlGenerator.java
Switched to branch 'ispn770_master'
[z at dhcp-144-240:~/Go/code/galder.infinispan.git]% gst               
# On branch ispn770_master
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#	modified:   tools/src/main/java/org/infinispan/tools/jopr/RhqPluginXmlGenerator.java
#
no changes added to commit (use "git add" and/or "git commit -a")

Hmmm, that's odd. The same file modified in two branches? I then tried to go to master and discard the changes in master:

[z at dhcp-144-240:~/Go/code/galder.infinispan.git]% gco master        
M	tools/src/main/java/org/infinispan/tools/jopr/RhqPluginXmlGenerator.java
Switched to branch 'master'
[z at dhcp-144-240:~/Go/code/galder.infinispan.git]% gst
# On branch master
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#	modified:   tools/src/main/java/org/infinispan/tools/jopr/RhqPluginXmlGenerator.java
#
no changes added to commit (use "git add" and/or "git commit -a")
[z at dhcp-144-240:~/Go/code/galder.infinispan.git]% git checkout -- tools/src/main/java/org/infinispan/tools/jopr/RhqPluginXmlGenerator.java 

And when I return back to the topic branch, the modification is gone from there as well! 

[z at dhcp-144-240:~/Go/code/galder.infinispan.git]% gst
# On branch master
nothing to commit (working directory clean)
[z at dhcp-144-240:~/Go/code/galder.infinispan.git]% gco ispn770_master 
Switched to branch 'ispn770_master'
[z at dhcp-144-240:~/Go/code/galder.infinispan.git]% gst
# On branch ispn770_master
nothing to commit (working directory clean)

Is this normal??

On Nov 15, 2010, at 11:56 AM, Galder Zamarreño wrote:

> Hmmm, I was working on a topic branch for https://jira.jboss.org/browse/ISPN-770 and tried to run https://gist.github.com/667673 but now my local, uncommitted, changes were gone.
> 
> Judging from log (see attached), it appears that the stash was popped on 4.0.x branch but after checking out 4.0.x, the changes are not there either.
> 
> I've tried to list stashes that were dropped erroneously and I see:
> 
> [z at dhcp-144-240:~/Go/code/galder.infinispan.git]% git fsck --unreachable | grep commit | cut -d\  -f3 | xargs git log --merges --no-walk --grep=WIP
> commit a45be8ad3c1acbb74e7d66eba1696880c6844bc2
> Merge: 03c776a 7e7b664
> Author: Galder Zamarreño <galder at jboss.org>
> Date:   Mon Nov 15 10:47:20 2010 +0100
> 
>    WIP on ispn770_master: 03c776a ISPN-731 - make rehashing state and tx log draining serial addendum to dd3e7e6 commit
> 
> Once I had do that, I was able to apply that stash via: git stash apply a45be8ad3c1acbb74e7d66eba1696880c6844bc2
> 
> Looking at the script again, it appears that the changes were popped in the pop call within sync(). I think the reason this happened is cos 'git status --porcelain' is not empty for 4.0.x or 4.1.x due to having untracked files (ignores have not been updated there).
> 
> So, a way to solve this might be to update ignores in those branches as well. That way we avoid untracked files being mistakenly being detected. 
> 
> However, this might still break in the future. Another possibility I see would be for the script to safe the git stash ref and to actually pop/apply that stash? That way the pop in sync() would not pop the initial stash, but the stash at the top of sync(). I don't see an easy way to do this though.
> 
> Maybe we need a different way to detect whether stashing is needed or not. For example, if only untracked files appear, 'git status --porcelain' is not empty, but 'git stash' won't have anything save. What about using the following?:
> 
> git status --porcelain --untracked-files=no
> 
> This might work better cos untracked files are not taken into account and hence we'd solve git ignore updates that are not ported over to old branches. I've just run this change locally and it worked fine for me, with my changes being properly stashed and restored.
> 
> Manik, thoughts? I've forked your script and applied the change in https://gist.github.com/700256
> 
> <stashed-disspeared.log>
> 
> Cheers,
> --
> Galder Zamarreño
> Sr. Software Engineer
> Infinispan, JBoss Cache
> 
> _______________________________________________
> infinispan-dev mailing list
> infinispan-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/infinispan-dev

--
Galder Zamarreño
Sr. Software Engineer
Infinispan, JBoss Cache




More information about the infinispan-dev mailing list