Created
July 25, 2012 21:05
-
-
Save colegleason/3178672 to your computer and use it in GitHub Desktop.
Show stashed changes after checkout
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # | |
| # .git/hooks/post-checkout | |
| import sys | |
| import subprocess | |
| git_name = subprocess.Popen(("git","name-rev","--name-only", "HEAD"), | |
| stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
| branch_name = git_name.communicate()[0].strip('\n') | |
| git_name.stdout.close() | |
| git_stash = subprocess.Popen(("git", "stash", "list", "--grep", branch_name), | |
| stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
| out,err = git_stash.communicate() | |
| if out: | |
| print("Stashed changes on this branch:") | |
| print(out.strip('\n')) | |
| if err: | |
| print(err) |
But this is a really cool script :)
Author
Dat sounds like sum of dem error checkin' nonsense, boy.
Also instead of grepping the list output, give list selective options (see man git-log).
Author
like git stash list --grep ?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
subprocess.check_output, buddy.