Adding Reviewed-by (and the like) tags

Peter Hutterer peter.hutterer at who-t.net
Thu May 5 16:14:34 PDT 2011


Slightly less fancy than the other two, but the few lines below do the job
when using gitsnippets
http://who-t.blogspot.com/2010/11/adding-reviewed-by-tags-to-patches.html

---%<-----
#!/bin/sh

# fake some name that looks like a git commit to vim
FAKE_GIT_DIR=/tmp/filter-branch-msg/.git
FILE=$FAKE_GIT_DIR/COMMIT_EDITMSG

if [ $# -ne 1 ]; then
    echo  "usage: $0 <commit range>"
fi

mkdir -p $FAKE_GIT_DIR

vim $FILE
git filter-branch -f --msg-filter "sed '\$a `cat $FILE`'" $1
rm -rf $FAKE_GIT_DIR
rmdir `dirname $FAKE_GIT_DIR`
---%<-----

then just call with git-add-tag HEAD~4.. and add all lines you need to add.

Cheers,
  Peter

On Thu, May 05, 2011 at 04:46:58PM +0100, Daniel Stone wrote:
> Hi,
> 
> On Thu, May 05, 2011 at 05:01:06PM +0200, Cyril Brulebois wrote:
> > git filter-branch --msg-filter 'add-tag.sh "Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>" "Reviewed-by: Daniel Stone <daniel at fooishbar.org>"' origin/master..
> 
> Or, in ~/.gitconfig:
> [aliases]
>     addrb = filter-branch --msg-filter ~/bin/add-r-b
> 
> And my version of the script, which works with short entries, tries to
> preserve order as much as possible, and defaults to adding a Reviewed-by
> tag with your identity if no arguments are given:
> 
> <---
> #!/bin/sh
> 
> if [ -n "$GIT_AUTHOR_NAME" ] && [ -n "$GIT_AUTHOR_EMAIL" ]; then
>     MY_ID="$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>"
> elif [ -n "$(git config --get user.name)" ] &&
>      [ -n "$(git config --get user.email)" ]; then
>     MY_ID="$(git config --get user.name) <$(git config --get user.email)>"
> fi
> 
> ARGS=$@
> if [ -z "$ARGS" ] && [ -n "$MY_ID" ]; then
>     ARGS="Reviewed-by: $MY_ID"
> fi
> 
> # Build the awk command line, reverse param orders:
> cmd=
> for i in "$ARGS"; do
>   cmd="print \"$i\"; $cmd"
> done
> 
> # Insert lines after the first/last empty line:
> cat | awk \
>    "BEGIN {
>         needs_blank=1
>     };
>     /Signed-off-by/ || /Reviewed-by/ || /Tested-by/ || /Reported-by/ {
>         needs_blank=0
>     };
>     {
>         print
>     };
>     END {
>         if (needs_blank) {
>             print \"\"
>         }
>         $cmd
>     };"
> 
> --->
> 
> Cheers,
> Daniel


More information about the xorg-devel mailing list