git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ben Keene via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Ben Keene <seraphire@gmail.com>, Ben Keene <seraphire@gmail.com>
Subject: [PATCH v2] git-p4.py: fix --prepare-p4-only error with multiple commits
Date: Tue, 12 May 2020 13:15:59 +0000	[thread overview]
Message-ID: <pull.775.v2.git.git.1589289359302.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.775.git.git.1588352952840.gitgitgadget@gmail.com>

From: Ben Keene <seraphire@gmail.com>

When using git p4 submit with the --prepare-p4-only option, the program
should prepare a single p4 changelist and notify the user that more
commits are pending and then stop processing.

A bug has been introduced by the p4-changelist hook feature that
causes the program to continue to try and process all pending
changelists at the same time.

The function applyCommit returns True when applying the commit
was successful and the program should continue. However, when the
optional flag --prepare-p4-only is set, the program should stop
after the first application.

Change the logic in the run method for P4Submit to check for the
flag --prepare-p4-only after successfully completing the applyCommit
method.

Be aware - this change will fix the existing test error in t9807.23
for --prepare-p4-only. However there is insufficent coverage for
this flag.  If more than 1 commit is pending submission to P4, the
method will properly prepare the P4 changelist, however it will
still exit the application with an exitcode of 1.

The current documentation does not define what the exit code should be
in this condition.
(See: https://git-scm.com/docs/git-p4#Documentation/git-p4.txt---prepare-p4-only)

Signed-off-by: Ben Keene <seraphire@gmail.com>
---
    git-p4.py: fix --prepare-p4-only error with multiple commits
    
    When using git p4 submit with the --prepare-p4-only option, the program
    should prepare a single p4 changelist and notify the user that more
    commits are pending and then stop processing.
    
    A bug has been introduced by the p4-changelist hook feature that causes
    the program to continue to try and process all pending changelists at
    the same time.
    
    The function applyCommit should return True when applying the commit was
    successful and the program should continue. In the case of the
    --prepare-p4-only flag, the function should return False, alerting the
    caller that the program should not proceed with additional commits.
    
    Change the return value from True to False in the applyCommit function
    when git-p4 is executed with --prepare-p4-only flag.

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-775%2Fseraphire%2Fseraphire%2Fp4-hook-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-775/seraphire/seraphire/p4-hook-v2
Pull-Request: https://github.com/git/git/pull/775

Range-diff vs v1:

 1:  57a34af2b86 < -:  ----------- git-p4.py: fix --prepare-p4-only error with multiple commits
 -:  ----------- > 1:  a554a65503e git-p4.py: fix --prepare-p4-only error with multiple commits


 git-p4.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/git-p4.py b/git-p4.py
index b8b2a1679e7..c4a4012bcc1 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -2537,11 +2537,12 @@ def run(self, args):
                 ok = self.applyCommit(commit)
             if ok:
                 applied.append(commit)
-            else:
-                if self.prepare_p4_only and i < last:
-                    print("Processing only the first commit due to option" \
-                          " --prepare-p4-only")
+                if self.prepare_p4_only:
+                    if i < last:
+                        print("Processing only the first commit due to option" \
+                                " --prepare-p4-only")
                     break
+            else:
                 if i < last:
                     # prompt for what to do, or use the option/variable
                     if self.conflict_behavior == "ask":

base-commit: 07d8ea56f2ecb64b75b92264770c0a664231ce17
-- 
gitgitgadget

  parent reply	other threads:[~2020-05-12 13:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-01 17:09 [PATCH] git-p4.py: fix --prepare-p4-only error with multiple commits Ben Keene via GitGitGadget
2020-05-01 18:39 ` Junio C Hamano
2020-05-06  3:44 ` Junio C Hamano
2020-05-12 13:15 ` Ben Keene via GitGitGadget [this message]
2020-05-12 20:05   ` [PATCH v2] " Junio C Hamano
2020-05-17  8:31     ` Luke Diamand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=pull.775.v2.git.git.1589289359302.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=seraphire@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).