diff options
-rw-r--r-- | Documentation/git-p4.txt | 5 | ||||
-rwxr-xr-x | git-p4.py | 14 | ||||
-rwxr-xr-x | t/t9806-git-p4-options.sh | 8 |
3 files changed, 20 insertions, 7 deletions
diff --git a/Documentation/git-p4.txt b/Documentation/git-p4.txt index 7bd5c290c4..e79d0467c4 100644 --- a/Documentation/git-p4.txt +++ b/Documentation/git-p4.txt @@ -112,6 +112,11 @@ will be fetched and consulted first during a 'git p4 sync'. Since importing directly from p4 is considerably slower than pulling changes from a git remote, this can be useful in a multi-developer environment. +If there are multiple branches, doing 'git p4 sync' will automatically +use the "BRANCH DETECTION" algorithm to try to partition new changes +into the right branch. This can be overridden with the '--branch' +option to specify just a single branch to update. + Rebase ~~~~~~ @@ -2804,14 +2804,22 @@ class P4Sync(Command, P4UserMap): # branches holds mapping from branch name to sha1 branches = p4BranchesInGit(self.importIntoRemotes) - self.p4BranchesInGit = branches.keys() - for branch in branches.keys(): - self.initialParents[self.refPrefix + branch] = branches[branch] + + # restrict to just this one, disabling detect-branches + if branch_arg_given: + short = self.branch.split("/")[-1] + if short in branches: + self.p4BranchesInGit = [ short ] + else: + self.p4BranchesInGit = branches.keys() if len(self.p4BranchesInGit) > 1: if not self.silent: print "Importing from/into multiple branches" self.detectBranches = True + for branch in branches.keys(): + self.initialParents[self.refPrefix + branch] = \ + branches[branch] if self.verbose: print "branches: %s" % self.p4BranchesInGit diff --git a/t/t9806-git-p4-options.sh b/t/t9806-git-p4-options.sh index a51f1221ed..3b0000fab2 100755 --- a/t/t9806-git-p4-options.sh +++ b/t/t9806-git-p4-options.sh @@ -88,14 +88,14 @@ test_expect_success 'sync when two branches but no master should noop' ' ) ' -test_expect_failure 'sync --branch updates specified branch' ' +test_expect_success 'sync --branch updates specific branch, no detection' ' test_when_finished cleanup_git && ( cd "$git" && git init && - git p4 sync --branch=refs/remotes/p4/b1 //depot@2 && - git p4 sync --branch=refs/remotes/p4/b2 //depot@2 && - git p4 sync --branch=refs/remotes/p4/b2 && + git p4 sync --branch=b1 //depot@2 && + git p4 sync --branch=b2 //depot@2 && + git p4 sync --branch=b2 && git show -s --format=%s refs/remotes/p4/b1 >show && grep "Initial import" show && git show -s --format=%s refs/remotes/p4/b2 >show && |