{"thread":{"id":"16593","subject":"[PATCH] git-p4: Fix bug in p4Where method.","startedAt":"2008-12-04T13:37:33Z","lastAt":"2008-12-05T02:23:39Z","messageCount":2,"participants":["Tor Arvid Lund","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"97145","messageId":"1228397853-15921-1-git-send-email-torarvid@gmail.com","threadId":"16593","inReplyTo":null,"subject":"[PATCH] git-p4: Fix bug in p4Where method.","fromName":"Tor Arvid Lund","fromEmail":"torarvid@gmail.com","sentAt":"2008-12-04T13:37:33Z","receivedAt":"2008-12-04T13:37:33Z","isPatch":true,"sender":{"key":"torarvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/439758?v=4"},"body":"When running:\n\np4 where //depot/SomePath/...\n\nThe result can in some situations look like:\n\n//depot/SomePath/... //client/SomePath/... /home/user/p4root/SomePath/...\n-//depot/SomePath/UndesiredSubdir/... //client/SomePath/UndesiredSubdir/... /home/user/p4root/SomePath/UndesiredSubdir/...\n\nThis depends on the users Client view. The current p4Where method will now\nreturn /home/user/p4root/SomePath/UndesiredSubdir/... which is not what we\nwant. This patch loops through the results from \"p4 where\", and picks the one\nwhere the depotFile exactly matches the given depotPath (//depot/SomePath/...\nin this example).\n\nSigned-off-by: Tor Arvid Lund <torarvid@gmail.com>\n---\n contrib/fast-import/git-p4 |   10 +++++++++-\n 1 files changed, 9 insertions(+), 1 deletions(-)\n\ndiff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4\nindex 46136d4..7ade777 100755\n--- a/contrib/fast-import/git-p4\n+++ b/contrib/fast-import/git-p4\n@@ -245,7 +245,15 @@ def p4Cmd(cmd):\n def p4Where(depotPath):\n     if not depotPath.endswith(\"/\"):\n         depotPath += \"/\"\n-    output = p4Cmd(\"where %s...\" % depotPath)\n+    depotPath = depotPath + \"...\"\n+    outputList = p4CmdList(\"where %s\" % depotPath)\n+    output = None\n+    for entry in outputList:\n+        if entry[\"depotFile\"] == depotPath:\n+            output = entry\n+            break\n+    if output == None:\n+        return \"\"\n     if output[\"code\"] == \"error\":\n         return \"\"\n     clientPath = \"\"\n-- \n1.6.0.2.1172.ga5ed0\n"},{"id":"97198","messageId":"7voczr1hsk.fsf@gitster.siamese.dyndns.org","threadId":"16593","inReplyTo":"1228397853-15921-1-git-send-email-torarvid@gmail.com","subject":"Re: [PATCH] git-p4: Fix bug in p4Where method.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-12-05T02:23:39Z","receivedAt":"2008-12-05T02:23:39Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks.  Will apply to 'master' and will be in 1.6.1 final, unless some p4\nusers object (I do not use p4 myself, so that is the best I could do).\n"}]}