{"thread":{"id":"26541","subject":"[PATCH 1/3] git-p4: Improve rename detection support","startedAt":"2011-02-18T00:23:20Z","lastAt":"2011-02-19T12:13:28Z","messageCount":2,"participants":["Vitor Antunes","Pete Wyckoff"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"161473","messageId":"1297988600-7002-1-git-send-email-vitor.hda@gmail.com","threadId":"26541","inReplyTo":null,"subject":"[PATCH 1/3] git-p4: Improve rename detection support","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2011-02-18T00:23:20Z","receivedAt":"2011-02-18T00:23:20Z","isPatch":true,"sender":{"key":"vitor.hda@gmail.com","avatar":"https://avatars.githubusercontent.com/u/606876?v=4"},"body":"Only open files for edit after integrating if the SHA1 of source and destination\ndiffer from each other.\nAdd git config option detectRenames to allow permanent rename detection. This\noptions should be set to a true/false value.\nRename \"detectRename\" variable to \"detectRenames\" to make it more coherent with\nthe description in git man pages, which always use plural.\n\nSigned-off-by: Vitor Antunes <vitor.hda@gmail.com>\n---\n contrib/fast-import/git-p4 |   19 +++++++++++++++----\n 1 files changed, 15 insertions(+), 4 deletions(-)\n\ndiff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4\nindex a92beb6..b0da28a 100755\n--- a/contrib/fast-import/git-p4\n+++ b/contrib/fast-import/git-p4\n@@ -543,13 +543,13 @@ class P4Submit(Command):\n         self.options = [\n                 optparse.make_option(\"--verbose\", dest=\"verbose\", action=\"store_true\"),\n                 optparse.make_option(\"--origin\", dest=\"origin\"),\n-                optparse.make_option(\"-M\", dest=\"detectRename\", action=\"store_true\"),\n+                optparse.make_option(\"-M\", dest=\"detectRenames\", action=\"store_true\"),\n         ]\n         self.description = \"Submit changes from git to the perforce depot.\"\n         self.usage += \" [name of git branch to submit into perforce depot]\"\n         self.interactive = True\n         self.origin = \"\"\n-        self.detectRename = False\n+        self.detectRenames = False\n         self.verbose = False\n         self.isWindows = (platform.system() == \"Windows\")\n \n@@ -613,7 +613,16 @@ class P4Submit(Command):\n \n     def applyCommit(self, id):\n         print \"Applying %s\" % (read_pipe(\"git log --max-count=1 --pretty=oneline %s\" % id))\n-        diffOpts = (\"\", \"-M\")[self.detectRename]\n+\n+        if not self.detectRenames:\n+            # If not explicitly set check the config variable\n+            self.detectRenames = gitConfig(\"git-p4.detectRenames\").lower() == \"true\"\n+\n+        if self.detectRenames:\n+            diffOpts = \"-M\"\n+        else:\n+            diffOpts = \"\"\n+\n         diff = read_pipe_lines(\"git diff-tree -r %s \\\"%s^\\\" \\\"%s\\\"\" % (diffOpts, id, id))\n         filesToAdd = set()\n         filesToDelete = set()\n@@ -640,8 +649,10 @@ class P4Submit(Command):\n             elif modifier == \"R\":\n                 src, dest = diff['src'], diff['dst']\n                 p4_system(\"integrate -Dt \\\"%s\\\" \\\"%s\\\"\" % (src, dest))\n-                p4_system(\"edit \\\"%s\\\"\" % (dest))\n+                if diff['src_sha1'] != diff['dst_sha1']:\n+                    p4_system(\"edit \\\"%s\\\"\" % (dest))\n                 if isModeExecChanged(diff['src_mode'], diff['dst_mode']):\n+                    p4_system(\"edit \\\"%s\\\"\" % (dest))\n                     filesToChangeExecBit[dest] = diff['dst_mode']\n                 os.unlink(dest)\n                 editedFiles.add(dest)\n-- \n1.7.2.3\n"},{"id":"161604","messageId":"20110219121328.GA5065@arf.padd.com","threadId":"26541","inReplyTo":"1297988600-7002-1-git-send-email-vitor.hda@gmail.com","subject":"Re: [PATCH 1/3] git-p4: Improve rename detection support","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2011-02-19T12:13:28Z","receivedAt":"2011-02-19T12:13:28Z","isPatch":true,"sender":{"key":"pw@padd.com","avatar":null},"body":"vitor.hda@gmail.com wrote on Fri, 18 Feb 2011 00:23 +0000:\n> Only open files for edit after integrating if the SHA1 of source and destination\n> differ from each other.\n> Add git config option detectRenames to allow permanent rename detection. This\n> options should be set to a true/false value.\n> Rename \"detectRename\" variable to \"detectRenames\" to make it more coherent with\n> the description in git man pages, which always use plural.\n> \n> Signed-off-by: Vitor Antunes <vitor.hda@gmail.com>\n\nClean change now, thanks.\n\nAcked-by: Pete Wyckoff <pw@padd.com>\n"}]}