Skip to content

Commit e388434

Browse files
committed
When creating a tracking branch pre-fill the branch name in the create branch sheet
1 parent 929f9fc commit e388434

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

PBCreateBranchSheet.m

+10
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@ - (void) beginCreateBranchSheetAtRefish:(id <PBGitRefish>)ref inRepository:(PBGi
5151
[self.errorMessageField setStringValue:@""];
5252
self.shouldCheckoutBranch = [PBGitDefaults shouldCheckoutBranch];
5353

54+
// when creating a local branch tracking a remote branch preset the branch name to the name of the remote branch
55+
if ([self.startRefish refishType] == kGitXRemoteBranchType) {
56+
NSMutableArray *components = [[[self.startRefish shortName] componentsSeparatedByString:@"/"] mutableCopy];
57+
if ([components count] > 1) {
58+
[components removeObjectAtIndex:0];
59+
NSString *branchName = [components componentsJoinedByString:@"/"];
60+
[self.branchNameField setStringValue:branchName];
61+
}
62+
}
63+
5464
[NSApp beginSheet:[self window] modalForWindow:[self.repository.windowController window] modalDelegate:self didEndSelector:nil contextInfo:NULL];
5565
}
5666

0 commit comments

Comments
 (0)