git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] git-p4: Unset P4DIFF environment variable when using 'p4 -du diff'
@ 2008-03-13  0:03 Shawn Bohrer
  2008-03-13  0:03 ` [PATCH] git-p4: Use P4EDITOR environment variable when set Shawn Bohrer
  0 siblings, 1 reply; 2+ messages in thread
From: Shawn Bohrer @ 2008-03-13  0:03 UTC (permalink / raw)
  To: git; +Cc: simon, Shawn Bohrer

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH] git-p4: Use P4EDITOR environment variable when set
  2008-03-13  0:03 [PATCH] git-p4: Unset P4DIFF environment variable when using 'p4 -du diff' Shawn Bohrer
@ 2008-03-13  0:03 ` Shawn Bohrer
  0 siblings, 0 replies; 2+ messages in thread
From: Shawn Bohrer @ 2008-03-13  0:03 UTC (permalink / raw)
  To: git; +Cc: simon, Shawn Bohrer

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-03-13  0:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-13  0:03 [PATCH] git-p4: Unset P4DIFF environment variable when using 'p4 -du diff' Shawn Bohrer
2008-03-13  0:03 ` [PATCH] git-p4: Use P4EDITOR environment variable when set Shawn Bohrer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).