{"thread":{"id":"12660","subject":"[PATCH] git-p4: Unset P4DIFF environment variable when using 'p4 -du diff'","startedAt":"2008-03-13T00:03:23Z","lastAt":"2008-03-13T00:03:24Z","messageCount":2,"participants":["Shawn Bohrer"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"71885","messageId":"1205366604-12970-1-git-send-email-shawn.bohrer@gmail.com","threadId":"12660","inReplyTo":null,"subject":"[PATCH] git-p4: Unset P4DIFF environment variable when using 'p4 -du diff'","fromName":"Shawn Bohrer","fromEmail":"shawn.bohrer@gmail.com","sentAt":"2008-03-13T00:03:23Z","receivedAt":"2008-03-13T00:03:23Z","isPatch":true,"sender":{"key":"shawn.bohrer@gmail.com","avatar":"https://gravatar.com/avatar/6eb093ef7d276306d18366254e0c95ff6a5db58231ac7e82fe78c2800aaae1b6?d=mp&s=160"},"body":"A custom diffing utility can be specified for the 'p4 diff' command by\nsetting the P4DIFF environment variable.  However when using a custom\ndiffing utility such as 'vimdiff' passing options like -du can cause\nunexpected behavior.\n\nSince the goal is to generate a unified diff of the changes and attach\nthem to the bottom of the p4 submit log we should unset P4DIFF if it\nhas been set in order to generate the diff properly.\n\nSigned-off-by: Shawn Bohrer <shawn.bohrer@gmail.com>\n---\n contrib/fast-import/git-p4 |    2 ++\n 1 files changed, 2 insertions(+), 0 deletions(-)\n\ndiff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4\nindex 650ea34..0b46084 100755\n--- a/contrib/fast-import/git-p4\n+++ b/contrib/fast-import/git-p4\n@@ -627,6 +627,8 @@ class P4Submit(Command):\n \n         if self.interactive:\n             submitTemplate = self.prepareLogMessage(template, logMessage)\n+            if os.environ.has_key(\"P4DIFF\"):\n+                del(os.environ[\"P4DIFF\"])\n             diff = read_pipe(\"p4 diff -du ...\")\n \n             for newFile in filesToAdd:\n-- \n1.5.4.3\n"},{"id":"71886","messageId":"1205366604-12970-2-git-send-email-shawn.bohrer@gmail.com","threadId":"12660","inReplyTo":"1205366604-12970-1-git-send-email-shawn.bohrer@gmail.com","subject":"[PATCH] git-p4: Use P4EDITOR environment variable when set","fromName":"Shawn Bohrer","fromEmail":"shawn.bohrer@gmail.com","sentAt":"2008-03-13T00:03:24Z","receivedAt":"2008-03-13T00:03:24Z","isPatch":true,"sender":{"key":"shawn.bohrer@gmail.com","avatar":"https://gravatar.com/avatar/6eb093ef7d276306d18366254e0c95ff6a5db58231ac7e82fe78c2800aaae1b6?d=mp&s=160"},"body":"Perforce allows you to set the P4EDITOR environment variable to your\npreferred editor for use in perforce.  Since we are displaying a\nperforce changelog to the user we should use it when it is defined.\n\nSigned-off-by: Shawn Bohrer <shawn.bohrer@gmail.com>\n---\n contrib/fast-import/git-p4 |    5 ++++-\n 1 files changed, 4 insertions(+), 1 deletions(-)\n\ndiff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4\nindex 0b46084..55e38ff 100755\n--- a/contrib/fast-import/git-p4\n+++ b/contrib/fast-import/git-p4\n@@ -652,7 +652,10 @@ class P4Submit(Command):\n             defaultEditor = \"vi\"\n             if platform.system() == \"Windows\":\n                 defaultEditor = \"notepad\"\n-            editor = os.environ.get(\"EDITOR\", defaultEditor);\n+            if os.environ.has_key(\"P4EDITOR\"):\n+                editor = os.environ.get(\"P4EDITOR\")\n+            else:\n+                editor = os.environ.get(\"EDITOR\", defaultEditor);\n             system(editor + \" \" + fileName)\n             tmpFile = open(fileName, \"rb\")\n             message = tmpFile.read()\n-- \n1.5.4.3\n"}]}