File tree Expand file tree Collapse file tree 3 files changed +20
-7
lines changed Expand file tree Collapse file tree 3 files changed +20
-7
lines changed Original file line number Diff line number Diff line change @@ -112,6 +112,11 @@ will be fetched and consulted first during a 'git p4 sync'. Since
112
112
importing directly from p4 is considerably slower than pulling changes
113
113
from a git remote, this can be useful in a multi-developer environment.
114
114
115
+ If there are multiple branches, doing 'git p4 sync' will automatically
116
+ use the "BRANCH DETECTION" algorithm to try to partition new changes
117
+ into the right branch. This can be overridden with the '--branch'
118
+ option to specify just a single branch to update.
119
+
115
120
116
121
Rebase
117
122
~~~~~~
Original file line number Diff line number Diff line change @@ -2804,14 +2804,22 @@ def run(self, args):
2804
2804
2805
2805
# branches holds mapping from branch name to sha1
2806
2806
branches = p4BranchesInGit (self .importIntoRemotes )
2807
- self .p4BranchesInGit = branches .keys ()
2808
- for branch in branches .keys ():
2809
- self .initialParents [self .refPrefix + branch ] = branches [branch ]
2807
+
2808
+ # restrict to just this one, disabling detect-branches
2809
+ if branch_arg_given :
2810
+ short = self .branch .split ("/" )[- 1 ]
2811
+ if short in branches :
2812
+ self .p4BranchesInGit = [ short ]
2813
+ else :
2814
+ self .p4BranchesInGit = branches .keys ()
2810
2815
2811
2816
if len (self .p4BranchesInGit ) > 1 :
2812
2817
if not self .silent :
2813
2818
print "Importing from/into multiple branches"
2814
2819
self .detectBranches = True
2820
+ for branch in branches .keys ():
2821
+ self .initialParents [self .refPrefix + branch ] = \
2822
+ branches [branch ]
2815
2823
2816
2824
if self .verbose :
2817
2825
print "branches: %s" % self .p4BranchesInGit
Original file line number Diff line number Diff line change @@ -88,14 +88,14 @@ test_expect_success 'sync when two branches but no master should noop' '
88
88
)
89
89
'
90
90
91
- test_expect_failure ' sync --branch updates specified branch' '
91
+ test_expect_success ' sync --branch updates specific branch, no detection ' '
92
92
test_when_finished cleanup_git &&
93
93
(
94
94
cd "$git" &&
95
95
git init &&
96
- git p4 sync --branch=refs/remotes/p4/ b1 //depot@2 &&
97
- git p4 sync --branch=refs/remotes/p4/ b2 //depot@2 &&
98
- git p4 sync --branch=refs/remotes/p4/ b2 &&
96
+ git p4 sync --branch=b1 //depot@2 &&
97
+ git p4 sync --branch=b2 //depot@2 &&
98
+ git p4 sync --branch=b2 &&
99
99
git show -s --format=%s refs/remotes/p4/b1 >show &&
100
100
grep "Initial import" show &&
101
101
git show -s --format=%s refs/remotes/p4/b2 >show &&
You can’t perform that action at this time.
0 commit comments