git-p4: Unset P4DIFF environment variable when using 'p4 -du diff'
PATCH 1/1 git-p4: Unset P4DIFF environment variable when using 'p4 -du diff'
A custom diffing utility can be specified for the 'p4 diff' command by setting the P4DIFF environment variable. However when using a custom diffing utility such as 'vimdiff' passing options like -du can cause unexpected behavior.
Since the goal is to generate a unified diff of the changes and attach them to the bottom of the p4 submit log we should unset P4DIFF if it has been set in order to generate the diff properly.
--- contrib/fast-import/git-p4 | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
contrib/fast-import/git-p4 +2 -0
@@ -627,6 +627,8 @@ class P4Submit(Command): if self.interactive: submitTemplate = self.prepareLogMessage(template, logMessage) + if os.environ.has_key("P4DIFF"): + del(os.environ["P4DIFF"]) diff = read_pipe("p4 diff -du ...") for newFile in filesToAdd:
Signature · 1 line
1.5.4.3
PATCH 1/1 git-p4: Use P4EDITOR environment variable when set
Perforce allows you to set the P4EDITOR environment variable to your preferred editor for use in perforce. Since we are displaying a perforce changelog to the user we should use it when it is defined.
--- contrib/fast-import/git-p4 | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
contrib/fast-import/git-p4 +4 -1
@@ -652,7 +652,10 @@ class P4Submit(Command): defaultEditor = "vi" if platform.system() == "Windows": defaultEditor = "notepad" - editor = os.environ.get("EDITOR", defaultEditor); + if os.environ.has_key("P4EDITOR"): + editor = os.environ.get("P4EDITOR") + else: + editor = os.environ.get("EDITOR", defaultEditor); system(editor + " " + fileName) tmpFile = open(fileName, "rb") message = tmpFile.read()
Signature · 1 line
1.5.4.3