Skip to content

Commit cf73166

Browse files
committed
request-pull: state what commit to expect
The message gives a detailed explanation of the commit the requester based the changes on, but lacks information that is necessary for the person who performs a fetch & merge in order to verify that the correct branch was fetched when responding to the pull request. Add a few more lines to describe the commit at the tip expected to be fetched to the same level of detail as the base commit. Also update the warning message slightly when the script notices that the commit may not have been pushed. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3c9f1e7 commit cf73166

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed

git-request-pull.sh

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ do
3535
shift
3636
done
3737

38-
base=$1 url=$2 head=${3-HEAD}
38+
base=$1 url=$2 head=${3-HEAD} status=0
3939

4040
test -n "$base" && test -n "$url" || usage
4141
baserev=$(git rev-parse --verify "$base"^0) &&
@@ -51,25 +51,29 @@ find_matching_branch="/^$headrev "'refs\/heads\//{
5151
}'
5252
branch=$(git ls-remote "$url" | sed -n -e "$find_matching_branch")
5353
url=$(git ls-remote --get-url "$url")
54-
if test -z "$branch"
55-
then
56-
echo "warn: No branch of $url is at:" >&2
57-
git log --max-count=1 --pretty='tformat:warn: %h: %s' $headrev >&2
58-
echo "warn: Are you sure you pushed $head there?" >&2
59-
echo >&2
60-
echo >&2
61-
branch=..BRANCH.NOT.VERIFIED..
62-
status=1
63-
fi
6454

6555
git show -s --format='The following changes since commit %H:
6656
6757
%s (%ci)
6858
69-
are available in the git repository at:' $baserev &&
70-
echo " $url $branch" &&
71-
echo &&
59+
are available in the git repository at:
60+
' $baserev &&
61+
echo " $url${branch+ $branch}" &&
62+
git show -s --format='
63+
for you to fetch changes up to %H:
64+
65+
%s (%ci)
66+
67+
----------------------------------------------------------------' $headrev &&
7268

7369
git shortlog ^$baserev $headrev &&
74-
git diff -M --stat --summary $patch $merge_base..$headrev || exit
70+
git diff -M --stat --summary $patch $merge_base..$headrev || status=1
71+
72+
if test -z "$branch"
73+
then
74+
echo "warn: No branch of $url is at:" >&2
75+
git show -s --format='warn: %h: %s' $headrev >&2
76+
echo "warn: Are you sure you pushed '$head' there?" >&2
77+
status=1
78+
fi
7579
exit $status

t/t5150-request-pull.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,14 @@ test_expect_success 'pull request format' '
193193
SUBJECT (DATE)
194194
195195
are available in the git repository at:
196+
196197
URL BRANCH
197198
199+
for you to fetch changes up to OBJECT_NAME:
200+
201+
SUBJECT (DATE)
202+
203+
----------------------------------------------------------------
198204
SHORTLOG
199205
200206
DIFFSTAT

0 commit comments

Comments
 (0)