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

2 messages from 2008-03-13 to 2008-03-13. Participants: Shawn Bohrer.
Thread: https://gitlist.dev/t/12660

## Shawn Bohrer, 2008-03-13 00:03

Subject: [PATCH] git-p4: Unset P4DIFF environment variable when using 'p4 -du diff'
Message-ID: <1205366604-12970-1-git-send-email-shawn.bohrer@gmail.com>
URL: https://gitlist.dev/e/1205366604-12970-1-git-send-email-shawn.bohrer%40gmail.com

```
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(-)

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, 2008-03-13 00:03

Subject: [PATCH] git-p4: Use P4EDITOR environment variable when set
Message-ID: <1205366604-12970-2-git-send-email-shawn.bohrer@gmail.com>
URL: https://gitlist.dev/e/1205366604-12970-2-git-send-email-shawn.bohrer%40gmail.com
In-Reply-To: <1205366604-12970-1-git-send-email-shawn.bohrer@gmail.com>

```
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(-)

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

```
