{"thread":{"id":"28159","subject":"[PATCH v3 0/4] git-p4: Improve branch support","startedAt":"2011-08-18T23:44:02Z","lastAt":"2011-08-23T22:32:07Z","messageCount":12,"participants":["Vitor Antunes","Pete Wyckoff","Junio C Hamano"],"isPatch":true,"patchVersion":3,"patchTotal":4},"messages":[{"id":"173815","messageId":"1313711046-23489-1-git-send-email-vitor.hda@gmail.com","threadId":"28159","inReplyTo":null,"subject":"[PATCH v3 0/4] git-p4: Improve branch support","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2011-08-18T23:44:02Z","receivedAt":"2011-08-18T23:44:02Z","isPatch":true,"sender":{"key":"vitor.hda@gmail.com","avatar":"https://avatars.githubusercontent.com/u/606876?v=4"},"body":"Add missing test case from last version of this set of patches.\n\nVitor Antunes (4):\n  git-p4: Correct branch base depot path detection\n  git-p4: Allow filtering Perforce branches by user\n  git-p4: Allow branch definition with git config\n  git-p4: Add simple test case for branch import\n\n contrib/fast-import/git-p4     |   40 ++++++++++++++++++++++--\n contrib/fast-import/git-p4.txt |   13 ++++++++\n t/t9800-git-p4.sh              |   64 ++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 113 insertions(+), 4 deletions(-)\n\n-- \n1.7.5.4\n"},{"id":"173818","messageId":"1313711046-23489-2-git-send-email-vitor.hda@gmail.com","threadId":"28159","inReplyTo":"1313711046-23489-1-git-send-email-vitor.hda@gmail.com","subject":"[PATCH v3 1/4] git-p4: Correct branch base depot path detection","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2011-08-18T23:44:03Z","receivedAt":"2011-08-18T23:44:03Z","isPatch":true,"sender":{"key":"vitor.hda@gmail.com","avatar":"https://avatars.githubusercontent.com/u/606876?v=4"},"body":"When branch detection is enabled each branch is named in git after their\nrelative depot path in Perforce. To do this the depot paths are compared against\neach other to find their common base path. The current algorithm makes this\ncomparison on a character by character basis.\nAssuming we have the following branches:\n\n//depot/branches/featureA\n//depot/branches/featureB\n\nThen the base depot path would be //depot/branches/feature, which is an invalid\ndepot path.\nThe current patch fixes this by splitting the path into a list and comparing the\nlist entries, making it choose correctly //depot/branches as the base path.\n\nSigned-off-by: Vitor Antunes <vitor.hda@gmail.com>\n---\n contrib/fast-import/git-p4 |    8 +++++---\n 1 files changed, 5 insertions(+), 3 deletions(-)\n\ndiff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4\nindex 29a5390..95246e9 100755\n--- a/contrib/fast-import/git-p4\n+++ b/contrib/fast-import/git-p4\n@@ -1829,12 +1829,14 @@ class P4Sync(Command, P4UserMap):\n                     else:\n                         paths = []\n                         for (prev, cur) in zip(self.previousDepotPaths, depotPaths):\n-                            for i in range(0, min(len(cur), len(prev))):\n-                                if cur[i] <> prev[i]:\n+                            prev_list = prev.split(\"/\")\n+                            cur_list = cur.split(\"/\")\n+                            for i in range(0, min(len(cur_list), len(prev_list))):\n+                                if cur_list[i] <> prev_list[i]:\n                                     i = i - 1\n                                     break\n \n-                            paths.append (cur[:i + 1])\n+                            paths.append (\"/\".join(cur_list[:i + 1]))\n \n                         self.previousDepotPaths = paths\n \n-- \n1.7.5.4\n"},{"id":"173816","messageId":"1313711046-23489-3-git-send-email-vitor.hda@gmail.com","threadId":"28159","inReplyTo":"1313711046-23489-1-git-send-email-vitor.hda@gmail.com","subject":"[PATCH v3 2/4] git-p4: Allow filtering Perforce branches by user","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2011-08-18T23:44:04Z","receivedAt":"2011-08-18T23:44:04Z","isPatch":true,"sender":{"key":"vitor.hda@gmail.com","avatar":"https://avatars.githubusercontent.com/u/606876?v=4"},"body":"All branches in the Perforce server are downloaded to allow branch detection. If\nyou have a centralized server on a remote location and there is a big number of\nbranches this operation can take some time.\nThis patch adds the configuration option git-p4.branchUser to allow filtering\nthe branch list by user. Although this limits the branch maintenance in Perforce\nto be done by a single user, it might be an advantage when the number of\nbranches being used in a specific depot is very small when compared with the\nbranches available in the server.\n\nSigned-off-by: Vitor Antunes <vitor.hda@gmail.com>\n---\n contrib/fast-import/git-p4     |    8 +++++++-\n contrib/fast-import/git-p4.txt |    6 ++++++\n 2 files changed, 13 insertions(+), 1 deletions(-)\n\ndiff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4\nindex 95246e9..8b88f97 100755\n--- a/contrib/fast-import/git-p4\n+++ b/contrib/fast-import/git-p4\n@@ -1455,7 +1455,13 @@ class P4Sync(Command, P4UserMap):\n     def getBranchMapping(self):\n         lostAndFoundBranches = set()\n \n-        for info in p4CmdList(\"branches\"):\n+        user = gitConfig(\"git-p4.branchUser\")\n+        if len(user) > 0:\n+            command = \"branches -u %s\" % user\n+        else:\n+            command = \"branches\"\n+\n+        for info in p4CmdList(command):\n             details = p4Cmd(\"branch -o %s\" % info[\"branch\"])\n             viewIdx = 0\n             while details.has_key(\"View%s\" % viewIdx):\ndiff --git a/contrib/fast-import/git-p4.txt b/contrib/fast-import/git-p4.txt\nindex 2ffbccc..97b66b9 100644\n--- a/contrib/fast-import/git-p4.txt\n+++ b/contrib/fast-import/git-p4.txt\n@@ -257,6 +257,12 @@ Perforce server. Will enable --find-copies-harder git argument.\n \n   git config [--global] git-p4.detectCopies true\n \n+git-p4.branchUser\n+\n+Only use branch specifications defined by the selected username.\n+\n+  git config [--global] git-p4.branchUser username\n+\n Implementation Details...\n =========================\n \n-- \n1.7.5.4\n"},{"id":"173819","messageId":"1313711046-23489-4-git-send-email-vitor.hda@gmail.com","threadId":"28159","inReplyTo":"1313711046-23489-1-git-send-email-vitor.hda@gmail.com","subject":"[PATCH v3 3/4] git-p4: Allow branch definition with git config","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2011-08-18T23:44:05Z","receivedAt":"2011-08-18T23:44:05Z","isPatch":true,"sender":{"key":"vitor.hda@gmail.com","avatar":"https://avatars.githubusercontent.com/u/606876?v=4"},"body":"Perforce does not strictly require the usage of branch specifications to create\nbranches. In these cases the branch detection code of git-p4 will not be able to\nimport them.\nThis patch adds support for git-p4.branchList configuration option, allowing\nbranches to be defined in git config.\n\nSigned-off-by: Vitor Antunes <vitor.hda@gmail.com>\n---\n contrib/fast-import/git-p4     |   24 ++++++++++++++++++++++++\n contrib/fast-import/git-p4.txt |    7 +++++++\n 2 files changed, 31 insertions(+), 0 deletions(-)\n\ndiff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4\nindex 8b88f97..f622a38 100755\n--- a/contrib/fast-import/git-p4\n+++ b/contrib/fast-import/git-p4\n@@ -342,6 +342,11 @@ def gitConfig(key, args = None): # set args to \"--bool\", for instance\n         _gitConfig[key] = read_pipe(cmd, ignore_error=True).strip()\n     return _gitConfig[key]\n \n+def gitConfigList(key):\n+    if not _gitConfig.has_key(key):\n+        _gitConfig[key] = read_pipe(\"git config --get-all %s\" % key, ignore_error=True).strip().split(os.linesep)\n+    return _gitConfig[key]\n+\n def p4BranchesInGit(branchesAreInRemotes = True):\n     branches = {}\n \n@@ -1490,6 +1495,25 @@ class P4Sync(Command, P4UserMap):\n                     if source not in self.knownBranches:\n                         lostAndFoundBranches.add(source)\n \n+        # Perforce does not strictly require branches to be defined, so we also\n+        # check git config for a branch list.\n+        #\n+        # Example of branch definition in git config file:\n+        # [git-p4]\n+        #   branchList=main:branchA\n+        #   branchList=main:branchB\n+        #   branchList=branchA:branchC\n+        configBranches = gitConfigList(\"git-p4.branchList\")\n+        for branch in configBranches:\n+            if branch:\n+                (source, destination) = branch.split(\":\")\n+                self.knownBranches[destination] = source\n+\n+                lostAndFoundBranches.discard(destination)\n+\n+                if source not in self.knownBranches:\n+                    lostAndFoundBranches.add(source)\n+\n \n         for branch in lostAndFoundBranches:\n             self.knownBranches[branch] = branch\ndiff --git a/contrib/fast-import/git-p4.txt b/contrib/fast-import/git-p4.txt\nindex 97b66b9..52003ae 100644\n--- a/contrib/fast-import/git-p4.txt\n+++ b/contrib/fast-import/git-p4.txt\n@@ -263,6 +263,13 @@ Only use branch specifications defined by the selected username.\n \n   git config [--global] git-p4.branchUser username\n \n+git-p4.branchList\n+\n+List of branches to be imported when branch detection is enabled.\n+\n+  git config [--global] git-p4.branchList main:branchA\n+  git config [--global] --add git-p4.branchList main:branchB\n+\n Implementation Details...\n =========================\n \n-- \n1.7.5.4\n"},{"id":"173817","messageId":"1313711046-23489-5-git-send-email-vitor.hda@gmail.com","threadId":"28159","inReplyTo":"1313711046-23489-1-git-send-email-vitor.hda@gmail.com","subject":"[PATCH v3 4/4] git-p4: Add simple test case for branch import","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2011-08-18T23:44:06Z","receivedAt":"2011-08-18T23:44:06Z","isPatch":true,"sender":{"key":"vitor.hda@gmail.com","avatar":"https://avatars.githubusercontent.com/u/606876?v=4"},"body":"Create a basic branch structure in P4 and clone it with git-p4.\nAlso, make an update on P4 side and check if git-p4 imports it correctly.\nThe branch structure is created in such a way that git-p4 will fail to import\nupdates if patch \"git-p4: Correct branch base depot path detection\" is not\napplied.\n\nSigned-off-by: Vitor Antunes <vitor.hda@gmail.com>\n---\n t/t9800-git-p4.sh |   64 +++++++++++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 64 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t9800-git-p4.sh b/t/t9800-git-p4.sh\nindex a4f3d66..777ead8 100755\n--- a/t/t9800-git-p4.sh\n+++ b/t/t9800-git-p4.sh\n@@ -390,6 +390,70 @@ test_expect_success 'detect copies' '\n \trm -rf \"$git\" && mkdir \"$git\"\n '\n \n+# Create a simple branch structure in P4 depot to check if it is correctly\n+# cloned.\n+test_expect_success 'add simple p4 branches' '\n+\tcd \"$cli\" &&\n+\tmkdir branch1 &&\n+\tcd branch1 &&\n+\techo file1 >file1 &&\n+\techo file2 >file2 &&\n+\tp4 add file* &&\n+\tp4 submit -d \"branch1\" &&\n+\tp4 integrate //depot/branch1/... //depot/branch2/... &&\n+\tp4 submit -d \"branch2\" &&\n+\techo file3 >file3 &&\n+\tp4 add file3 &&\n+\tp4 submit -d \"add file3 in branch1\" &&\n+\tp4 open file2 &&\n+\techo update >>file2 &&\n+\tp4 submit -d \"update file2 in branch1\" &&\n+\tp4 integrate //depot/branch1/... //depot/branch3/... &&\n+\tp4 submit -d \"branch3\" &&\n+\tcd \"$TRASH_DIRECTORY\"\n+'\n+\n+# Configure branches through git-config and clone them.\n+# All files are tested to make sure branches were cloned correctly.\n+# Finally, make an update to branch1 on P4 side to check if it is imported\n+# correctly by git-p4.\n+test_expect_success 'git-p4 clone simple branches' '\n+\tgit init \"$git\" &&\n+\tcd \"$git\" &&\n+\tgit config git-p4.branchList branch1:branch2 &&\n+\tgit config --add git-p4.branchList branch1:branch3 &&\n+\tcd \"$TRASH_DIRECTORY\" &&\n+\t\"$GITP4\" clone --dest=\"$git\" --detect-branches //depot@all &&\n+\tcd \"$git\" &&\n+\tgit log --all --graph --decorate --stat &&\n+\tgit reset --hard p4/depot/branch1 &&\n+\ttest -f file1 &&\n+\ttest -f file2 &&\n+\ttest -f file3 &&\n+\tgrep -q update file2 &&\n+\tgit reset --hard p4/depot/branch2 &&\n+\ttest -f file1 &&\n+\ttest -f file2 &&\n+\ttest \\! -z file3 &&\n+\t! grep -q update file2 &&\n+\tgit reset --hard p4/depot/branch3 &&\n+\ttest -f file1 &&\n+\ttest -f file2 &&\n+\ttest -f file3 &&\n+\tgrep -q update file2 &&\n+\tcd \"$cli\" &&\n+\tcd branch1 &&\n+\tp4 edit file2 &&\n+\techo file2_ >> file2 &&\n+\tp4 submit -d \"update file2 in branch3\" &&\n+\tcd \"$git\" &&\n+\tgit reset --hard p4/depot/branch1 &&\n+\t\"$GITP4\" rebase &&\n+\tgrep -q file2_ file2 &&\n+\tcd \"$TRASH_DIRECTORY\" &&\n+\trm -rf \"$git\" && mkdir \"$git\"\n+'\n+\n test_expect_success 'shutdown' '\n \tpid=`pgrep -f p4d` &&\n \ttest -n \"$pid\" &&\n-- \n1.7.5.4\n"},{"id":"173851","messageId":"20110819115310.GC15639@padd.com","threadId":"28159","inReplyTo":"1313711046-23489-1-git-send-email-vitor.hda@gmail.com","subject":"Re: [PATCH v3 0/4] git-p4: Improve branch support","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2011-08-19T11:53:10Z","receivedAt":"2011-08-19T11:53:10Z","isPatch":true,"sender":{"key":"pw@padd.com","avatar":null},"body":"vitor.hda@gmail.com wrote on Fri, 19 Aug 2011 00:44 +0100:\n> Add missing test case from last version of this set of patches.\n> \n> Vitor Antunes (4):\n>   git-p4: Correct branch base depot path detection\n>   git-p4: Allow filtering Perforce branches by user\n>   git-p4: Allow branch definition with git config\n>   git-p4: Add simple test case for branch import\n> \n>  contrib/fast-import/git-p4     |   40 ++++++++++++++++++++++--\n>  contrib/fast-import/git-p4.txt |   13 ++++++++\n>  t/t9800-git-p4.sh              |   64 ++++++++++++++++++++++++++++++++++++++++\n>  3 files changed, 113 insertions(+), 4 deletions(-)\n\nPatches 1 and 2 are great.  We should have gotten those in way\nback when you first submitted them.  I happily ack those.\n\nI'm still a bit hung up on #3, mainly because I don't get branch\nsupport.  Let me play around with your test.  Having this\nplaybook of how it is supposed to work will help to educate me.\n\n\t\t-- Pete\n"},{"id":"173859","messageId":"CAOpHH-WeLWyEZaktYRzVN+dfgqu3==o4bgrfzpvS-QUCQboPgg@mail.gmail.com","threadId":"28159","inReplyTo":"20110819115310.GC15639@padd.com","subject":"Re: [PATCH v3 0/4] git-p4: Improve branch support","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2011-08-19T14:30:01Z","receivedAt":"2011-08-19T14:30:01Z","isPatch":true,"sender":{"key":"vitor.hda@gmail.com","avatar":"https://avatars.githubusercontent.com/u/606876?v=4"},"body":"On Fri, Aug 19, 2011 at 12:53 PM, Pete Wyckoff <pw@padd.com> wrote:\n> Patches 1 and 2 are great.  We should have gotten those in way\n> back when you first submitted them.  I happily ack those.\n>\n> I'm still a bit hung up on #3, mainly because I don't get branch\n> support.  Let me play around with your test.  Having this\n> playbook of how it is supposed to work will help to educate me.\n\n(I am probably going in too much detail here. Please skip any\nredundant information.)\n\nIn general, you can see branches in P4 as you do in SVN. They are\nsimple copies from one directory to another. For example:\n\n    p4 integrate //depot/big/directory/path/myproj/version_A \\\n                 //depot/big/directory/path/myproj/version_B\n\nNow the history of \"version_B\" is tied to \"version_A\". If you want to\nintegrate (merge, in this case) new updates from one of the\ndirectories to the other you can just rerun the above command\n(version_A and version_B order may change depending on the direction\nof the merge).\n\nP4 also allows you to define \"branch specs\" that you can use as a\nshort hand instead of having to type in the full directory paths. So,\nassuming that you have a branch named \"myproj_B\" with the following\nview defined:\n\n    //depot/big/directory/path/myproj/version_A \\\n        //depot/big/directory/path/myproj/version_B\n\nWhen you want to integrate it again you can simply type:\n\n    p4 integrate -b myproj_B\n\nor, if you want to integrate from version_B into version_A instead:\n\n    p4 integrate -b myproj_B -r\n\ngit-p4 is using these branch specs to identify branches. Without this\nextra information it is nearly impossible for it to identify branches\nbecause an integrate can be done of a single file.\n\nBut since P4 does not strictly require branch specs and because most\nof the time integrations are done through P4V, then most of the time\nno branch specs are created. Now, if this happens git-p4 will not be\nable to detect branches! And creating branches in P4 just for git-p4\ndoes not make much sense, right? This is the main reason behind the\nthird patch... :)\n\nSorry for the long email.\n\n-- \nVitor Antunes\n"},{"id":"173869","messageId":"7v4o1d46uk.fsf@alter.siamese.dyndns.org","threadId":"28159","inReplyTo":"1313711046-23489-1-git-send-email-vitor.hda@gmail.com","subject":"Re: [PATCH v3 0/4] git-p4: Improve branch support","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-08-19T18:02:59Z","receivedAt":"2011-08-19T18:02:59Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Even though this is labeled as v3, I do not see a corresponding v2 in\nrecent mail log. Is this an unrelated series that depends on v2 of your\n\"p4 rename/copy\" topic?\n"},{"id":"173874","messageId":"CAOpHH-XduhWd_CTORxRoc24En1+Q_kvxb0uwD6HQqLNv+B0phA@mail.gmail.com","threadId":"28159","inReplyTo":"7v4o1d46uk.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v3 0/4] git-p4: Improve branch support","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2011-08-19T18:23:17Z","receivedAt":"2011-08-19T18:23:17Z","isPatch":true,"sender":{"key":"vitor.hda@gmail.com","avatar":"https://avatars.githubusercontent.com/u/606876?v=4"},"body":"On Fri, Aug 19, 2011 at 7:02 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Even though this is labeled as v3, I do not see a corresponding v2 in\n> recent mail log. Is this an unrelated series that depends on v2 of your\n> \"p4 rename/copy\" topic?\n\nYou have to search in older archives... :)\n\nhttp://article.gmane.org/gmane.comp.version-control.git/167998\n\n-- \nVitor Antunes\n"},{"id":"173933","messageId":"20110820191133.GB7135@arf.padd.com","threadId":"28159","inReplyTo":"1313711046-23489-5-git-send-email-vitor.hda@gmail.com","subject":"Re: [PATCH v3 4/4] git-p4: Add simple test case for branch import","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2011-08-20T19:11:33Z","receivedAt":"2011-08-20T19:11:33Z","isPatch":true,"sender":{"key":"pw@padd.com","avatar":null},"body":"vitor.hda@gmail.com wrote on Fri, 19 Aug 2011 00:44 +0100:\n> Create a basic branch structure in P4 and clone it with git-p4.\n> Also, make an update on P4 side and check if git-p4 imports it correctly.\n> The branch structure is created in such a way that git-p4 will fail to import\n> updates if patch \"git-p4: Correct branch base depot path detection\" is not\n> applied.\n\nHere are some minor style edits to this test.\n\n\t\t-- Pete\n\n-----------------8<-----------------------\n\n>From 958effaad24d129ad472b48f3a691c7e7de2e918 Mon Sep 17 00:00:00 2001\nFrom: Pete Wyckoff <pw@padd.com>\nDate: Sat, 20 Aug 2011 14:24:31 -0400\nSubject: [PATCH 2/4] git-p4: simple branch tests edits\n\nMore review comments.\n\nSigned-off-by: Pete Wyckoff <pw@padd.com>\n---\n t/t9800-git-p4.sh |   17 +++++++----------\n 1 files changed, 7 insertions(+), 10 deletions(-)\n\ndiff --git a/t/t9800-git-p4.sh b/t/t9800-git-p4.sh\nindex bbf1485..5bcb8b4 100755\n--- a/t/t9800-git-p4.sh\n+++ b/t/t9800-git-p4.sh\n@@ -412,7 +412,7 @@ test_expect_success 'add simple p4 branches' '\n \tcd branch1 &&\n \techo file1 >file1 &&\n \techo file2 >file2 &&\n-\tp4 add file* &&\n+\tp4 add file1 file2 &&\n \tp4 submit -d \"branch1\" &&\n \tp4 integrate //depot/branch1/... //depot/branch2/... &&\n \tp4 submit -d \"branch2\" &&\n@@ -432,13 +432,12 @@ test_expect_success 'add simple p4 branches' '\n # Finally, make an update to branch1 on P4 side to check if it is imported\n # correctly by git-p4.\n test_expect_success 'git-p4 clone simple branches' '\n-\tgit init \"$git\" &&\n+\ttest_when_finished cleanup_git &&\n+\ttest_create_repo \"$git\" &&\n \tcd \"$git\" &&\n \tgit config git-p4.branchList branch1:branch2 &&\n \tgit config --add git-p4.branchList branch1:branch3 &&\n-\tcd \"$TRASH_DIRECTORY\" &&\n-\t\"$GITP4\" clone --dest=\"$git\" --detect-branches //depot@all &&\n-\tcd \"$git\" &&\n+\t\"$GITP4\" clone --dest=. --detect-branches //depot@all &&\n \tgit log --all --graph --decorate --stat &&\n \tgit reset --hard p4/depot/branch1 &&\n \ttest -f file1 &&\n@@ -448,7 +447,7 @@ test_expect_success 'git-p4 clone simple branches' '\n \tgit reset --hard p4/depot/branch2 &&\n \ttest -f file1 &&\n \ttest -f file2 &&\n-\ttest \\! -z file3 &&\n+\ttest ! -f file3 &&\n \t! grep -q update file2 &&\n \tgit reset --hard p4/depot/branch3 &&\n \ttest -f file1 &&\n@@ -458,14 +457,12 @@ test_expect_success 'git-p4 clone simple branches' '\n \tcd \"$cli\" &&\n \tcd branch1 &&\n \tp4 edit file2 &&\n-\techo file2_ >> file2 &&\n+\techo file2_ >>file2 &&\n \tp4 submit -d \"update file2 in branch3\" &&\n \tcd \"$git\" &&\n \tgit reset --hard p4/depot/branch1 &&\n \t\"$GITP4\" rebase &&\n-\tgrep -q file2_ file2 &&\n-\tcd \"$TRASH_DIRECTORY\" &&\n-\trm -rf \"$git\" && mkdir \"$git\"\n+\tgrep -q file2_ file2\n '\n \n # Create a complex branch structure in P4 depot to check if they are correctly\n-- \n1.7.5.4\n"},{"id":"173935","messageId":"20110820191407.GD7135@arf.padd.com","threadId":"28159","inReplyTo":"CAOpHH-WeLWyEZaktYRzVN+dfgqu3==o4bgrfzpvS-QUCQboPgg@mail.gmail.com","subject":"Re: [PATCH v3 0/4] git-p4: Improve branch support","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2011-08-20T19:14:07Z","receivedAt":"2011-08-20T19:14:07Z","isPatch":true,"sender":{"key":"pw@padd.com","avatar":null},"body":"vitor.hda@gmail.com wrote on Fri, 19 Aug 2011 15:30 +0100:\n> On Fri, Aug 19, 2011 at 12:53 PM, Pete Wyckoff <pw@padd.com> wrote:\n> > Patches 1 and 2 are great.  We should have gotten those in way\n> > back when you first submitted them.  I happily ack those.\n> >\n> > I'm still a bit hung up on #3, mainly because I don't get branch\n> > support.  Let me play around with your test.  Having this\n> > playbook of how it is supposed to work will help to educate me.\n> \n> (I am probably going in too much detail here. Please skip any\n> redundant information.)\n> \n> In general, you can see branches in P4 as you do in SVN. They are\n> simple copies from one directory to another. For example:\n> \n>     p4 integrate //depot/big/directory/path/myproj/version_A \\\n>                  //depot/big/directory/path/myproj/version_B\n> \n> Now the history of \"version_B\" is tied to \"version_A\". If you want to\n> integrate (merge, in this case) new updates from one of the\n> directories to the other you can just rerun the above command\n> (version_A and version_B order may change depending on the direction\n> of the merge).\n> \n> P4 also allows you to define \"branch specs\" that you can use as a\n> short hand instead of having to type in the full directory paths. So,\n> assuming that you have a branch named \"myproj_B\" with the following\n> view defined:\n> \n>     //depot/big/directory/path/myproj/version_A \\\n>         //depot/big/directory/path/myproj/version_B\n> \n> When you want to integrate it again you can simply type:\n> \n>     p4 integrate -b myproj_B\n> \n> or, if you want to integrate from version_B into version_A instead:\n> \n>     p4 integrate -b myproj_B -r\n> \n> git-p4 is using these branch specs to identify branches. Without this\n> extra information it is nearly impossible for it to identify branches\n> because an integrate can be done of a single file.\n> \n> But since P4 does not strictly require branch specs and because most\n> of the time integrations are done through P4V, then most of the time\n> no branch specs are created. Now, if this happens git-p4 will not be\n> able to detect branches! And creating branches in P4 just for git-p4\n> does not make much sense, right? This is the main reason behind the\n> third patch... :)\n\nThank you for these useful comments.  I have taken a first stab\nat documenting the bevy of confusing branch flags and settings\nin git-p4.  Please correct my errors and add other information\nthat is missing.\n\nIn particular, a clear case of how to set up the branches for\nthe branchList example would be good.  My minimal test did not\nexactly work.\n\n\n\t\t-- Pete\n\n--------------8<----------------------\n\nFrom 36608a6e195041e8738bab24b84fadd0bf386865 Mon Sep 17 00:00:00 2001\nFrom: Pete Wyckoff <pw@padd.com>\nDate: Sat, 20 Aug 2011 15:04:09 -0400\nSubject: [PATCH 4/4] git-p4: branch detection documentation start\n\nInitial stab at documentation for --detect-branches and the\nnew branchList config setting.\n\nSigned-off-by: Pete Wyckoff <pw@padd.com>\n---\n contrib/fast-import/git-p4.txt |   48 +++++++++++++++++++++++++++++++++++++++-\n 1 files changed, 47 insertions(+), 1 deletions(-)\n\ndiff --git a/contrib/fast-import/git-p4.txt b/contrib/fast-import/git-p4.txt\nindex 52003ae..6d21557 100644\n--- a/contrib/fast-import/git-p4.txt\n+++ b/contrib/fast-import/git-p4.txt\n@@ -265,11 +265,57 @@ Only use branch specifications defined by the selected username.\n \n git-p4.branchList\n \n-List of branches to be imported when branch detection is enabled.\n+List of branches to be imported when branch detection is enabled.  This\n+example shows that branchA and branchB are both created off branch main.\n \n   git config [--global] git-p4.branchList main:branchA\n   git config [--global] --add git-p4.branchList main:branchB\n \n+Branch Detection\n+================\n+\n+There are a few options that try to automatically create branches in git\n+corresponding to branches in p4.\n+\n+Unfortunately, the concept of branch in p4 is quite different:  a p4\n+branch is a mapping from one area of the repository to another.  It is\n+used as input to \"p4 integrate\" to specify the source and destination of\n+an integration.\n+\n+If you have a repository where all the branches are below a single\n+directory, you can use \"--detect-branches\" when cloning or syncing to\n+have git-p4 automatically look up the p4 branches and use these to\n+generate branches in git.  Example:\n+\n+    P4 repository structure:\n+\n+\t//depot/main/...\n+\t//depot/branch1/...\n+    \n+    View section from \"p4 branch -o branch1\"\n+\n+\t//depot/main/... //depot/branch1/...\n+    \n+    Git clone command:\n+\n+\tgit-p4 clone --detect-branches //depot@all\n+\n+    Produces a separate branch in remotes/p4 for\n+    //depot/main (called \"master\"), and one for //depot/branch1\n+    (called \"depot/branch1\").\n+\n+However, it is not necessary to create branches in p4 to be able to\n+use them like branches.  It is quite difficult to detect this\n+automatically, but a git configuration setting \"git-p4.branchList\" can be\n+used to explicitly identify branch relationships.  It is a list of\n+\"source\":\"destination\" pairs, like a simple p4 branch specification,\n+where the \"source\" and \"destination\" are the path elements in the\n+p4 repository.  The example above relied on the presence of the p4\n+branch.  Without that, you can get the same results by setting:\n+\n+  git config git-p4.branchList main:branch1\n+\n+\n Implementation Details...\n =========================\n \n-- \n1.7.5.4\n"},{"id":"174128","messageId":"CAOpHH-X2OP983mX_oMmsMg2-8UAKxK_2J0Fz_a_pDN7HhOn7Pg@mail.gmail.com","threadId":"28159","inReplyTo":"20110820191407.GD7135@arf.padd.com","subject":"Re: [PATCH v3 0/4] git-p4: Improve branch support","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2011-08-23T22:32:07Z","receivedAt":"2011-08-23T22:32:07Z","isPatch":true,"sender":{"key":"vitor.hda@gmail.com","avatar":"https://avatars.githubusercontent.com/u/606876?v=4"},"body":"On Sat, Aug 20, 2011 at 8:14 PM, Pete Wyckoff <pw@padd.com> wrote:\n> In particular, a clear case of how to set up the branches for\n> the branchList example would be good.  My minimal test did not\n> exactly work.\n\nCould you send me the list of steps you followed that resulted in git-p4\nfailing to detect the branches?\n\nThanks,\n-- \nVitor Antunes\n"}]}