I was wondering if you can generate patches for a range but only limit to commits from a specific author, the way you do with git log --author='bob'
.
Yes, it is possible.
According to reference on git format-patch
it accepts <revision range>
Generic expression (see "SPECIFYING REVISIONS" section in gitrevisions(7)) means the commits in the specified range.
Details may be found in the reference but we only need this one:
^!, e.g. HEAD^!
A suffix ^ followed by an exclamation mark is the same as giving commit and then all its parents prefixed with ^ to exclude them (and their ancestors).
So you'll need:
git log X..Y --author='<AUTHOR>' --format="%H" | sed 's/$/^!/g' | xargs -I{} git format-patch {}
git log X..Y --author='<AUTHOR>' --format="%H"
produces output in format of 40-digit sha1 sums.
sed 's/$/^!/g'
adds ^! at the end of each line
xargs -I{} git format-patch {}
just runs git format-patch
with each line
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With