|
|
|
@@ -8,34 +8,719 @@
|
|
|
|
|
<link rel="stylesheet" href="../../lib/syntaxhighlighter_2.1.364/styles/shCore.css" type="text/css" media="screen" title="no title" charset="utf-8">
|
|
|
|
|
<link rel="stylesheet" href="../../lib/syntaxhighlighter_2.1.364/styles/shThemeDefault.css" type="text/css" media="screen" title="no title" charset="utf-8">
|
|
|
|
|
</head>
|
|
|
|
|
<body>
|
|
|
|
|
<body onload="SyntaxHighlighter.highlight();">
|
|
|
|
|
|
|
|
|
|
<table class='blocks'>
|
|
|
|
|
<tr class='block l20'>
|
|
|
|
|
<td><p class='author'>author Pieter de Bie</p><p class='summary'>summary Add a search field and subject</p></td>
|
|
|
|
|
<tr class='block l11'>
|
|
|
|
|
<td><p class='author'>author Pieter de Bie</p><p class='summary'>summary Add a Tree displayer</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<table class='code'>
|
|
|
|
|
<tr><td>1</td><td><pre class='brush: js'> /*</pre></td></tr>
|
|
|
|
|
<tr><td>2</td><td><pre class='brush: js'> * Extension for NSFileHandle to make it capable of easy network programming</pre></td></tr>
|
|
|
|
|
<tr><td>3</td><td><pre class='brush: js'> *</pre></td></tr>
|
|
|
|
|
<tr><td>4</td><td><pre class='brush: js'> * Version 1.0, get the newest from http://michael.stapelberg.de/NSFileHandleExt.php</pre></td></tr>
|
|
|
|
|
<tr><td>5</td><td><pre class='brush: js'> *</pre></td></tr>
|
|
|
|
|
<tr><td>6</td><td><pre class='brush: js'> * Copyright 2007 Michael Stapelberg</pre></td></tr>
|
|
|
|
|
<tr><td>7</td><td><pre class='brush: js'> *</pre></td></tr>
|
|
|
|
|
<tr><td>8</td><td><pre class='brush: js'> * Distributed under BSD-License, see http://michael.stapelberg.de/BSD.php</pre></td></tr>
|
|
|
|
|
<tr><td>9</td><td><pre class='brush: js'> *</pre></td></tr>
|
|
|
|
|
<tr><td>10</td><td><pre class='brush: js'> */</pre></td></tr>
|
|
|
|
|
<tr><td>11</td><td><pre class='brush: js'> </pre></td></tr>
|
|
|
|
|
<tr><td>12</td><td><pre class='brush: js'> #import <Cocoa/Cocoa.h></pre></td></tr>
|
|
|
|
|
<tr><td>13</td><td><pre class='brush: js'> #include <netinet/in.h></pre></td></tr>
|
|
|
|
|
<tr><td>14</td><td><pre class='brush: js'> #include <arpa/inet.h></pre></td></tr>
|
|
|
|
|
<tr><td>15</td><td><pre class='brush: js'> #include <netdb.h></pre></td></tr>
|
|
|
|
|
<tr><td>16</td><td><pre class='brush: js'> #include <fcntl.h></pre></td></tr>
|
|
|
|
|
<tr><td>17</td><td><pre class='brush: js'> </pre></td></tr>
|
|
|
|
|
<tr><td>18</td><td><pre class='brush: js'> @interface NSFileHandle(NSFileHandleExt)</pre></td></tr>
|
|
|
|
|
<tr><td>19</td><td><pre class='brush: js'> -(NSString*)readLine;</pre></td></tr>
|
|
|
|
|
<tr><td>20</td><td><pre class='brush: js'> @end</pre></td></tr>
|
|
|
|
|
</table>
|
|
|
|
|
</td>
|
|
|
|
|
<pre class='first-line: 1;brush: js'> //
|
|
|
|
|
// PBGitTree.m
|
|
|
|
|
// GitTest
|
|
|
|
|
//
|
|
|
|
|
// Created by Pieter de Bie on 15-06-08.
|
|
|
|
|
// Copyright 2008 __MyCompanyName__. All rights reserved.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#import "PBGitTree.h"
|
|
|
|
|
#import "PBGitCommit.h"
|
|
|
|
|
#import "NSFileHandleExt.h"
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
</table> </body>
|
|
|
|
|
<tr class='block l1'>
|
|
|
|
|
<td><p class='author'>author Pieter de Bie</p><p class='summary'>summary Allow double click to open file</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 12;brush: js'> #import "PBEasyPipe.h"
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l1'>
|
|
|
|
|
<td><p class='author'>author Pieter de Bie</p><p class='summary'>summary Delete temporary files when they are deallocated</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 13;brush: js'> #import "PBEasyFS.h"
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l7'>
|
|
|
|
|
<td><p class='author'>author Pieter de Bie</p><p class='summary'>summary Add a Tree displayer</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 14;brush: js'>
|
|
|
|
|
@implementation PBGitTree
|
|
|
|
|
|
|
|
|
|
@synthesize sha, path, repository, leaf, parent;
|
|
|
|
|
|
|
|
|
|
+ (PBGitTree*) rootForCommit:(id) commit
|
|
|
|
|
{
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l4'>
|
|
|
|
|
<td><p class='author'>author Pieter de Bie</p><p class='summary'>summary Add a Tree displayer</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 21;brush: js'> PBGitCommit* c = commit;
|
|
|
|
|
PBGitTree* tree = [[self alloc] init];
|
|
|
|
|
tree.parent = nil;
|
|
|
|
|
tree.leaf = NO;
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l1'>
|
|
|
|
|
<td><p class='author'>author Pieter de Bie</p><p class='summary'>summary Include libgit2 as submodule and use it to store sha's</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 25;brush: js'> tree.sha = [c realSha];
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l18'>
|
|
|
|
|
<td><p class='author'>author Pieter de Bie</p><p class='summary'>summary Add a Tree displayer</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 26;brush: js'> tree.repository = c.repository;
|
|
|
|
|
tree.path = @"";
|
|
|
|
|
return tree;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
+ (PBGitTree*) treeForTree: (PBGitTree*) prev andPath: (NSString*) path;
|
|
|
|
|
{
|
|
|
|
|
PBGitTree* tree = [[self alloc] init];
|
|
|
|
|
tree.parent = prev;
|
|
|
|
|
tree.sha = prev.sha;
|
|
|
|
|
tree.repository = prev.repository;
|
|
|
|
|
tree.path = path;
|
|
|
|
|
return tree;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- init
|
|
|
|
|
{
|
|
|
|
|
children = nil;
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l1'>
|
|
|
|
|
<td><p class='author'>author Pieter de Bie</p><p class='summary'>summary Delete temporary files when they are deallocated</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 44;brush: js'> localFileName = nil;
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l4'>
|
|
|
|
|
<td><p class='author'>author Pieter de Bie</p><p class='summary'>summary Add a Tree displayer</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 45;brush: js'> leaf = YES;
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l5'>
|
|
|
|
|
<td><p class='author'>author Pieter de Bie</p><p class='summary'>summary Use unified interface and display tree contents</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 49;brush: js'> - (NSString*) refSpec
|
|
|
|
|
{
|
|
|
|
|
return [NSString stringWithFormat:@"%@:%@", self.sha, self.fullPath];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l12'>
|
|
|
|
|
<td><p class='author'>author Pieter de Bie</p><p class='summary'>summary Delete temporary files when they are deallocated</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 54;brush: js'> - (BOOL) isLocallyCached
|
|
|
|
|
{
|
|
|
|
|
NSFileManager* fs = [NSFileManager defaultManager];
|
|
|
|
|
if (localFileName && [fs fileExistsAtPath:localFileName])
|
|
|
|
|
{
|
|
|
|
|
NSDate* mtime = [[fs attributesOfItemAtPath:localFileName error: nil] objectForKey:NSFileModificationDate];
|
|
|
|
|
if ([mtime compare:localMtime] == 0)
|
|
|
|
|
return YES;
|
|
|
|
|
}
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l1'>
|
|
|
|
|
<td><p class='author'>author Johannes Gilger</p><p class='summary'>summary PBGitTree: Improve binary-file decision</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 66;brush: js'> - (BOOL)hasBinaryHeader:(NSString*)contents
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l1'>
|
|
|
|
|
<td><p class='author'>author Johannes Gilger</p><p class='summary'>summary PBGitTree: Don't try to print binary-file contents</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 67;brush: js'> {
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l1'>
|
|
|
|
|
<td><p class='author'>author Johannes Gilger</p><p class='summary'>summary PBGitTree: Improve binary-file decision</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 68;brush: js'> if(!contents)
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l2'>
|
|
|
|
|
<td><p class='author'>author Johannes Gilger</p><p class='summary'>summary PBGitTree: Don't try to print binary-file contents</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 69;brush: js'> return NO;
|
|
|
|
|
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l1'>
|
|
|
|
|
<td><p class='author'>author Johannes Gilger</p><p class='summary'>summary PBGitTree: Improve binary-file decision</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 71;brush: js'> return [contents rangeOfString:@"\0" options:0 range:NSMakeRange(0, ([contents length] >= 8000) ? 7999 : [contents length])].location != NSNotFound;
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l28'>
|
|
|
|
|
<td><p class='author'>author Johannes Gilger</p><p class='summary'>summary PBGitTree: Don't try to print binary-file contents</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 72;brush: js'> }
|
|
|
|
|
|
|
|
|
|
- (BOOL)hasBinaryAttributes
|
|
|
|
|
{
|
|
|
|
|
// First ask git check-attr if the file has a binary attribute custom set
|
|
|
|
|
NSFileHandle *handle = [repository handleInWorkDirForArguments:[NSArray arrayWithObjects:@"check-attr", @"binary", [self fullPath], nil]];
|
|
|
|
|
NSData *data = [handle readDataToEndOfFile];
|
|
|
|
|
NSString *string = [[NSString alloc] initWithData:data encoding:NSISOLatin1StringEncoding];
|
|
|
|
|
|
|
|
|
|
if (!string)
|
|
|
|
|
return NO;
|
|
|
|
|
string = [string stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]];
|
|
|
|
|
|
|
|
|
|
if ([string hasSuffix:@"binary: set"])
|
|
|
|
|
return YES;
|
|
|
|
|
|
|
|
|
|
if ([string hasSuffix:@"binary: unset"])
|
|
|
|
|
return NO;
|
|
|
|
|
|
|
|
|
|
// Binary state unknown, do a check on common filename-extensions
|
|
|
|
|
for (NSString *extension in [NSArray arrayWithObjects:@".pdf", @".jpg", @".jpeg", @".png", @".bmp", @".gif", @".o", nil]) {
|
|
|
|
|
if ([[self fullPath] hasSuffix:extension])
|
|
|
|
|
return YES;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l3'>
|
|
|
|
|
<td><p class='author'>author Pieter de Bie</p><p class='summary'>summary Use unified interface and display tree contents</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 100;brush: js'> - (NSString*) contents
|
|
|
|
|
{
|
|
|
|
|
if (!leaf)
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l1'>
|
|
|
|
|
<td><p class='author'>author dbr</p><p class='summary'>summary When selecting a folder in tree-view, display the</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 103;brush: js'> return [NSString stringWithFormat:@"This is a tree with path %@", [self fullPath]];
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l1'>
|
|
|
|
|
<td><p class='author'>author German Laullon</p><p class='summary'>summary initial blame functionality on tree view</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 104;brush: js'>
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l6'>
|
|
|
|
|
<td><p class='author'>author Johannes Gilger</p><p class='summary'>summary PBGitTree: Don't try to print binary-file contents</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 105;brush: js'> if ([self isLocallyCached]) {
|
|
|
|
|
NSData *data = [NSData dataWithContentsOfFile:localFileName];
|
|
|
|
|
NSString *string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
|
|
|
|
|
if (!string)
|
|
|
|
|
string = [[NSString alloc] initWithData:data encoding:NSISOLatin1StringEncoding];
|
|
|
|
|
return string;
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l2'>
|
|
|
|
|
<td><p class='author'>author Pieter de Bie</p><p class='summary'>summary Delete temporary files when they are deallocated</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 111;brush: js'> }
|
|
|
|
|
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l4'>
|
|
|
|
|
<td><p class='author'>author German Laullon</p><p class='summary'>summary initial blame functionality on tree view</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 113;brush: js'> //return [repository outputForArguments:[NSArray arrayWithObjects:@"show", [self refSpec], nil]];
|
|
|
|
|
return [repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"blame", self.path, nil]];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l1'>
|
|
|
|
|
<td><p class='author'>author German Laullon</p><p class='summary'>summary HTML Blame</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 117;brush: js'> // XXX: create img tag for images.
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l2'>
|
|
|
|
|
<td><p class='author'>author German Laullon</p><p class='summary'>summary initial blame functionality on tree view</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 118;brush: js'> - (NSString*) contents:(NSInteger)option
|
|
|
|
|
{
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l2'>
|
|
|
|
|
<td><p class='author'>author German Laullon</p><p class='summary'>summary HTML Blame</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 120;brush: js'> NSString* contents;
|
|
|
|
|
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l3'>
|
|
|
|
|
<td><p class='author'>author German Laullon</p><p class='summary'>summary initial blame functionality on tree view</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 122;brush: js'> if (!leaf)
|
|
|
|
|
return [NSString stringWithFormat:@"This is a tree with path %@", [self fullPath]];
|
|
|
|
|
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l6'>
|
|
|
|
|
<td><p class='author'>author German Laullon</p><p class='summary'>summary HTML Blame</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 125;brush: js'> if ([self hasBinaryAttributes])
|
|
|
|
|
return [NSString stringWithFormat:@"%@ appears to be a binary file of %d bytes", [self fullPath], [self fileSize]];
|
|
|
|
|
|
|
|
|
|
if ([self fileSize] > 52428800) // ~50MB
|
|
|
|
|
return [NSString stringWithFormat:@"%@ is too big to be displayed (%d bytes)", [self fullPath], [self fileSize]];
|
|
|
|
|
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l1'>
|
|
|
|
|
<td><p class='author'>author German Laullon</p><p class='summary'>summary initial blame functionality on tree view</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 131;brush: js'> if(option==0)
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l1'>
|
|
|
|
|
<td><p class='author'>author German Laullon</p><p class='summary'>summary HTML Blame</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 132;brush: js'> contents= [repository outputForArguments:[NSArray arrayWithObjects:@"show", [self refSpec], nil]];
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l1'>
|
|
|
|
|
<td><p class='author'>author German Laullon</p><p class='summary'>summary initial blame functionality on tree view</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 133;brush: js'> else
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l6'>
|
|
|
|
|
<td><p class='author'>author German Laullon</p><p class='summary'>summary HTML Blame</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 134;brush: js'> contents=[PBGitTree parseBlame:[repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"blame", @"-p", self.fullPath, nil]]];
|
|
|
|
|
|
|
|
|
|
if ([self hasBinaryHeader:contents])
|
|
|
|
|
return [NSString stringWithFormat:@"%@ appears to be a binary file of %d bytes", [self fullPath], [self fileSize]];
|
|
|
|
|
|
|
|
|
|
return contents;
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l26'>
|
|
|
|
|
<td><p class='author'>author Johannes Gilger</p><p class='summary'>summary PBGitTree: Don't try to print binary-file contents</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 140;brush: js'> }
|
|
|
|
|
|
|
|
|
|
- (long long)fileSize
|
|
|
|
|
{
|
|
|
|
|
if (_fileSize)
|
|
|
|
|
return _fileSize;
|
|
|
|
|
|
|
|
|
|
NSFileHandle *handle = [repository handleForArguments:[NSArray arrayWithObjects:@"cat-file", @"-s", [self refSpec], nil]];
|
|
|
|
|
NSString *sizeString = [[NSString alloc] initWithData:[handle readDataToEndOfFile] encoding:NSISOLatin1StringEncoding];
|
|
|
|
|
|
|
|
|
|
if (!sizeString)
|
|
|
|
|
_fileSize = -1;
|
|
|
|
|
else
|
|
|
|
|
_fileSize = [sizeString longLongValue];
|
|
|
|
|
|
|
|
|
|
return _fileSize;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSString *)textContents
|
|
|
|
|
{
|
|
|
|
|
if (!leaf)
|
|
|
|
|
return [NSString stringWithFormat:@"This is a tree with path %@", [self fullPath]];
|
|
|
|
|
|
|
|
|
|
if ([self hasBinaryAttributes])
|
|
|
|
|
return [NSString stringWithFormat:@"%@ appears to be a binary file of %d bytes", [self fullPath], [self fileSize]];
|
|
|
|
|
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l2'>
|
|
|
|
|
<td><p class='author'>author Johannes Gilger</p><p class='summary'>summary PBGitTree: Improve binary-file decision</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 166;brush: js'> if ([self fileSize] > 52428800) // ~50MB
|
|
|
|
|
return [NSString stringWithFormat:@"%@ is too big to be displayed (%d bytes)", [self fullPath], [self fileSize]];
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l1'>
|
|
|
|
|
<td><p class='author'>author Johannes Gilger</p><p class='summary'>summary PBGitTree: Don't try to print binary-file contents</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 168;brush: js'>
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l1'>
|
|
|
|
|
<td><p class='author'>author Johannes Gilger</p><p class='summary'>summary PBGitTree: Improve binary-file decision</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 169;brush: js'> NSString* contents = [self contents];
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l1'>
|
|
|
|
|
<td><p class='author'>author Johannes Gilger</p><p class='summary'>summary PBGitTree: Don't try to print binary-file contents</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 170;brush: js'>
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l2'>
|
|
|
|
|
<td><p class='author'>author Johannes Gilger</p><p class='summary'>summary PBGitTree: Improve binary-file decision</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 171;brush: js'> if ([self hasBinaryHeader:contents])
|
|
|
|
|
return [NSString stringWithFormat:@"%@ appears to be a binary file of %d bytes", [self fullPath], [self fileSize]];
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l2'>
|
|
|
|
|
<td><p class='author'>author Johannes Gilger</p><p class='summary'>summary PBGitTree: Don't try to print binary-file contents</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 173;brush: js'>
|
|
|
|
|
return contents;
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l2'>
|
|
|
|
|
<td><p class='author'>author Pieter de Bie</p><p class='summary'>summary Use unified interface and display tree contents</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 175;brush: js'> }
|
|
|
|
|
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l10'>
|
|
|
|
|
<td><p class='author'>author Pieter de Bie</p><p class='summary'>summary Delete temporary files when they are deallocated</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 177;brush: js'> - (void) saveToFolder: (NSString *) dir
|
|
|
|
|
{
|
|
|
|
|
NSString* newName = [dir stringByAppendingPathComponent:path];
|
|
|
|
|
|
|
|
|
|
if (leaf) {
|
|
|
|
|
NSFileHandle* handle = [repository handleForArguments:[NSArray arrayWithObjects:@"show", [self refSpec], nil]];
|
|
|
|
|
NSData* data = [handle readDataToEndOfFile];
|
|
|
|
|
[data writeToFile:newName atomically:YES];
|
|
|
|
|
} else { // Directory
|
|
|
|
|
[[NSFileManager defaultManager] createDirectoryAtPath:newName attributes:nil];
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l1'>
|
|
|
|
|
<td><p class='author'>author Michael Stephens</p><p class='summary'>summary Fix saving tree to folder</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 187;brush: js'> for (PBGitTree* child in [self children])
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l12'>
|
|
|
|
|
<td><p class='author'>author Pieter de Bie</p><p class='summary'>summary Delete temporary files when they are deallocated</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 188;brush: js'> [child saveToFolder: newName];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSString*) tmpDirWithContents
|
|
|
|
|
{
|
|
|
|
|
if (leaf)
|
|
|
|
|
return nil;
|
|
|
|
|
|
|
|
|
|
if (!localFileName)
|
|
|
|
|
localFileName = [PBEasyFS tmpDirWithPrefix: path];
|
|
|
|
|
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l1'>
|
|
|
|
|
<td><p class='author'>author Pieter de Bie</p><p class='summary'>summary Delete temporary files when they are deallocated</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 200;brush: js'> for (PBGitTree* child in [self children]) {
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l8'>
|
|
|
|
|
<td><p class='author'>author Pieter de Bie</p><p class='summary'>summary Delete temporary files when they are deallocated</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 201;brush: js'> [child saveToFolder: localFileName];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return localFileName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l3'>
|
|
|
|
|
<td><p class='author'>author Pieter de Bie</p><p class='summary'>summary Allow double click to open file</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 209;brush: js'> - (NSString*) tmpFileNameForContents
|
|
|
|
|
{
|
|
|
|
|
if (!leaf)
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l6'>
|
|
|
|
|
<td><p class='author'>author Pieter de Bie</p><p class='summary'>summary Delete temporary files when they are deallocated</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 212;brush: js'> return [self tmpDirWithContents];
|
|
|
|
|
|
|
|
|
|
if ([self isLocallyCached])
|
|
|
|
|
return localFileName;
|
|
|
|
|
|
|
|
|
|
if (!localFileName)
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l1'>
|
|
|
|
|
<td><p class='author'>author Ciar‡n Walsh</p><p class='summary'>summary Prevent confusing filenames when quick-looking files.</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 218;brush: js'> localFileName = [[PBEasyFS tmpDirWithPrefix: sha] stringByAppendingPathComponent:path];
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l1'>
|
|
|
|
|
<td><p class='author'>author Pieter de Bie</p><p class='summary'>summary Delete temporary files when they are deallocated</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 219;brush: js'>
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l2'>
|
|
|
|
|
<td><p class='author'>author Pieter de Bie</p><p class='summary'>summary Allow double click to open file</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 220;brush: js'> NSFileHandle* handle = [repository handleForArguments:[NSArray arrayWithObjects:@"show", [self refSpec], nil]];
|
|
|
|
|
NSData* data = [handle readDataToEndOfFile];
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l6'>
|
|
|
|
|
<td><p class='author'>author Pieter de Bie</p><p class='summary'>summary Delete temporary files when they are deallocated</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 222;brush: js'> [data writeToFile:localFileName atomically:YES];
|
|
|
|
|
|
|
|
|
|
NSFileManager* fs = [NSFileManager defaultManager];
|
|
|
|
|
localMtime = [[fs attributesOfItemAtPath:localFileName error: nil] objectForKey:NSFileModificationDate];
|
|
|
|
|
|
|
|
|
|
return localFileName;
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l2'>
|
|
|
|
|
<td><p class='author'>author Pieter de Bie</p><p class='summary'>summary Allow double click to open file</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 228;brush: js'> }
|
|
|
|
|
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l2'>
|
|
|
|
|
<td><p class='author'>author Pieter de Bie</p><p class='summary'>summary Add a Tree displayer</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 230;brush: js'> - (NSArray*) children
|
|
|
|
|
{
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l1'>
|
|
|
|
|
<td><p class='author'>author Pieter de Bie</p><p class='summary'>summary Use unified interface and display tree contents</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 232;brush: js'> if (children != nil)
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l2'>
|
|
|
|
|
<td><p class='author'>author Pieter de Bie</p><p class='summary'>summary Add a Tree displayer</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 233;brush: js'> return children;
|
|
|
|
|
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l1'>
|
|
|
|
|
<td><p class='author'>author Pieter de Bie</p><p class='summary'>summary Use unified interface and display tree contents</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 235;brush: js'> NSString* ref = [self refSpec];
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l9'>
|
|
|
|
|
<td><p class='author'>author Pieter de Bie</p><p class='summary'>summary Add a Tree displayer</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 236;brush: js'>
|
|
|
|
|
NSFileHandle* handle = [repository handleForArguments:[NSArray arrayWithObjects:@"show", ref, nil]];
|
|
|
|
|
[handle readLine];
|
|
|
|
|
[handle readLine];
|
|
|
|
|
|
|
|
|
|
NSMutableArray* c = [NSMutableArray array];
|
|
|
|
|
|
|
|
|
|
NSString* p = [handle readLine];
|
|
|
|
|
while (p.length > 0) {
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l3'>
|
|
|
|
|
<td><p class='author'>author Nathan Kinsinger</p><p class='summary'>summary Bugfix: Avoid looping while parsing the children of a tree</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 245;brush: js'> if ([p isEqualToString:@"\r"])
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l25'>
|
|
|
|
|
<td><p class='author'>author Pieter de Bie</p><p class='summary'>summary Add a Tree displayer</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 248;brush: js'> BOOL isLeaf = ([p characterAtIndex:p.length - 1] != '/');
|
|
|
|
|
if (!isLeaf)
|
|
|
|
|
p = [p substringToIndex:p.length -1];
|
|
|
|
|
|
|
|
|
|
PBGitTree* child = [PBGitTree treeForTree:self andPath:p];
|
|
|
|
|
child.leaf = isLeaf;
|
|
|
|
|
[c addObject: child];
|
|
|
|
|
|
|
|
|
|
p = [handle readLine];
|
|
|
|
|
}
|
|
|
|
|
children = c;
|
|
|
|
|
return c;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSString*) fullPath
|
|
|
|
|
{
|
|
|
|
|
if (!parent)
|
|
|
|
|
return @"";
|
|
|
|
|
|
|
|
|
|
if ([parent.fullPath isEqualToString:@""])
|
|
|
|
|
return self.path;
|
|
|
|
|
|
|
|
|
|
return [parent.fullPath stringByAppendingPathComponent: self.path];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l6'>
|
|
|
|
|
<td><p class='author'>author Pieter de Bie</p><p class='summary'>summary Delete temporary files when they are deallocated</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 273;brush: js'> - (void) finalize
|
|
|
|
|
{
|
|
|
|
|
if (localFileName)
|
|
|
|
|
[[NSFileManager defaultManager] removeFileAtPath:localFileName handler:nil];
|
|
|
|
|
[super finalize];
|
|
|
|
|
}
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l5'>
|
|
|
|
|
<td><p class='author'>author German Laullon</p><p class='summary'>summary HTML Blame</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 279;brush: js'>
|
|
|
|
|
+(NSString *)parseBlame:(NSString *)string
|
|
|
|
|
{
|
|
|
|
|
string=[string stringByReplacingOccurrencesOfString:@"<" withString:@"<"];
|
|
|
|
|
string=[string stringByReplacingOccurrencesOfString:@">" withString:@">"];
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l29'>
|
|
|
|
|
<td><p class='author'>author German Laullon</p><p class='summary'>summary HTML Blame</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 284;brush: js'>
|
|
|
|
|
NSArray *lines = [string componentsSeparatedByString:@"\n"];
|
|
|
|
|
NSString *line;
|
|
|
|
|
NSMutableDictionary *headers=[NSMutableDictionary dictionary];
|
|
|
|
|
NSMutableString *res=[NSMutableString string];
|
|
|
|
|
|
|
|
|
|
[res appendString:@"<table class='blocks'>\n"];
|
|
|
|
|
int i=0;
|
|
|
|
|
while(i<[lines count]){
|
|
|
|
|
line=[lines objectAtIndex:i];
|
|
|
|
|
NSArray *header=[line componentsSeparatedByString:@" "];
|
|
|
|
|
if([header count]==4){
|
|
|
|
|
int nLines=[(NSString *)[header objectAtIndex:3] intValue];
|
|
|
|
|
[res appendFormat:@"<tr class='block l%d'>\n",nLines];
|
|
|
|
|
line=[lines objectAtIndex:++i];
|
|
|
|
|
if([[[line componentsSeparatedByString:@" "] objectAtIndex:0] isEqual:@"author"]){
|
|
|
|
|
NSString *author=line;
|
|
|
|
|
NSString *summary=nil;
|
|
|
|
|
while(summary==nil){
|
|
|
|
|
line=[lines objectAtIndex:i++];
|
|
|
|
|
if([[[line componentsSeparatedByString:@" "] objectAtIndex:0] isEqual:@"summary"]){
|
|
|
|
|
summary=line;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
NSString *block=[NSString stringWithFormat:@"<td><p class='author'>%@</p><p class='summary'>%@</p></td>\n<td>\n",author,summary];
|
|
|
|
|
[headers setObject:block forKey:[header objectAtIndex:0]];
|
|
|
|
|
}
|
|
|
|
|
[res appendString:[headers objectForKey:[header objectAtIndex:0]]];
|
|
|
|
|
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l1'>
|
|
|
|
|
<td><p class='author'>author Not Committed Yet</p><p class='summary'>summary Version of PBGitTree.m from PBGitTree.m</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 313;brush: js'> NSMutableString *code=[NSMutableString string];
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l4'>
|
|
|
|
|
<td><p class='author'>author German Laullon</p><p class='summary'>summary HTML Blame</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 314;brush: js'> do{
|
|
|
|
|
line=[lines objectAtIndex:i++];
|
|
|
|
|
}while([line characterAtIndex:0]!='\t');
|
|
|
|
|
line=[line stringByReplacingOccurrencesOfString:@"\t" withString:@" "];
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l2'>
|
|
|
|
|
<td><p class='author'>author Not Committed Yet</p><p class='summary'>summary Version of PBGitTree.m from PBGitTree.m</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 318;brush: js'> [code appendString:line];
|
|
|
|
|
[code appendString:@"\n"];
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l9'>
|
|
|
|
|
<td><p class='author'>author German Laullon</p><p class='summary'>summary HTML Blame</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 320;brush: js'>
|
|
|
|
|
int n;
|
|
|
|
|
for(n=1;n<nLines;n++){
|
|
|
|
|
line=[lines objectAtIndex:i++];
|
|
|
|
|
NSArray *h=[line componentsSeparatedByString:@" "];
|
|
|
|
|
do{
|
|
|
|
|
line=[lines objectAtIndex:i++];
|
|
|
|
|
}while([line characterAtIndex:0]!='\t');
|
|
|
|
|
line=[line stringByReplacingOccurrencesOfString:@"\t" withString:@" "];
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l2'>
|
|
|
|
|
<td><p class='author'>author Not Committed Yet</p><p class='summary'>summary Version of PBGitTree.m from PBGitTree.m</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 329;brush: js'> [code appendString:line];
|
|
|
|
|
[code appendString:@"\n"];
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l1'>
|
|
|
|
|
<td><p class='author'>author German Laullon</p><p class='summary'>summary HTML Blame</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 331;brush: js'> }
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l2'>
|
|
|
|
|
<td><p class='author'>author Not Committed Yet</p><p class='summary'>summary Version of PBGitTree.m from PBGitTree.m</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 332;brush: js'> [res appendFormat:@"<pre class='first-line: %@;brush: js'>%@</pre>",[header objectAtIndex:2],code];
|
|
|
|
|
[res appendString:@"</td>\n"];
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l6'>
|
|
|
|
|
<td><p class='author'>author German Laullon</p><p class='summary'>summary HTML Blame</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 334;brush: js'> }else{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
[res appendString:@"</tr>\n"];
|
|
|
|
|
}
|
|
|
|
|
[res appendString:@"</table>\n"];
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l1'>
|
|
|
|
|
<td><p class='author'>author Not Committed Yet</p><p class='summary'>summary Version of PBGitTree.m from PBGitTree.m</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 340;brush: js'> NSLog(@"%@",res);
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l3'>
|
|
|
|
|
<td><p class='author'>author German Laullon</p><p class='summary'>summary HTML Blame</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 341;brush: js'>
|
|
|
|
|
return (NSString *)res;
|
|
|
|
|
}
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr class='block l1'>
|
|
|
|
|
<td><p class='author'>author Pieter de Bie</p><p class='summary'>summary Add a Tree displayer</p></td>
|
|
|
|
|
<td>
|
|
|
|
|
<pre class='first-line: 344;brush: js'> @end
|
|
|
|
|
</pre></td>
|
|
|
|
|
</tr>
|
|
|
|
|
</table>
|
|
|
|
|
|
|
|
|
|
</body>
|
|
|
|
|
</html>
|