Grapher: dereference annotated tags

The for-each-ref construct used to return the tag sha for annotated tags.
We're not really interested in that, so also display its referenced object.
This commit is contained in:
Pieter de Bie
2008-08-28 17:46:54 +02:00
parent 9bfccb5ea5
commit ae7d15a247
+14 -6
View File
@@ -141,18 +141,26 @@ static NSString* gitPath;
- (void) readRefs
{
NSString* output = [PBEasyPipe outputForCommand:gitPath withArgs:[NSArray arrayWithObjects:@"for-each-ref", @"refs", nil] inDir: self.fileURL.path];
NSString* output = [PBEasyPipe outputForCommand:gitPath withArgs:[NSArray arrayWithObjects:@"for-each-ref", @"--format=%(refname) %(objecttype) %(objectname) %(*objectname)", @"refs", nil] inDir: self.fileURL.path];
NSArray* lines = [output componentsSeparatedByString:@"\n"];
NSMutableDictionary* newRefs = [NSMutableDictionary dictionary];
NSMutableArray* newBranches = [NSMutableArray array];
for (NSString* line in lines) {
NSString* substr = [line substringWithRange: NSMakeRange(40,19)];
if ([substr isEqualToString:@" commit\trefs/heads/"]) {
NSString* branch = [line substringFromIndex:59];
NSArray* components = [line componentsSeparatedByString:@" "];
NSString* ref = [components objectAtIndex:0];
NSString* type = [components objectAtIndex:1];
NSString* sha;
if ([type isEqualToString:@"tag"] && [components count] == 4)
sha = [components objectAtIndex:3];
else
sha = [components objectAtIndex:2];
if ([[ref substringToIndex:11] isEqualToString:@"refs/heads/"]) {
NSString* branch = [ref substringFromIndex:11];
[newBranches addObject: branch];
}
NSArray* components = [line componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@" \t"]];
[newRefs setObject:[components objectAtIndex:2] forKey:[components objectAtIndex:0]];
[newRefs setObject:ref forKey:sha];
}
self.branches = newBranches;
self.refs = newRefs;