On Sun, Aug 29, 2010 at 08:30:15PM +0000, Ævar Arnfjörð Bjarmason wrote: > I have this alias in my .gitconfig: > > review = "!f() { for rev in $(git rev-list --reverse \"$@\"); do > git show $rev; done; }; f" > > I use it after I "git pull" to see what changed, e.g.: > > git review 49ea7b8..e1ef3c1 It took me a minute of reading this to see why you would want to call "git show" in a loop when you could have the same data from "git log" all at once (and much faster, too). But I guess you like having an individual less invocation for each commit. Have you tried "tig", which might suit your purpose even better? > But sometimes I find that I want to do that for other things too, so I > have these hacks: > > review-grep = "!f() { for rev in $(git log --reverse > --pretty=format:%H --grep=\"$@\"); do git show $rev; done; }; f" > review-file = "!f() { for rev in $(git log --reverse > --pretty=format:%H \"$@\"); do git show $rev; done; }; f" > > But just now I wanted to use -S instead of grep, but adding aliases > like this is a bit silly. I don't understand why you have these at all. Just use "git log --format=%H" in your git review above (instead of rev-list), and then you can just do: git review --grep=whatever git review -Sfoo git review file Or am I missing something subtle? You wouldn't even need to switch to log over rev-list, except that rev-list misses log's useful "default to HEAD if no revisions given" behavior. > Maybe we should have something like: > > git log --for-each=less a..b > > To call "less" for each commit, what do you think? I think it is not very Unix-y. We already have many ways to to call a command once per commit, including: - for i in `git rev-list "$@"`; do git show $i; done - git rev-list "$@" | xargs -n 1 git show - git log -z "$@" | perl -0ne 'open(LESS, "|less"); print LESS' What does your solution offer that the other do not? Because you are actually reinvoking git for each commit, it is more efficient than the first two (as you seem to assume that the --for-each command will receive the entire log output). But the third one should be more or less equivalent to what you want (though note: if you want tty-ish things like color on, you should set GIT_PAGER_IN_USE=1 so git knows output is eventually going to a pager). Sure, yours is slightly less typing, but it's _way_ less flexible, and that typing should probably be hidden behind an alias anyway. -Peff -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html