Created
June 28, 2011 16:46
-
-
Save mfontani/1051568 to your computer and use it in GitHub Desktop.
git-rr: show which files were changed in commits, when rebasing
This file contains 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
#!/bin/sh | |
# Usage: | |
# Once you started git rebase --interactive master, and you are presented | |
# with the list of commit SHAs and commit messages, from Vim: | |
# - visually select all SHAs via "V}k" | |
# - launch git-rr: !git-rr | |
# - ... | |
# - profit! you now have the same info as before, just with the list of | |
# filenames which changed with each commit, and can now move around | |
# commits knowing which files were touched by which commit | |
# Get current branch, without initial "heads/" | |
BRANCH=$(git describe --all | perl -lne's!^heads/!!;print') | |
# Kill the "git log" paging features | |
PAGER= | |
# Lines look like: | |
# * c0ffee00 commit message1 | |
# path/to/file1 | |
# <-= newline | |
# * 00c0ffee commit message2 | |
# path/to/file2 | |
# <-= newline | |
echo "### START Rebasing branch $BRANCH" | |
echo "###" | |
git log --reverse --pretty=format:'* %h %s' --abbrev-commit --stat --name-only master.. | perl -lne' | |
if ( m!^\*! ) { | |
s!^\*!pick ! # by default, show "pick" | |
} else { | |
s!^!# ! # just comment-out anything else, with leading spaces for filenames | |
} | |
s!\s*$!!; # kill any trailing spaces | |
' | |
echo "###" | |
echo "### END Rebasing branch $BRANCH" | |
echo "###" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
inspired from your script, I did it this way: https://github.com/cfconrad/scripts/blob/master/git/git-rb
It's basically the same, but I do not get the list of commits again, while just parsing the current buffer from stdin...
With this, I don't care about branches
--autosqash
orrebase.instructionFormat
, cause I just don't touch it.