{"thread":{"id":"56639","subject":"[PATCH 0/3] request-pull: write to file option","startedAt":"2021-10-03T12:29:56Z","lastAt":"2021-10-03T12:30:02Z","messageCount":4,"participants":["Bagas Sanjaya"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"437809","messageId":"20211003122943.338199-1-bagasdotme@gmail.com","threadId":"56639","inReplyTo":null,"subject":"[PATCH 0/3] request-pull: write to file option","fromName":"Bagas Sanjaya","fromEmail":"bagasdotme@gmail.com","sentAt":"2021-10-03T12:29:40Z","receivedAt":"2021-10-03T12:29:56Z","isPatch":true,"sender":{"key":"bagasdotme@gmail.com","avatar":"https://avatars.githubusercontent.com/u/40219486?v=4"},"body":"Currently, `git request-pull` only outputs PR message to stdout. Users\nwished to send the message have to use shell redirection to file. Add\nthe option to write it to user-specified file.\n\nBagas Sanjaya (3):\n  request-pull: introduce display_message() function\n  request-pull: add -o/--output option\n  request-pull: document -o/--output\n\n Documentation/git-request-pull.txt | 16 +++++-\n git-request-pull.sh                | 81 +++++++++++++++++++++---------\n t/t5150-request-pull.sh            | 13 +++++\n 3 files changed, 83 insertions(+), 27 deletions(-)\n\n\nbase-commit: cefe983a320c03d7843ac78e73bd513a27806845\n-- \nAn old man doll... just what I always wanted! - Clara\n\n"},{"id":"437810","messageId":"20211003122943.338199-3-bagasdotme@gmail.com","threadId":"56639","inReplyTo":"20211003122943.338199-1-bagasdotme@gmail.com","subject":"[PATCH 2/3] request-pull: add -o/--output option","fromName":"Bagas Sanjaya","fromEmail":"bagasdotme@gmail.com","sentAt":"2021-10-03T12:29:42Z","receivedAt":"2021-10-03T12:29:59Z","isPatch":true,"sender":{"key":"bagasdotme@gmail.com","avatar":"https://avatars.githubusercontent.com/u/40219486?v=4"},"body":"Add -o option (and long dash counterpart --option), which allow users to\nwrite pull request message to the specified file.\n\nSigned-off-by: Bagas Sanjaya <bagasdotme@gmail.com>\n---\n git-request-pull.sh     | 28 +++++++++++++++++++++++-----\n t/t5150-request-pull.sh | 13 +++++++++++++\n 2 files changed, 36 insertions(+), 5 deletions(-)\n\ndiff --git a/git-request-pull.sh b/git-request-pull.sh\nindex 88a7a9cf0d..f4d6f846d0 100755\n--- a/git-request-pull.sh\n+++ b/git-request-pull.sh\n@@ -7,10 +7,12 @@\n SUBDIRECTORY_OK='Yes'\n OPTIONS_KEEPDASHDASH=\n OPTIONS_STUCKLONG=\n-OPTIONS_SPEC='git request-pull [options] start url [end]\n+OPTIONS_SPEC=\"\\\n+git request-pull [options] start url [end]\n --\n-p    show patch text as well\n-'\n+p            show patch text as well\n+o,output=    output pull request to the specified file\n+\"\n \n . git-sh-setup\n \n@@ -18,11 +20,16 @@ GIT_PAGER=\n export GIT_PAGER\n \n patch=\n-while\tcase \"$#\" in 0) break ;; esac\n+out=\n+while test $# != 0\n do\n \tcase \"$1\" in\n \t-p)\n \t\tpatch=-p ;;\n+\t-o|--output)\n+\t\tcase \"$2\" in '') usage ;; esac\n+\t\tout=\"$2\"\n+\t\tshift ;;\n \t--)\n \t\tshift; break ;;\n \t-*)\n@@ -180,6 +187,17 @@ $dash_line\" $headrev &&\n \n message=$(display_message) || status=1\n \n-echo \"$message\"\n+if test $status -ne 0\n+then\n+\techo \"There's an error when outputting message, exiting\"\n+\texit $status\n+fi\n+\n+if test -n \"$out\"\n+then\n+\techo \"$message\" > \"$out\"\n+else\n+\techo \"$message\"\n+fi\n \n exit $status\ndiff --git a/t/t5150-request-pull.sh b/t/t5150-request-pull.sh\nindex cb67bac1c4..b87e9c9869 100755\n--- a/t/t5150-request-pull.sh\n+++ b/t/t5150-request-pull.sh\n@@ -168,6 +168,19 @@ test_expect_success 'pull request after push' '\n \n '\n \n+test_expect_success 'pull request output with -o' '\n+\n+\trm -fr downstream.git &&\n+\tgit init --bare downstream.git &&\n+\t(\n+\t\tcd local &&\n+\t\tgit checkout initial &&\n+\t\tgit merge --ff-only main &&\n+\t\tgit push origin main:for-upstream &&\n+\t\tgit request-pull -o ../request initial origin main:for-upstream\n+\t)\n+'\n+\n test_expect_success 'request asks HEAD to be pulled' '\n \n \trm -fr downstream.git &&\n-- \nAn old man doll... just what I always wanted! - Clara\n\n"},{"id":"437811","messageId":"20211003122943.338199-2-bagasdotme@gmail.com","threadId":"56639","inReplyTo":"20211003122943.338199-1-bagasdotme@gmail.com","subject":"[PATCH 1/3] request-pull: introduce display_message() function","fromName":"Bagas Sanjaya","fromEmail":"bagasdotme@gmail.com","sentAt":"2021-10-03T12:29:41Z","receivedAt":"2021-10-03T12:29:59Z","isPatch":true,"sender":{"key":"bagasdotme@gmail.com","avatar":"https://avatars.githubusercontent.com/u/40219486?v=4"},"body":"Move displaying PR message logic into display_message. While at it, use\nlocal variable $format and $dashline to shorten argument typing to git\nshow.\n\nSigned-off-by: Bagas Sanjaya <bagasdotme@gmail.com>\n---\n git-request-pull.sh | 57 ++++++++++++++++++++++++++++-----------------\n 1 file changed, 35 insertions(+), 22 deletions(-)\n\ndiff --git a/git-request-pull.sh b/git-request-pull.sh\nindex 2d0e44656c..88a7a9cf0d 100755\n--- a/git-request-pull.sh\n+++ b/git-request-pull.sh\n@@ -136,37 +136,50 @@ fi\n \n url=$(git ls-remote --get-url \"$url\")\n \n-git show -s --format='The following changes since commit %H:\n+display_message() {\n+\tlocal format\n+\tlocal dash_line\n+\n+\tdash_line=\"----------------------------------------------------------------\"\n+\tformat='The following changes since commit %H:\n \n   %s (%ci)\n \n are available in the Git repository at:\n-' $merge_base &&\n-echo \"  $url $pretty_remote\" &&\n-git show -s --format='\n-for you to fetch changes up to %H:\n+'\n+\n+\tgit show -s --format=\"$format\" $merge_base &&\n+\techo \"  $url $pretty_remote\" &&\n+\tformat='for you to fetch changes up to %H:\n \n   %s (%ci)\n+'\n+\tgit show -s --format=\"\n+$format\n+$dash_line\" $headrev &&\n \n-----------------------------------------------------------------' $headrev &&\n+\tif test $(git cat-file -t \"$head\") = tag\n+\tthen\n+\t\tgit cat-file tag \"$head\" |\n+\t\tsed -n -e '1,/^$/d' -e '/^-----BEGIN PGP /q' -e p\n+\t\techo\n+\t\techo \"$dash_line\"\n+\tfi &&\n \n-if test $(git cat-file -t \"$head\") = tag\n-then\n-\tgit cat-file tag \"$head\" |\n-\tsed -n -e '1,/^$/d' -e '/^-----BEGIN PGP /q' -e p\n-\techo\n-\techo \"----------------------------------------------------------------\"\n-fi &&\n+\tif test -n \"$branch_name\"\n+\tthen\n+\t\techo \"(from the branch description for $branch_name local branch)\"\n+\t\techo\n+\t\tgit config \"branch.$branch_name.description\"\n+\t\techo \"$dash_line\"\n+\tfi &&\n \n-if test -n \"$branch_name\"\n-then\n-\techo \"(from the branch description for $branch_name local branch)\"\n-\techo\n-\tgit config \"branch.$branch_name.description\"\n-\techo \"----------------------------------------------------------------\"\n-fi &&\n+\tgit shortlog ^$baserev $headrev &&\n+\tgit diff -M --stat --summary $patch $merge_base..$headrev\n+}\n \n-git shortlog ^$baserev $headrev &&\n-git diff -M --stat --summary $patch $merge_base..$headrev || status=1\n+message=$(display_message) || status=1\n+\n+echo \"$message\"\n \n exit $status\n-- \nAn old man doll... just what I always wanted! - Clara\n\n"},{"id":"437812","messageId":"20211003122943.338199-4-bagasdotme@gmail.com","threadId":"56639","inReplyTo":"20211003122943.338199-1-bagasdotme@gmail.com","subject":"[PATCH 3/3] request-pull: document -o/--output","fromName":"Bagas Sanjaya","fromEmail":"bagasdotme@gmail.com","sentAt":"2021-10-03T12:29:43Z","receivedAt":"2021-10-03T12:30:02Z","isPatch":true,"sender":{"key":"bagasdotme@gmail.com","avatar":"https://avatars.githubusercontent.com/u/40219486?v=4"},"body":"Document the option in git-request-pull(1), as well as usage example\n(along with shell redirection method).\n\nSigned-off-by: Bagas Sanjaya <bagasdotme@gmail.com>\n---\n Documentation/git-request-pull.txt | 16 ++++++++++++++--\n 1 file changed, 14 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-request-pull.txt b/Documentation/git-request-pull.txt\nindex 4d4392d0f8..4bb07d8865 100644\n--- a/Documentation/git-request-pull.txt\n+++ b/Documentation/git-request-pull.txt\n@@ -8,7 +8,7 @@ git-request-pull - Generates a summary of pending changes\n SYNOPSIS\n --------\n [verse]\n-'git request-pull' [-p] <start> <url> [<end>]\n+'git request-pull' [-p] [-o | --output <file>] <start> <url> [<end>]\n \n DESCRIPTION\n -----------\n@@ -29,6 +29,10 @@ OPTIONS\n -p::\n \tInclude patch text in the output.\n \n+-o <file>::\n+--output <file>::\n+\tWrite the request to the specified file.\n+\n <start>::\n \tCommit to start at.  This names a commit that is already in\n \tthe upstream history.\n@@ -64,6 +68,15 @@ which will produce a request to the upstream, summarizing the\n changes between the `v1.0` release and your `master`, to pull it\n from your public repository.\n \n+To generate the request to a file for later editing, you can either\n+use shell redirection:\n+\n+\tgit request-pull v1.0 https://git.ko.xz/project master > request\n+\n+or with `-o` option:\n+\n+\tgit request-pull -o request v1.0 https://git.ko.xz/project master\n+\n If you pushed your change to a branch whose name is different from\n the one you have locally, e.g.\n \n@@ -73,7 +86,6 @@ then you can ask that to be pulled with\n \n \tgit request-pull v1.0 https://git.ko.xz/project master:for-linus\n \n-\n GIT\n ---\n Part of the linkgit:git[1] suite\n-- \nAn old man doll... just what I always wanted! - Clara\n\n"}]}