From: Willy Tarreau Date: Wed, 3 Nov 2021 07:41:01 +0000 (+0100) Subject: SCRIPTS: git-show-backports: re-enable file-based filtering X-Git-Tag: v2.5-dev13~35 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0d026edaefcee30d5532a9fde7cbfbeed411379e;p=thirdparty%2Fhaproxy.git SCRIPTS: git-show-backports: re-enable file-based filtering 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. --- diff --git a/scripts/git-show-backports b/scripts/git-show-backports index 4ac4110f8a..01a9e6331b 100755 --- a/scripts/git-show-backports +++ b/scripts/git-show-backports @@ -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