Ensure that the commit message is Windows formated (CRLF) before invoking the editor.
authorMarius Storm-Olsen <marius@trolltech.com>
Thu, 7 Jun 2007 12:07:01 +0000 (14:07 +0200)
committerSimon Hausmann <shausman@trolltech.com>
Thu, 7 Jun 2007 12:11:15 +0000 (14:11 +0200)
(The default editor on Windows (Notepad) doesn't handle Unix line endings)

Signed-off-by: Marius Storm-Olsen <marius@trolltech.com>
contrib/fast-import/git-p4

index 8b00e350ec277f1f8fe78430f7234f5e45cd8af5..fc4e7d26f061621ac424a92b15cfc9132b76247b 100755 (executable)
@@ -277,6 +277,7 @@ class P4Submit(Command):
         self.directSubmit = False
         self.trustMeLikeAFool = False
         self.verbose = False
+        self.isWindows = (platform.system() == "Windows")
 
         self.logSubstitutions = {}
         self.logSubstitutions["<enter description here>"] = "%log%"
@@ -398,6 +399,8 @@ class P4Submit(Command):
         if not self.directSubmit:
             logMessage = extractLogMessageFromGitCommit(id)
             logMessage = logMessage.replace("\n", "\n\t")
+            if self.isWindows:
+                logMessage = logMessage.replace("\n", "\r\n")
             logMessage = logMessage.strip()
 
         template = read_pipe("p4 change -o")
@@ -444,6 +447,8 @@ class P4Submit(Command):
                     tmpFile.close()
                     os.remove(fileName)
                     submitTemplate = message[:message.index(separatorLine)]
+                    if self.isWindows:
+                        submitTemplate = submitTemplate.replace("\r\n", "\n")
 
             if response == "y" or response == "yes":
                if self.dryRun: