Skip to content

Commit

Permalink
Merge pull request laullon#85 from Uncommon/stashfix
Browse files Browse the repository at this point in the history
Stash selection fix
  • Loading branch information
laullon committed Jun 27, 2011
2 parents 6cc2e26 + b4557eb commit a569bd6
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion PBGitRepository.m
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,31 @@ - (PBGitCommit *)commitForSHA:(NSString *)sha
if ([[commit sha] isEqual:sha])
return commit;

return nil;
// The commit has not been loaded, but it may exist anyway
NSArray *args = [NSArray arrayWithObjects:
@"show", sha,
@"--pretty=format:"
"%P%n" // parents
"%aN <%aE>%n" // author name
"%cN <%cE>%n" // committer name
"%ct%n" // commit date
"%s", // subject
nil];
int retValue = 1;
NSString *output = [self outputInWorkdirForArguments:args retValue:&retValue];

if ((retValue != 0) || [output hasPrefix:@"fatal:"])
return nil;

NSArray *lines = [output componentsSeparatedByString:@"\n"];
PBGitCommit *commit = [PBGitCommit commitWithRepository:self andSha:sha];

commit.parents = [[lines objectAtIndex:0] componentsSeparatedByString:@" "];
commit.author = [lines objectAtIndex:1];
commit.committer = [lines objectAtIndex:2];
commit.timestamp = [[lines objectAtIndex:3] intValue];
commit.subject = [lines objectAtIndex:4];
return commit;
}

- (BOOL)isOnSameBranch:(NSString *)branchSHA asSHA:(NSString *)testSHA
Expand Down

0 comments on commit a569bd6

Please sign in to comment.