@@ -7,10 +7,12 @@
SUBDIRECTORY_OK='Yes'
OPTIONS_KEEPDASHDASH=
OPTIONS_STUCKLONG=
-OPTIONS_SPEC='git request-pull [options] start url [end]
+OPTIONS_SPEC="\
+git request-pull [options] start url [end]
--
-p show patch text as well
-'
+p show patch text as well
+o,output= output pull request to the specified file
+"
. git-sh-setup
@@ -18,11 +20,16 @@ GIT_PAGER=
export GIT_PAGER
patch=
-while case "$#" in 0) break ;; esac
+out=
+while test $# != 0
do
case "$1" in
-p)
patch=-p ;;
+ -o|--output)
+ case "$2" in '') usage ;; esac
+ out="$2"
+ shift ;;
--)
shift; break ;;
-*)
@@ -180,6 +187,17 @@ $dash_line" $headrev &&
message=$(display_message) || status=1
-echo "$message"
+if test $status -ne 0
+then
+ echo "There's an error when outputting message, exiting"
+ exit $status
+fi
+
+if test -n "$out"
+then
+ echo "$message" > "$out"
+else
+ echo "$message"
+fi
exit $status
@@ -168,6 +168,19 @@ test_expect_success 'pull request after push' '
'
+test_expect_success 'pull request output with -o' '
+
+ rm -fr downstream.git &&
+ git init --bare downstream.git &&
+ (
+ cd local &&
+ git checkout initial &&
+ git merge --ff-only main &&
+ git push origin main:for-upstream &&
+ git request-pull -o ../request initial origin main:for-upstream
+ )
+'
+
test_expect_success 'request asks HEAD to be pulled' '
rm -fr downstream.git &&
Add -o option (and long dash counterpart --option), which allow users to write pull request message to the specified file. Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com> --- git-request-pull.sh | 28 +++++++++++++++++++++++----- t/t5150-request-pull.sh | 13 +++++++++++++ 2 files changed, 36 insertions(+), 5 deletions(-)