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.
This commit is contained in:
Willy Tarreau 2021-11-03 08:41:01 +01:00
parent 35dc13f224
commit 0d026edaef
1 changed files with 10 additions and 3 deletions

View File

@ -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