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 4ac4110..01a9e63 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 @@
BRANCHES=( )
BASES=( )
while [ $# -gt 0 ]; do
+ if [ "$1" = "--" ]; then
+ shift
+ break
+ fi
branch="${1##*..}"
if [ "$branch" == "$1" ]; then
base=""
@@ -174,6 +178,9 @@
shift
done
+# args left for git-log
+ARGS=( "$@" )
+
if [ ${#BRANCHES[@]} = 0 ]; then
die "$USAGE"
fi
@@ -200,7 +207,7 @@
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 @@
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