From patchwork Sun Oct 3 12:29:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bagas Sanjaya X-Patchwork-Id: 12532715 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9479C433F5 for ; Sun, 3 Oct 2021 12:29:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A844B61B31 for ; Sun, 3 Oct 2021 12:29:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230214AbhJCMbo (ORCPT ); Sun, 3 Oct 2021 08:31:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230050AbhJCMbn (ORCPT ); Sun, 3 Oct 2021 08:31:43 -0400 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D491AC0613EC for ; Sun, 3 Oct 2021 05:29:55 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id rj12-20020a17090b3e8c00b0019f88e44d85so3628601pjb.4 for ; Sun, 03 Oct 2021 05:29:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=A6FYBdq6zC89oXjnPnKchxhMnsagoeSJO63WkxkYaOM=; b=ZMcv7YnKBj/woeT792+zpeE2e3fWEkD7dqmouStABfth24QUL5xAC9sZd062QAcxgG 4QNmT/bVFf5yzSakCj1lPwQUUhaZWOCBtPZ7SCU2yruBPrr1W93PpUiWU5nx3vaQO5bW AXJDM2Guf6s6NAWokk/X4upSTqsV7854Ux0VPFSQs02yFggzmKEV8iDVolqxOQeIy5Fq qGsjmI1IorbFOmkO+WP49dtFGTs6vSEKPurlGK+0Gb9mWPYgoOOGp0CVKttfu4Rq8A0o t6Qqv5lM6Z+HmPjtMzHH+UDemJGC58CNd0ajAb8IZ4qe9KteQncjkT9O4I21aR56cQxB 6CYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=A6FYBdq6zC89oXjnPnKchxhMnsagoeSJO63WkxkYaOM=; b=AQ5suulqcmO0dZ5XLRtF8NynkvkSaRRPgzDbaJAKgKC+iLMUDa8hMzAxzjJZsn9Lsq pt2Qa57RvWrfuoIExfvAWTod/W9VBmNyqwmAvUxXrYKbQy3GkKdjo6HRdW+gYw6X3YGm dsYt6WevdSFn7LxmpTPwYI1hq0Ac775nTBA7rOJX8pKewzthRHtyzpaLYWY1mrtDCyBf XGtUDPSoFexpvmvi9rHXo9RirRof8r/kLB4GB0wSctK82cnWLJsNC7ELr7Pn1AP+1Wy0 9wTVWsoCxZtFBpkUesFlIhUV5DYmbCiE5SMrP1c/FRFx0qRZknSfbTu+q2xQeYVMeDBY IvDg== X-Gm-Message-State: AOAM532uBJSJkzZoOkzBbwg7Lc/XozAUC77slYfEN6rhWaKKTc5dxE34 wC2X0aOfxAITYEgrXTxjMsqLhcxVdW2Qbw== X-Google-Smtp-Source: ABdhPJyPYcvbwI8i2wcoiOR48zcF/bayNHg/4S6a1jS9ep85MQFCwW0DRNzqKJFlG1K85qLl+EWC9Q== X-Received: by 2002:a17:902:ab17:b0:13e:b2e0:58b with SMTP id ik23-20020a170902ab1700b0013eb2e0058bmr3226683plb.9.1633264195213; Sun, 03 Oct 2021 05:29:55 -0700 (PDT) Received: from ubuntu.mate (subs09b-223-255-225-231.three.co.id. [223.255.225.231]) by smtp.gmail.com with ESMTPSA id k17sm8476394pfu.82.2021.10.03.05.29.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 05:29:55 -0700 (PDT) From: Bagas Sanjaya To: git@vger.kernel.org Cc: Ryan Anderson , Bagas Sanjaya Subject: [PATCH 1/3] request-pull: introduce display_message() function Date: Sun, 3 Oct 2021 19:29:41 +0700 Message-Id: <20211003122943.338199-2-bagasdotme@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211003122943.338199-1-bagasdotme@gmail.com> References: <20211003122943.338199-1-bagasdotme@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Move displaying PR message logic into display_message. While at it, use local variable $format and $dashline to shorten argument typing to git show. Signed-off-by: Bagas Sanjaya --- git-request-pull.sh | 57 ++++++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/git-request-pull.sh b/git-request-pull.sh index 2d0e44656c..88a7a9cf0d 100755 --- a/git-request-pull.sh +++ b/git-request-pull.sh @@ -136,37 +136,50 @@ fi url=$(git ls-remote --get-url "$url") -git show -s --format='The following changes since commit %H: +display_message() { + local format + local dash_line + + dash_line="----------------------------------------------------------------" + format='The following changes since commit %H: %s (%ci) are available in the Git repository at: -' $merge_base && -echo " $url $pretty_remote" && -git show -s --format=' -for you to fetch changes up to %H: +' + + git show -s --format="$format" $merge_base && + echo " $url $pretty_remote" && + format='for you to fetch changes up to %H: %s (%ci) +' + git show -s --format=" +$format +$dash_line" $headrev && -----------------------------------------------------------------' $headrev && + if test $(git cat-file -t "$head") = tag + then + git cat-file tag "$head" | + sed -n -e '1,/^$/d' -e '/^-----BEGIN PGP /q' -e p + echo + echo "$dash_line" + fi && -if test $(git cat-file -t "$head") = tag -then - git cat-file tag "$head" | - sed -n -e '1,/^$/d' -e '/^-----BEGIN PGP /q' -e p - echo - echo "----------------------------------------------------------------" -fi && + if test -n "$branch_name" + then + echo "(from the branch description for $branch_name local branch)" + echo + git config "branch.$branch_name.description" + echo "$dash_line" + fi && -if test -n "$branch_name" -then - echo "(from the branch description for $branch_name local branch)" - echo - git config "branch.$branch_name.description" - echo "----------------------------------------------------------------" -fi && + git shortlog ^$baserev $headrev && + git diff -M --stat --summary $patch $merge_base..$headrev +} -git shortlog ^$baserev $headrev && -git diff -M --stat --summary $patch $merge_base..$headrev || status=1 +message=$(display_message) || status=1 + +echo "$message" exit $status From patchwork Sun Oct 3 12:29:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bagas Sanjaya X-Patchwork-Id: 12532713 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2FBAC433EF for ; Sun, 3 Oct 2021 12:29:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B68D661A0A for ; Sun, 3 Oct 2021 12:29:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230228AbhJCMbp (ORCPT ); Sun, 3 Oct 2021 08:31:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230215AbhJCMbp (ORCPT ); Sun, 3 Oct 2021 08:31:45 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE25AC0613EC for ; Sun, 3 Oct 2021 05:29:57 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id c4so9278249pls.6 for ; Sun, 03 Oct 2021 05:29:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Et/0kg4oqqlXETsgCOA1jUbnwh3zRsXlgKH9Jo/Wnyw=; b=N2qJVGxzKgEyDepFBvLMMljwYbJNQZSPmm+viKxprumrJSN184qLSf1AYQmfS3rCkv +NH+Kpq4zVfvfQTADC3cpatAgxlgnyWHJCJ+YoiN/O2+Ftn4pfeGBXgN9nvOI0oQpdXV nrABBiEiRtkUCYNx4N0VZ6C7ZmzcS+YoU5MSpE31V8cZD2Ntiy7whyLKfvY6FNJ48YaA F8KTolkcbneVQphXRxYuqBOZUDHVXKtynla1x/qVtpeTt9VYOQfDpSFzf/O3GeWNdxce +qIzZHIGDb4by7dwaWhAmZ14GLUGKLdCUfbhY1fvGCiX8pm4rep5Pig3dJdZRmtGn/35 Kksg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Et/0kg4oqqlXETsgCOA1jUbnwh3zRsXlgKH9Jo/Wnyw=; b=0yW+AMZxOq8aKSIh08UuSgH088IEMd+RRRhpTJZ24L8aO8a0zt+8ad8pBQfwUUc00X DTkcojurfmz/mkEYVRTZFRjYz+1F1RU2ZHwuG+2HdCti7yXhc+0knz9qH7XgjasQnPgj xCHsFvaWgkntbtKRrKYHgLZnkV9+UTimnjb8mF61TfUZKEtgMwGh494KCnnYM6yPMwLf FA5AQNx3pawOWNP6P09z+pG3KZqqIqmb9KxQFv/MJAgR2szZegoCDJUOJPZwPkBoLC6N epY+ClC9ldOTSL4w9HzHYgGHenyu+lsDqhXUvsDfj+rE1Rq/fG/o4+hlFb1j9mjL58gf 1vGA== X-Gm-Message-State: AOAM533uY8YAVO3GJR0/nu8f5rlkIDUXH5GKB461xjGyg5dn/htc/sf4 5GBZQRpIp10FotgECLfrvgSlwSnUgvgaXg== X-Google-Smtp-Source: ABdhPJzu7p+OaRVW8Qphlj31nDFz2L6Rlo8cdk47eLszyAFHkUCuC/LDygBdxm4ib3SFIzYtDqUkmA== X-Received: by 2002:a17:90b:17ca:: with SMTP id me10mr30871038pjb.171.1633264197295; Sun, 03 Oct 2021 05:29:57 -0700 (PDT) Received: from ubuntu.mate (subs09b-223-255-225-231.three.co.id. [223.255.225.231]) by smtp.gmail.com with ESMTPSA id k17sm8476394pfu.82.2021.10.03.05.29.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 05:29:57 -0700 (PDT) From: Bagas Sanjaya To: git@vger.kernel.org Cc: Ryan Anderson , Bagas Sanjaya Subject: [PATCH 2/3] request-pull: add -o/--output option Date: Sun, 3 Oct 2021 19:29:42 +0700 Message-Id: <20211003122943.338199-3-bagasdotme@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211003122943.338199-1-bagasdotme@gmail.com> References: <20211003122943.338199-1-bagasdotme@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org 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 --- git-request-pull.sh | 28 +++++++++++++++++++++++----- t/t5150-request-pull.sh | 13 +++++++++++++ 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/git-request-pull.sh b/git-request-pull.sh index 88a7a9cf0d..f4d6f846d0 100755 --- a/git-request-pull.sh +++ b/git-request-pull.sh @@ -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 diff --git a/t/t5150-request-pull.sh b/t/t5150-request-pull.sh index cb67bac1c4..b87e9c9869 100755 --- a/t/t5150-request-pull.sh +++ b/t/t5150-request-pull.sh @@ -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 && From patchwork Sun Oct 3 12:29:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bagas Sanjaya X-Patchwork-Id: 12532717 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72B68C433EF for ; Sun, 3 Oct 2021 12:30:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4FA8361B31 for ; Sun, 3 Oct 2021 12:30:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230229AbhJCMbs (ORCPT ); Sun, 3 Oct 2021 08:31:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230215AbhJCMbr (ORCPT ); Sun, 3 Oct 2021 08:31:47 -0400 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16568C061781 for ; Sun, 3 Oct 2021 05:30:00 -0700 (PDT) Received: by mail-pj1-x1029.google.com with SMTP id oa12-20020a17090b1bcc00b0019f715462a8so4903934pjb.3 for ; Sun, 03 Oct 2021 05:30:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1zzYB649SUQeFEv+CNLZnMiewbejrWDe3PrP3+EPyo0=; b=pywQkngJeBT3dy9e8173UGyvFqAQxYRCqNHfIfuzfjAdKTTtL/VV6mfRLrbMRp3Sag a0GZAxsLaQ71KnSJC9C8iY3etC2MP/vhDdnDQ6ytmVwbl0S0ZcZr2kCNVvNrSH1OXxB6 7Kpu9ZefXrqYKbTX4Spx7cZdJbKJna9bDMWH36hnniMFBoLRLqvNNI14hhTVMMQRihPK i376Zx+SZHF5MXx+AQ3tUVBxC4qjiK2hlmMs33Q7oku84VPf7Rzo20bV7a/j3hx3Y4IN M6YwpIuM1OOzkIHxPqT15+18++0VWIrFovplyXHeaatK23lujQ211NJC8llJLl6ssbgZ aPpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1zzYB649SUQeFEv+CNLZnMiewbejrWDe3PrP3+EPyo0=; b=qoP4wAhW+kef5mS3K3Esurggsg4PirCZmVvYD02BtyDrSPTR/KWl0qaTvZ9GQ8jDEV SiFAf9kDWJtJVLqUZznBnDzo4pDEgvJjm/XhjlXyYFweirK6xw/aVSg4t2jRT67iuH/v czyhqvAgTJrwQivCWfL4fkyKT6matPvkR8vscgUt7CYr0+6T7HsMXE7YDUq0Zhwz/9aM Gcq6E7KK/R9y3+lQ4vzZQhqCJ6RbIib1k3YSqFl+maXm9IX9K9Kij7jYEXyQIRQJI7pk icVgV9BRLeEAS6mSagnEoSP+cRcZSgrI8tG1FVo2+fzy4gXES3FaHpvz+9/9pJmNu3Aw DAqQ== X-Gm-Message-State: AOAM530SYFSfE6QUD/BnE8w01fqmD2g/ThZZN+TkbBkxcpqHstv5e03S 6NZzEY0kAd5FbD/2GhSeCbP5wPTmGxlmWQ== X-Google-Smtp-Source: ABdhPJwGOA7e77u4ars2ADtzHujYAqYncPioMFzCysCyn6nDp8Uk+G0kupZavpnRG6ALCXdocujGcw== X-Received: by 2002:a17:902:bcc6:b0:138:d3ca:c356 with SMTP id o6-20020a170902bcc600b00138d3cac356mr18091028pls.6.1633264199410; Sun, 03 Oct 2021 05:29:59 -0700 (PDT) Received: from ubuntu.mate (subs09b-223-255-225-231.three.co.id. [223.255.225.231]) by smtp.gmail.com with ESMTPSA id k17sm8476394pfu.82.2021.10.03.05.29.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 05:29:59 -0700 (PDT) From: Bagas Sanjaya To: git@vger.kernel.org Cc: Ryan Anderson , Bagas Sanjaya Subject: [PATCH 3/3] request-pull: document -o/--output Date: Sun, 3 Oct 2021 19:29:43 +0700 Message-Id: <20211003122943.338199-4-bagasdotme@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211003122943.338199-1-bagasdotme@gmail.com> References: <20211003122943.338199-1-bagasdotme@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Document the option in git-request-pull(1), as well as usage example (along with shell redirection method). Signed-off-by: Bagas Sanjaya --- Documentation/git-request-pull.txt | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Documentation/git-request-pull.txt b/Documentation/git-request-pull.txt index 4d4392d0f8..4bb07d8865 100644 --- a/Documentation/git-request-pull.txt +++ b/Documentation/git-request-pull.txt @@ -8,7 +8,7 @@ git-request-pull - Generates a summary of pending changes SYNOPSIS -------- [verse] -'git request-pull' [-p] [] +'git request-pull' [-p] [-o | --output ] [] DESCRIPTION ----------- @@ -29,6 +29,10 @@ OPTIONS -p:: Include patch text in the output. +-o :: +--output :: + Write the request to the specified file. + :: Commit to start at. This names a commit that is already in the upstream history. @@ -64,6 +68,15 @@ which will produce a request to the upstream, summarizing the changes between the `v1.0` release and your `master`, to pull it from your public repository. +To generate the request to a file for later editing, you can either +use shell redirection: + + git request-pull v1.0 https://git.ko.xz/project master > request + +or with `-o` option: + + git request-pull -o request v1.0 https://git.ko.xz/project master + If you pushed your change to a branch whose name is different from the one you have locally, e.g. @@ -73,7 +86,6 @@ then you can ask that to be pulled with git request-pull v1.0 https://git.ko.xz/project master:for-linus - GIT --- Part of the linkgit:git[1] suite