{"thread":{"id":"40976","subject":"Bug: git-p4 can skip changes when syncing large from multiple depot paths","startedAt":"2015-12-12T02:52:51Z","lastAt":"2015-12-13T19:04:43Z","messageCount":2,"participants":["James Farwell","Luke Diamand"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"274312","messageId":"1449888770698.39553@vmware.com","threadId":"40976","inReplyTo":null,"subject":"Bug: git-p4 can skip changes when syncing large from multiple depot paths","fromName":"James Farwell","fromEmail":"jfarwell@vmware.com","sentAt":"2015-12-12T02:52:51Z","receivedAt":"2015-12-12T02:52:51Z","isPatch":false,"sender":{"key":"jfarwell@vmware.com","avatar":"https://gravatar.com/avatar/ab0d9202e2b5b9267d4c1cc792bbe3b00945504feeef83b0633770346fc71c7d?d=mp&s=160"},"body":"\nReproduction Steps:\n\n1. Have a git repo cloned from a perforce repo using multiple depot paths (e.g. //depot/foo/ and //depot/bar/).\n2. Add changes to the perforce repo in both depot paths. (e.g. 5 changes in each)\n2. Do a \"git p4 sync --changes_block_size n\" where n is smaller than the number of changes applied to each depot path. (e.g. 2)\n\n\nExpected Behavior:\n\nAll changes should sync and become commits in the git repo.\n\n\nActual Behavior:\n\nAll changes from the first depot path (if any) sync. After that only a small subset of changes from the remaining depot paths sync, causing some changes to be skipped entirely.\n\n\nBest Guess:\n\nI believe this was introduced in commit 1051ef00636357061d72bcf673da86054fb14a12. The important code in question is the p4ChangesForPaths function, which contains a for loop that iterates over the depot paths, which then contains a while loop which iterates over the blocks. This change modified the inner while loop so that with every iteration it modifies changeStart, which causes the original value of changeStart to be lost. The first iteration of the for loop will correctly iterate across all the blocks until changeStart is within one block of the last change number, but then all subsequent iterations of the for loop will use that final changeStart value, causing any changes in those depot paths in earlier blocks to be skipped.\n\nThis can probably be easily remedied by using a temporary \"start\" variable for the block iteration, much like there is already a temporary \"end\" variable, and resetting it to the value of changeStart at the top of the for loop. (Note: this appears to be how the code prior to 1051ef00636357061d72bcf673da86054fb14a12 functioned).\n\n\nThanks!\n- James"},{"id":"274356","messageId":"CAE5ih79iZDx58dagzNpND=QFOQssb2BhuTTQu=KDrdrNoyb0XQ@mail.gmail.com","threadId":"40976","inReplyTo":"1449888770698.39553@vmware.com","subject":"Re: Bug: git-p4 can skip changes when syncing large from multiple depot paths","fromName":"Luke Diamand","fromEmail":"luke@diamand.org","sentAt":"2015-12-13T19:04:43Z","receivedAt":"2015-12-13T19:04:43Z","isPatch":false,"sender":{"key":"luke@diamand.org","avatar":"https://avatars.githubusercontent.com/u/5330967?v=4"},"body":"On 12 December 2015 at 02:52, James Farwell <jfarwell@vmware.com> wrote:\n>\n> Reproduction Steps:\n>\n> 1. Have a git repo cloned from a perforce repo using multiple depot paths (e.g. //depot/foo/ and //depot/bar/).\n> 2. Add changes to the perforce repo in both depot paths. (e.g. 5 changes in each)\n> 2. Do a \"git p4 sync --changes_block_size n\" where n is smaller than the number of changes applied to each depot path. (e.g. 2)\n\nThanks - this is definitely a bug. Let me see if I can work up a\ntestcase for it and a fix.\n\nLuke\n"}]}