From: Maxime Coste <frrrwww@gmail.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>, Pete Wyckoff <pw@padd.com>
Subject: [PATCH] Fix git-p4 submit in non --prepare-p4-only mode
Date: Tue, 10 Jun 2014 13:14:46 +0100 [thread overview]
Message-ID: <20140610121446.GA25634@nekage> (raw)
In-Reply-To: <20140524174034.GA7560@nekage>
b4073bb387ef303c9ac3c044f46d6a8ae6e190f0 broke git p4 submit, here
is a proper fix, including proper handling for windows end of lines.
Signed-off-by: Maxime Coste <frrrwww@gmail.com>
---
git-p4.py | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/git-p4.py b/git-p4.py
index 7bb0f73..ff132b2 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -1238,7 +1238,7 @@ class P4Submit(Command, P4UserMap):
if response == 'n':
return False
- def get_diff_description(self, editedFiles):
+ def get_diff_description(self, editedFiles, filesToAdd):
# diff
if os.environ.has_key("P4DIFF"):
del(os.environ["P4DIFF"])
@@ -1258,7 +1258,7 @@ class P4Submit(Command, P4UserMap):
newdiff += "+" + line
f.close()
- return diff + newdiff
+ return (diff + newdiff).replace('\r\n', '\n')
def applyCommit(self, id):
"""Apply one commit, return True if it succeeded."""
@@ -1422,10 +1422,10 @@ class P4Submit(Command, P4UserMap):
separatorLine = "######## everything below this line is just the diff #######\n"
if not self.prepare_p4_only:
submitTemplate += separatorLine
- submitTemplate += self.get_diff_description(editedFiles)
+ submitTemplate += self.get_diff_description(editedFiles, filesToAdd)
(handle, fileName) = tempfile.mkstemp()
- tmpFile = os.fdopen(handle, "w+")
+ tmpFile = os.fdopen(handle, "w+b")
if self.isWindows:
submitTemplate = submitTemplate.replace("\n", "\r\n")
tmpFile.write(submitTemplate)
@@ -1475,9 +1475,9 @@ class P4Submit(Command, P4UserMap):
tmpFile = open(fileName, "rb")
message = tmpFile.read()
tmpFile.close()
- submitTemplate = message[:message.index(separatorLine)]
if self.isWindows:
- submitTemplate = submitTemplate.replace("\r\n", "\n")
+ message = message.replace("\r\n", "\n")
+ submitTemplate = message[:message.index(separatorLine)]
p4_write_pipe(['submit', '-i'], submitTemplate)
if self.preserveUser:
--
2.0.0
next prev parent reply other threads:[~2014-06-10 12:10 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-10 18:18 [PATCH] git-p4: Do not include diff in spec file when just preparing p4 Maxime Coste
2014-01-12 22:29 ` Pete Wyckoff
2014-01-13 12:10 ` Maxime Coste
2014-01-14 0:06 ` Pete Wyckoff
2014-05-24 1:39 ` Maxime Coste
2014-05-24 1:44 ` Maxime Coste
2014-05-24 13:52 ` Pete Wyckoff
2014-05-24 17:40 ` Maxime Coste
2014-06-10 12:14 ` Maxime Coste [this message]
2014-06-10 22:39 ` [PATCH] Fix git-p4 submit in non --prepare-p4-only mode Pete Wyckoff
2014-06-11 13:06 ` Maxime Coste
2014-06-11 13:36 ` Pete Wyckoff
2014-06-11 13:09 ` Maxime Coste
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=20140610121446.GA25634@nekage \
--to=frrrwww@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=pw@padd.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.