git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 06/12] git p4: standardize submit cancel due to unchanged template

From
PWPete Wyckoff <pw@padd.com>
Date
Aug 16, 2012, 23:35 UTC
Message-ID
<1345160114-27654-7-git-send-email-pw@padd.com>
In-Reply-To
<1345160114-27654-1-git-send-email-pw@padd.com>

When editing the submit template, if no change was made to it, git p4 offers a prompt "Submit anyway?". Answering "no" cancels the submit.

Previously, a "no" answer behaves like a "[s]kip" answer to the failed-patch prompt, in that it proceeded to try to apply the rest of the commits. Instead, put users back into the new "[s]kip / [c]ontinue" loop so that they can decide. This makes both cases of patch failure behave identically.

The return code of git p4 after a "no" answer is now the same as that for a "skip" due to failed patch; update a test to understand this.

Signed-off-by: Pete Wyckoff <pw@padd.com>
---
 git-p4.py                          | 4 +++-
 t/t9805-git-p4-skip-submit-edit.sh | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/git-p4.py b/git-p4.py
index 1d5194d..075f477 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -1262,6 +1262,7 @@ class P4Submit(Command, P4UserMap):
 
         if self.edit_template(fileName):
             # read the edited message and submit
+            ret = True
             tmpFile = open(fileName, "rb")
             message = tmpFile.read()
             tmpFile.close()
@@ -1285,6 +1286,7 @@ class P4Submit(Command, P4UserMap):
 
         else:
             # skip this patch
+            ret = False
             print "Submission cancelled, undoing p4 changes."
             for f in editedFiles:
                 p4_revert(f)
@@ -1293,7 +1295,7 @@ class P4Submit(Command, P4UserMap):
                 os.remove(f)
 
         os.remove(fileName)
-        return True  # success
+        return ret
 
     # Export git tags as p4 labels. Create a p4 label and then tag
     # with that.
diff --git a/t/t9805-git-p4-skip-submit-edit.sh b/t/t9805-git-p4-skip-submit-edit.sh
index fb3c8ec..ff2cc79 100755
--- a/t/t9805-git-p4-skip-submit-edit.sh
+++ b/t/t9805-git-p4-skip-submit-edit.sh
@@ -38,7 +38,7 @@ test_expect_success 'no config, unedited, say no' '
 		cd "$git" &&
 		echo line >>file1 &&
 		git commit -a -m "change 3 (not really)" &&
-		printf "bad response\nn\n" | git p4 submit &&
+		printf "bad response\nn\n" | test_expect_code 1 git p4 submit &&
 		p4 changes //depot/... >wc &&
 		test_line_count = 2 wc
 	)
-- 
1.7.11.4
Previous: Pete WyckoffNext: Pete Wyckoff
Message 13 of 21 in “git p4: submit conflict handling”
  1. 00/12 git p4: submit conflict handlingPete Wyckoff, Aug 16, 2012
  2. 01/12 git p4 test: remove bash-ism of combined export/assignmentPete Wyckoff, Aug 16, 2012
  3. Junio C HamanoAug 17, 2012
  4. 02/12 git p4 test: use p4d -L option to suppress log messagesPete Wyckoff, Aug 16, 2012
  5. Luke DiamandAug 17, 2012
  6. 03/12 git p4: gracefully fail if some commits could not be appliedPete Wyckoff, Aug 16, 2012
  7. Johannes SixtAug 17, 2012
  8. Pete WyckoffAug 17, 2012
  9. Luke DiamandAug 17, 2012
  10. Pete WyckoffAug 17, 2012
  11. 04/12 git p4: remove submit failure options [a]pply and [w]ritePete Wyckoff, Aug 16, 2012
  12. 05/12 git p4: move conflict prompt into run, use [c]ontinue and [q]uitPete Wyckoff, Aug 16, 2012
  13. 06/12 git p4: standardize submit cancel due to unchanged templatePete Wyckoff, Aug 16, 2012
  14. 07/12 git p4: test clean-up after failed submit, fix added filesPete Wyckoff, Aug 16, 2012
  15. 08/12 git p4: rearrange submit template constructionPete Wyckoff, Aug 16, 2012
  16. 09/12 git p4: revert deleted files after submit cancelPete Wyckoff, Aug 16, 2012
  17. 10/12 git p4: accept -v for --verbosePete Wyckoff, Aug 16, 2012
  18. 11/12 git p4: add submit --dry-run optionPete Wyckoff, Aug 16, 2012
  19. 12/12 git p4: add submit --prepare-p4-only optionPete Wyckoff, Aug 16, 2012
  20. Luke DiamandAug 17, 2012
  21. Pete WyckoffAug 17, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.