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

Subsystems: the rest

DORMANTno replies

2 messages, 1 author, 2016-06-15 · open the first message on its own page

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

From: Shawn Bohrer <hidden>
Date: 2016-06-15 22:44:22

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 <redacted>
---
 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

[PATCH] git-p4: Use P4EDITOR environment variable when set

From: Shawn Bohrer <hidden>
Date: 2016-06-15 22:44:22

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 <redacted>
---
 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help