Skip to content

Commit

Permalink
PBGitCommit: Improve isOnSameBranchAs: detection.
Browse files Browse the repository at this point in the history
Now it will not include commits that are ahead of the existing commit.

So, given commits A->B->C, A is in C's branch but C is not in A's.
  • Loading branch information
brotherbard committed Nov 18, 2009
1 parent a12283f commit cfaa720
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion PBGitCommit.m
Expand Up @@ -156,7 +156,13 @@ - (BOOL) isOnSameBranchAs:(PBGitCommit *)other
if ([otherSHA isEqualToString:mySHA])
return YES;

NSString *mergeSHA = [repository outputForArguments:[NSArray arrayWithObjects:@"merge-base", mySHA, otherSHA, nil]];
NSString *commitRange = [NSString stringWithFormat:@"%@..%@", mySHA, otherSHA];
NSString *parentsOutput = [repository outputForArguments:[NSArray arrayWithObjects:@"rev-list", @"--parents", @"-1", commitRange, nil]];
if ([parentsOutput isEqualToString:@""]) {
return NO;
}

NSString *mergeSHA = [repository outputForArguments:[NSArray arrayWithObjects:@"merge-base", mySHA, otherSHA, nil]];
if ([mergeSHA isEqualToString:mySHA] || [mergeSHA isEqualToString:otherSHA])
return YES;

Expand Down

0 comments on commit cfaa720

Please sign in to comment.