# 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} [...] [-- file*]"
+USAGE="Usage: ${0##*/} [-q] [-H] [-m] [-u] [-L] [-r reference] [-l logexpr] [-s subject] [-b base] {branch|range} [...] [-- file*]"
BASES=( )
BRANCHES=( )
REF=
MISSING=
UPSTREAM=
BODYHASH=
+SINCELAST=
die() {
[ "$#" -eq 0 ] || echo "$*" >&2
count=0
# now look up commits
while read ref subject; do
- if [ -n "$MISSING" -a "${subject:0:9}" = "[RELEASE]" ]; then
+ if [ -n "$MISSING" -o -n "$SINCELAST" ] && [ "${subject:0:9}" = "[RELEASE]" ]; then
continue
fi
-m) MISSING=1 ; shift ;;
-u) UPSTREAM=1 ; shift ;;
-H) BODYHASH=1 ; shift ;;
+ -L) SINCELAST=1 ; shift ;;
-h|--help) quit "$USAGE" ;;
*) die "$USAGE" ;;
esac
(
left_commits=( )
right_commits=( )
+ since_last=( )
+ last_bkp=$BASE
while read line; do
# append the subject at the end of the line
set -- $line
+ if [ -n "$SINCELAST" ]; then
+ if [ "${line::1}" = ":" ]; then
+ continue
+ fi
+ if [ "$2" != "-" ]; then
+ last_bkp="$1"
+ since_last=( )
+ else
+ since_last[${#since_last[@]}]="$1"
+ fi
+ continue
+ fi
echo -n "$line "
if [ "${line::1}" = ":" ]; then
echo "---- Subject ----"
right_commits[${#right_commits[@]}]="$comm"
fi
done
- if [ -n "$MISSING" -a ${#left_commits[@]} -eq 0 ]; then
+ if [ -n "$SINCELAST" -a ${#since_last[@]} -eq 0 ]; then
+ echo "No new commit upstream since last commit $last_bkp."
+ elif [ -n "$SINCELAST" ]; then
+ echo "Found ${#since_last[@]} commit(s) added to branch $REF since last backported commit $last_bkp:"
+ echo
+ echo " git cherry-pick -sx ${since_last[@]}"
+ echo
+ elif [ -n "$MISSING" -a ${#left_commits[@]} -eq 0 ]; then
echo "No missing commit to apply."
elif [ -n "$MISSING" ]; then
echo