threads / patch / 12660

patchgit-p4: Unset P4DIFF environment variable when using 'p4 -du diff'

Subject: [PATCH] git-p4: Unset P4DIFF environment variable when using 'p4 -du diff'

## tl;dr

2 messages between Mar 13, 2008 and Mar 13, 2008. Diffs are folded; open one to read it.

replies: 1people: 1as markdown or json

Shawn Bohrer· Mar 13, 2008, 00:03 UTC · lore

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.

Signed-off-by: Shawn Bohrer <shawn.bohrer@gmail.com>
---
 contrib/fast-import/git-p4 |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
Show changes to contrib/fast-import/git-p4 +2 −0
diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
index 650ea34..0b46084 100755
--- a/contrib/fast-import/git-p4
+++ b/contrib/fast-import/git-p4
@@ -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:
-- 
1.5.4.3
Shawn Bohrer· Mar 13, 2008, 00:03 UTC · re: Shawn Bohrer · lore

[PATCH] 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.

Signed-off-by: Shawn Bohrer <shawn.bohrer@gmail.com>
---
 contrib/fast-import/git-p4 |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
Show changes to contrib/fast-import/git-p4 +4 −1
diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
index 0b46084..55e38ff 100755
--- a/contrib/fast-import/git-p4
+++ b/contrib/fast-import/git-p4
@@ -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()
-- 
1.5.4.3

← back to recent threads