Skip to content

Commit 5a41c16

Browse files
Pete Wyckoffgitster
authored andcommitted
git p4: standardize submit cancel due to unchanged template
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 <[email protected]> Acked-by: Luke Diamand <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7e5dd9f commit 5a41c16

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

git-p4.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1262,6 +1262,7 @@ def applyCommit(self, id):
12621262

12631263
if self.edit_template(fileName):
12641264
# read the edited message and submit
1265+
ret = True
12651266
tmpFile = open(fileName, "rb")
12661267
message = tmpFile.read()
12671268
tmpFile.close()
@@ -1285,6 +1286,7 @@ def applyCommit(self, id):
12851286

12861287
else:
12871288
# skip this patch
1289+
ret = False
12881290
print "Submission cancelled, undoing p4 changes."
12891291
for f in editedFiles:
12901292
p4_revert(f)
@@ -1293,7 +1295,7 @@ def applyCommit(self, id):
12931295
os.remove(f)
12941296

12951297
os.remove(fileName)
1296-
return True # success
1298+
return ret
12971299

12981300
# Export git tags as p4 labels. Create a p4 label and then tag
12991301
# with that.

t/t9805-git-p4-skip-submit-edit.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ test_expect_success 'no config, unedited, say no' '
3838
cd "$git" &&
3939
echo line >>file1 &&
4040
git commit -a -m "change 3 (not really)" &&
41-
printf "bad response\nn\n" | git p4 submit &&
41+
printf "bad response\nn\n" | test_expect_code 1 git p4 submit &&
4242
p4 changes //depot/... >wc &&
4343
test_line_count = 2 wc
4444
)

0 commit comments

Comments
 (0)