Advertisement
jjmaestro

git stash/unstash fail :-?

Aug 8th, 2012
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.70 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. TMPREPO=/tmp/.${RANDOM}-git-test
  4. mkdir -p $TMPREPO
  5. cd $TMPREPO
  6.  
  7. [ "$(uname -s)" == "Darwin" ] && __=''
  8.  
  9. git init .
  10.  
  11. echo "foobar" > foobar
  12. git add foobar
  13. git commit -m "Adding foobar"
  14.  
  15.  
  16. # Prepend 'bar' to file foobar and stage it
  17. sed -i $__ -e "1i\\
  18. bar
  19. " foobar
  20. git add foobar
  21.  
  22.  
  23. # Prepend 'foo' to file foobar and leave it unstaged
  24. sed -i $__ -e "1i\\
  25. foo
  26. " foobar
  27.  
  28.  
  29. # Now, there are both unstaged ('foo') AND staged ('bar') changes in foobar.
  30. # Let's stash the temporary work
  31. git stash save --keep-index "Temporary work ('foo')"
  32.  
  33. # Unstash them and... BOOOM! It fails... :(
  34. git stash pop
  35. echo "----- foobar ------"
  36. cat foobar
  37. echo "----- foobar ------"
  38. rm -rf $TMPREPO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement