On Tue, Apr 21, 2020 at 07:49:15PM +0100, Ian Jackson wrote:
> Stefano Stabellini writes ("[PATCH] Introduce a description of the Backport 
> and Fixes tags"):
> > Create a new document under docs/process to describe our special tags.
> > Add a description of the Fixes tag and the new Backport tag. Also
> > clarify that lines with tags should not be split.
> > 
> > Signed-off-by: Stefano Stabellini <stefano.stabell...@xilinx.com>
> > Acked-by: Wei Liu <w...@xen.org>
> 
> Acked-by: Ian Jackson <ian.jack...@eu.citrix.com>
> 
> > +When possible, please use the Fixes tag instead (or in addition).
> 
> Do we have any code to turn Fixes: into a list of commits to
> backport to a particular stable branch ?

I think we should have one of those, I've attempted something like:

#!/bin/sh -e

branch=$1
remote=$2

for fix in `git log ${remote}/master --grep='^Fixes:\s.*' --format="%H"`; do
    # Check if the fix is already part of the branch, in which case we have
    # gone backwards enough
    if git branch --contains $fix -r | \
       grep -q ${remote}/staging-${branch}; then
        break;
    fi
    bug=`git show $fix | grep -E '^\s*Fixes:\s.*' | awk '{ print $2 }'`
    # Append possible backports of the bug
    bugs="$bug `git log --grep="^master commit: $bug" --format="%H" --all` \
               `git log --grep="^(cherry picked from commit $bug" --format="%H" 
--all`"
    for bug in $bugs; do
        if ! git branch --contains $bug -r | \
             grep -q ${remote}/staging-${branch}; then
            continue
        fi
        # Check if fix has been backported
        fixes="`git log --grep="^master commit: $fix" --format="%H" --all` \
               `git log --grep="^(cherry picked from commit $fix" --format="%H" 
--all`"
        fixed=0
        for f in $fixes; do
            if git branch --contains $f -r | \
               grep -q ${remote}/staging-${branch}; then
                fixed=1
                break
            fi
        done
        if [ $fixed == 0 ]; then
            echo "$fix"
            break
        fi
    done
done

But it's hard to actually test whether it's correct. Seems to produce
some output, but I'm not sure whether it's missing commits, use as:

# ./check-branch.sh 4.12 origin

The script could also likely be cleaned up and improved, it's quite
ugly...

> If not it might be easier to ask people to add both Backport: and
> Fixes:.

I would like to avoid that, a Fixes tag should be enough for us to
figure out where the patch should be applied.

Thanks, Roger.

Reply via email to