Reputation: 194
So, the following bash oneliner will generate similar output as git log
git rev-list --reverse HEAD | while read rev; do git log -1 $rev; done
What I want to know is, what is the purpose of read rev
in this context? Is there another way this could be written without read rev
perhapse with xargs
?
Upvotes: 1
Views: 280
Reputation: 26251
Yes you can use xargs in this case:
git rev-list --reverse HEAD | xargs -L 1 -J % git log -1 %
To explain how read rev
works here, the loop reads one line from its input (in this case, from the output of the git rev-list --reverse HEAD
command) and stores it in the variable rev
. Then, any commands within the loop can use the variable rev
. As an example:
seq 1 5 | while read x; do echo "value is $x"; done
will show
value is 1
value is 2
value is 3
value is 4
value is 5
Upvotes: 3