Skip to content

Commit 4bafe47

Browse files
committed
email: enhance send.sh script
* Ignore this patch * don't send to author when sending to --just-me or --just-us * eliminate the need for <branch>-patch-base tag * Add support for IGNORE_BOTTOM * find merge base based on UPSTREAM_BRANCH * print the full list of ignored and included commits and get OK Signed-off-by: Bill Mills <bill.mills@linaro.org>
1 parent ba0adf4 commit 4bafe47

1 file changed

Lines changed: 57 additions & 3 deletions

File tree

.prjinfo/sendmail/send.sh

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,78 @@ Viresh Kumar <viresh.kumar@linaro.org>,
1313
Alex Bennee <alex.bennee@linaro.org>,
1414
Armelle Laine <armellel@google.com>"
1515

16+
UPSTREAM_BRANCH=master
1617
BRANCH=$(git rev-parse --abbrev-ref HEAD)
17-
SINCE=${BRANCH}-patch-base
18-
IGNORE_TOP=1
18+
IGNORE_TOP=2
19+
IGNORE_BOTTOM=7 # only used if <branch>-patch-base does not exist
1920

2021
MY_DIR=$(dirname $0)
2122
BASE_DIR=$(cd $MY_DIR/../..; pwd)
2223

24+
get_tag() {
25+
git show-ref --tag --hash $1 2>/dev/null
26+
}
27+
28+
BASE=$(get_tag ${BRANCH}-merge-base)
29+
if [ -z "${BASE}" ]; then
30+
BASE=$(git merge-base ${UPSTREAM_BRANCH} HEAD)
31+
fi
32+
if [ -z "${BASE}" ]; then
33+
echo "Can't find base commit (common ancestor)" >&2
34+
exit 3
35+
fi
36+
37+
SINCE=$(get_tag ${BRANCH}-patch-base)
38+
if [ -z "${SINCE}" ]; then
39+
SINCE=$(git log --format=%H ${BASE}..HEAD | tac | head -n $(( $IGNORE_BOTTOM + 0 )) | tail -n 1 )
40+
fi
41+
if [ -z "${SINCE}" ]; then
42+
echo "Can't find patch base commit (first included commit)" >&2
43+
exit 3
44+
fi
45+
46+
TOP=$(git log -n 1 --format=%H HEAD~${IGNORE_TOP})
47+
if [ -z "${TOP}" ]; then
48+
echo "Can't top commit (last included commit)" >&2
49+
exit 3
50+
fi
51+
52+
if false; then
53+
echo "BASE: $(git log -n 1 --oneline $BASE)"
54+
echo "SINCE: $(git log -n 1 --oneline $SINCE)"
55+
echo "TOP: $(git log -n 1 --oneline $TOP)"
56+
echo "HEAD: $(git log -n 1 --oneline HEAD)"
57+
fi
58+
59+
echo "Ignore top commits:"
60+
git -P log --oneline ${TOP}..HEAD
61+
echo
62+
echo "Include commits:"
63+
git -P log --oneline ${SINCE}..${TOP}
64+
echo
65+
echo "Ignore bottom commits:"
66+
git -P log --oneline ${BASE}..${SINCE}
67+
echo
68+
69+
echo "^c to cancel, enter to proceed"
70+
read
71+
72+
# example commands
73+
# git log -n 1 --oneline --no-abbrev-commit virtio-msg-patch2-patch-basey
74+
# git log --oneline --no-abbrev-commit a1883517ee44cc03d1b621a331d24a6f5cc08a92..HEAD | tac | head -n $(( 5 + 1 )) | tail -n 1
75+
2376
case $1 in
2477
--for-real)
2578
TO="$REAL"
2679
;;
2780
--just-us)
2881
TO="$US"
82+
EXTRA_SEND_OPTS="--no-signed-off-by-cc --suppress-cc=author"
2983
;;
3084
--just-me)
3185
TO="$ME"
3286
CC="$ME2"
33-
EXTRA_SEND_OPTS="--no-signed-off-by-cc"
87+
EXTRA_SEND_OPTS="--no-signed-off-by-cc --suppress-cc=author"
3488
;;
3589
--dry-run)
3690
TO="$ME"

0 commit comments

Comments
 (0)