Skip to content

Commit ed2174d

Browse files
committed
Don't show very long diffs by default.
1 parent 3583a9c commit ed2174d

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

PBWebCommitController.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@
1919

2020
NSString* currentSha;
2121
NSString* diff;
22+
BOOL showLongDiffs;
2223
}
2324

2425
- (void) changeContentTo: (PBGitCommit *) content;
2526
- (void) sendKey: (NSString*) key;
2627
- (void) openFileMerge:(NSString*)file sha:(NSString *)sha sha2:(NSString *)sha2;
28+
- (void) showLongDiff;
2729

2830
- (void) didLoad;
2931
// Called when a commit or parent link is clicked.

PBWebCommitController.m

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,14 @@ @implementation PBWebCommitController
3232

3333
@synthesize diff;
3434

35+
- (void) showLongDiff
36+
{
37+
showLongDiffs = TRUE;
38+
}
39+
3540
- (void) awakeFromNib
3641
{
42+
showLongDiffs = FALSE;
3743
startFile = @"history";
3844
[super awakeFromNib];
3945
}
@@ -118,10 +124,16 @@ - (void)commitDetailsLoaded:(NSNotification *)notification
118124
[args addObjectsFromArray:parents];
119125
[args addObject:currentSha];
120126
NSString *d = [repository outputInWorkdirForArguments:args];
121-
NSString *diffs = [GLFileView parseDiff:d];
122-
123-
NSString *html = [NSString stringWithFormat:@"%@%@<div id='diffs'>%@</div>",header,fileList,diffs];
124-
127+
NSString *html;
128+
if(showLongDiffs || [d length] < 200000)
129+
{
130+
showLongDiffs = FALSE;
131+
NSString *diffs = [GLFileView parseDiff:d];
132+
html = [NSString stringWithFormat:@"%@%@<div id='diffs'>%@</div>",header,fileList,diffs];
133+
} else {
134+
html = [NSString stringWithFormat:@"%@%@<div id='diffs'><p>This is a very large commit. It may take a long time to load the diff. Click <a href='' onclick='showFullDiff(); return false;'>here</a> to show anyway.</p></div>",header,fileList,currentSha];
135+
}
136+
125137
html = [html stringByReplacingOccurrencesOfString:@"{SHA_PREV}" withString:[NSString stringWithFormat:@"%@^",currentSha]];
126138
html = [html stringByReplacingOccurrencesOfString:@"{SHA}" withString:currentSha];
127139

html/views/history/history.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@ var showCommit = function(data){
2121
$("commit").innerHTML=data;
2222
}
2323

24+
var showFullDiff = function() {
25+
Controller.showLongDiff();
26+
Controller.updateView();
27+
}

0 commit comments

Comments
 (0)