]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
SCRIPTS: git-show-backports: re-enable file-based filtering
authorWilly Tarreau <w@1wt.eu>
Wed, 3 Nov 2021 07:41:01 +0000 (08:41 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 3 Nov 2021 07:41:01 +0000 (08:41 +0100)
The early version of the script used to support passing non-branch
arguments but as it evolved we lost that option. Let's use "--" as a
delimiter after the branch(es) to pass optional file names to filter
on. This is convenient to list missing patches on a specific set of
files.

scripts/git-show-backports

index 4ac4110f8a348d219abd02b38370098dc74ff52a..01a9e6331b9563af5e15c5196278db1243805996 100755 (executable)
@@ -28,7 +28,7 @@
 #   show-backports -q -m -r hapee-r2 hapee-r1
 
 
-USAGE="Usage: ${0##*/} [-q] [-H] [-m] [-u] [-r reference] [-l logexpr] [-s subject] [-b base] {branch|range} [...]"
+USAGE="Usage: ${0##*/} [-q] [-H] [-m] [-u] [-r reference] [-l logexpr] [-s subject] [-b base] {branch|range} [...] [-- file*]"
 BASES=( )
 BRANCHES=( )
 REF=master
@@ -163,6 +163,10 @@ done
 BRANCHES=( )
 BASES=( )
 while [ $# -gt 0 ]; do
+        if [ "$1" = "--" ]; then
+                shift
+                break
+        fi
        branch="${1##*..}"
        if [ "$branch" == "$1" ]; then
                base=""
@@ -174,6 +178,9 @@ while [ $# -gt 0 ]; do
        shift
 done
 
+# args left for git-log
+ARGS=( "$@" )
+
 if [ ${#BRANCHES[@]} = 0 ]; then
        die "$USAGE"
 fi
@@ -200,7 +207,7 @@ mkdir -p .git/.show-backports #|| die "Can't create .git/.show-backports"
 WORK=.git/.show-backports
 
 rm -f "$WORK/${REF//\//_}"
-git log --reverse ${LOGEXPR:+--grep $LOGEXPR} --pretty="%H %s" "$BASE".."$REF" | grep "${SUBJECT}" > "$WORK/${REF//\//_}"
+git log --reverse ${LOGEXPR:+--grep $LOGEXPR} --pretty="%H %s" "$BASE".."$REF" -- "${ARGS[@]}" | grep "${SUBJECT}" > "$WORK/${REF//\//_}"
 
 # for each branch, enumerate all commits and their ancestry
 
@@ -210,7 +217,7 @@ while [ $branch_num -lt "${#BRANCHES[@]}" ]; do
        base="${BASES[$branch_num]}"
        base="${base:-$BASE}"
        rm -f "$WORK/${branch//\//_}"
-       git log --reverse --pretty="%H %s" "$base".."$branch" | grep "${SUBJECT}" | while read h subject; do
+       git log --reverse --pretty="%H %s" "$base".."$branch" -- "${ARGS[@]}" | grep "${SUBJECT}" | while read h subject; do
                echo -n "$h" $(git log -1 --pretty --format=%B "$h" | \
                        sed -n 's/^commit \([^)]*\) upstream\.$/\1/p;s/^(cherry picked from commit \([^)]*\))/\1/p')
                if [ -n "$BODYHASH" ]; then