From 7ef15f9154980adef72af9cf2c69c686d3f70499 Mon Sep 17 00:00:00 2001
From: Pieter de Bie
Date: Thu, 14 May 2009 16:59:36 +0100
Subject: [PATCH] Update diffHighlighter test
---
html/test.html | 3849 +++++++++++++++++++++++++++++++++++++-----------
1 file changed, 3020 insertions(+), 829 deletions(-)
diff --git a/html/test.html b/html/test.html
index 795c686..8d9be6d 100644
--- a/html/test.html
+++ b/html/test.html
@@ -9,14 +9,25 @@
@@ -24,847 +35,3027 @@
+ Download
+
+
+- The newest version of GitX is 0.6.1. This version can be downloaded from here. To see what has changed, read the Release History.
++ The newest version of GitX is <%= ReleaseNotes::last_version %>. This version can be downloaded from here. To see what has changed, read the Release History.
+
+
+ After you have started it once, you can install the command-line tool through the menu (GitX->Enable Terminal Usage…). This will install a “gitx” binary in /usr/local/bin.
+diff --git a/Site/text/release_history.markdown b/Site/text/release_history.markdown
+index 9b95961..1909539 100644
+--- a/Site/text/release_history.markdown
++++ b/Site/text/release_history.markdown
+@@ -3,105 +3,4 @@
+ Release history
+
+
+-### Changes in v0.6.1:
+-
+-This is a bugfix release. The following bugs have been fixed:
+-
+-* The commit view shows new files with linebreaks
+-* The history view works with Git >= 1.5.4 again
+-* Reloading the detailed view in the History no longer causes an empty page
+-
+-### Changes in v0.6
+-
+-This release has the following new features and enhancements:
+-
+-* The diff display now looks much nicer, using boxes to segment files
+-* The toolbar can now me customized
+-* Images that have been changed or added in a commit can now be viewed
+- inline in GitX
+-* GitX has gained a preference pane which allows you to specify a git path
+- and disable the Gist and Gravatar integration
+-* The commit interface is now more intuitive. Particularly, you can now
+- select multiple files and use drag and drop to stage / unstage files
+-* You can now drag and drop files out of the commit view
+-* The files in the commit view have gained a context menu that allows you
+- to revert changes / open the file / ignore the file
+-* It is now possible to adjust the amount of context lines in the commit view.
+- Using a smaller context size allows you to do more fine-grained commits
+-* The branch menu is now organized in branches/remotes/tags
+-* The view switch button now uses icons rather than words
+-* The view shortcuts have changed to use command 1/2 for the history/commit
+- view. The history's subviews can now be changed using command-option-1/2/3
+-* Listing commits has become much faster
+-* GitX no longer spawns zombie processes
+-* GitX now shows a list of files that have been changed in a commit
+-* GitX now uses libgit2 to store object id's, reducing it's memory footprint
+-
+-In addition many bugs were fixed, including the correct calculation of a
+-gravatar MD5 hash.
+-
+-### Changes in v0.5
+-
+-This feature release has several new smaller or larger features:
+-
+-* The current branch is now highlighted
+-* In the commit view, there is an option to amend commits
+-* The "Gist it" button now respects github.user/token
+-* Display a gravatar of the committer
+-* The commit message view now displays a vertical line at 50 characters
+-* It is now possible to revert changes by using the context menu in the
+- commit view
+-* You can now stage only parts of a file by using the "Stage Hunk" buttons
+- in the commit view
+-* You can now use GitX to show a diff of anything, for example by using
+- 'gitx --diff HEAD^^' or 'git diff HEAD~3 | gitx --diff'
+-* You can now drag and drop refs to move them and also create branches
+-
+-In addition, the following bugs have been fixed:
+-
+-* Better detection of git version
+-* Branch lines are no longer interspersed with half a pixel of whitespace
+-* The toolbar keeps its state when switching views
+-
+-
Changes in v0.4.1:
+-
+-- The diff display is now much faster
+- - More locations are now searched for a default git
+- - Code pasted online is now private
+-
+-
+-Changes in v0.4:
+-
+-- A new commitview, allowing you to selectively add changes and commit them.
+- - You can now upload a commit as a patch to gist.github.com
+-
+- - GitX now searches for your git binary in more directories and is smarter
+- about reporting errors regarding git paths.
+- - You can now remove branches by right-clicking on them in the detailed view
+- - GitX now comes with a spicy new icon
+- - The diff view has become prettier and now also highlights trailing
+- whitespace.
+- - Various little changes and stability improvement
+-
+-Changes in v0.3:
+-
+-- You can now pass on command-line arguments just like you can with ‘git log’
+- - The program has an icon
+- - Also displays remote branches in the branch list
+-
+- - Is better in determining if a directory is a bare git repository
+- - Support for—left-right: use ‘gitx—left-right HEAD..origin/master’
+- to see which commits are only on your branch or on their branch
+- - Navigate through changed hunks by using j/k keys
+- - Scroll down in webview by using space / shift-space
+-
+-
+-Changes in v0.2.1:
+-
+-- Added supercool auto-update feature (Sparkle)
+-
+-Changes in v0.2
+-
+-- Branch lines now have colors
+-- Ref labels added to commits
+-
++<%= ReleaseNotes::aggregate_notes %>
+\ No newline at end of file
+diff --git a/gitx.mm b/gitx.mm
+index 65829e0..fbd5411 100644
+--- a/gitx.mm
++++ b/gitx.mm
+@@ -74,6 +74,16 @@ void version_info()
+ exit(1);
+ }
+
++void git_path()
++{
++ if (![PBGitBinary path])
++ exit(101);
++
++ NSString *path = [[PBGitBinary path] stringByDeletingLastPathComponent];
++ printf("%s", [path UTF8String]);
++ exit(0);
++}
++
+ void handleSTDINDiff(id proxy)
+ {
+ NSFileHandle *handle = [NSFileHandle fileHandleWithStandardInput];
+@@ -106,6 +116,8 @@ int main(int argc, const char** argv)
+ usage(argv[0]);
+ if (argc >= 2 && (!strcmp(argv[1], "--version") || !strcmp(argv[1], "-v")))
+ version_info();
++ if (argc >= 2 && !strcmp(argv[1], "--git-path"))
++ git_path();
+
+ if (![PBGitBinary path]) {
+ printf("%s\n", [[PBGitBinary notFoundError] cStringUsingEncoding:NSUTF8StringEncoding]);
+diff --git a/html/lib/diffHighlighter.js b/html/lib/diffHighlighter.js
+index 8f51c5d..1a7663e 100644
+--- a/html/lib/diffHighlighter.js
++++ b/html/lib/diffHighlighter.js
+@@ -67,10 +67,12 @@ var highlightDiff = function(diff, element, callbacks) {
+ return; // so printing the filename in the file-list is enough
+ }
+
+- finalContent += '' +
+- '';
++ if (diffContent != "" || binary) {
++ finalContent += '
' +
++ '';
++ }
+
+- if (!binary) {
++ if (!binary && (diffContent != "")) {
+ finalContent += '
' +
+ '
' + line1 + "
" +
+ '
' + line2 + "
" +
+@@ -86,7 +88,8 @@ var highlightDiff = function(diff, element, callbacks) {
+ }
+ }
+
+- finalContent += '
';
++ if (diffContent != "" || binary)
++ finalContent += '
';
+
+ line1 = "";
+ line2 = "";
+@@ -117,6 +120,29 @@ var highlightDiff = function(diff, element, callbacks) {
+ }
+
+ if (header) {
++ if (firstChar == "n") {
++ if (l.match(/^new file mode .*$/))
++ startname = "/dev/null";
++
++ if (match = l.match(/^new mode (.*)$/)) {
++ mode_change = true;
++ new_mode = match[1];
++ }
++ continue;
++ }
++ if (firstChar == "o") {
++ if (match = l.match(/^old mode (.*)$/)) {
++ mode_change = true;
++ old_mode = match[1];
++ }
++ continue;
++ }
++
++ if (firstChar == "d") {
++ if (l.match(/^deleted file mode .*$/))
++ endname = "/dev/null";
++ continue;
++ }
+ if (firstChar == "-") {
+ if (match = l.match(/^--- (a\/)?(.*)$/))
+ startname = match[2];
+@@ -153,17 +179,6 @@ var highlightDiff = function(diff, element, callbacks) {
+ }
+ }
+
+- if (match = l.match(/^old mode (.*)$/)) {
+- mode_change = true;
+- old_mode = match[1];
+- }
+-
+- if (match = l.match(/^new mode (.*)$/)) {
+- mode_change = true;
+- new_mode = match[1];
+- }
+-
+-
+ // Finish the header
+ if (firstChar == "@")
+ header = false;
+@@ -188,7 +203,7 @@ var highlightDiff = function(diff, element, callbacks) {
+ header = false;
+ }
+
+- if (m = l.match(/@@ \-([0-9]+),\d+ \+(\d+),\d+ @@/))
++ if (m = l.match(/@@ \-([0-9]+),?\d* \+(\d+),?\d* @@/))
+ {
+ hunk_start_line_1 = parseInt(m[1]) - 1;
+ hunk_start_line_2 = parseInt(m[2]) - 1;
+@@ -199,14 +214,14 @@ var highlightDiff = function(diff, element, callbacks) {
+ } else if (firstChar == " ") {
+ line1 += ++hunk_start_line_1 + "\n";
+ line2 += ++hunk_start_line_2 + "\n";
+- diffContent += l + "\n";
++ diffContent += "
" + l + "
";
+ }
+ }
+
+ finishContent();
+
+ // This takes about 7ms
+- element.innerHTML = finalContent;
++ // element.innerHTML = finalContent;
+
+ // TODO: Replace this with a performance pref call
+ if (false)
+diff --git a/html/test.html b/html/test.html
+index 795c686..8919193 100644
+--- a/html/test.html
++++ b/html/test.html
+@@ -13,10 +13,13 @@
+ }
+
+ var doeHet = function() {
++ var start = Date.now();
+ highlightDiff($("orig_diff").value,
+ $("diff"),
+ { "newfile" : newFile }
+ );
++ var end = Date.now();
++ console.debug("Parsing took: " + (end - start) + " ms");
+ }
+
+
+diff --git a/html/views/commit/commit.css b/html/views/commit/commit.css
+index 18d6a2e..268109d 100644
+--- a/html/views/commit/commit.css
++++ b/html/views/commit/commit.css
+@@ -61,7 +61,6 @@ table.diff {
+ }
+
+ .diff a.stagebutton {
+- display: block;
+ width: 40px;
+ padding: 0 2px 0 2px;
+ margin-bottom: 4px;
+@@ -77,7 +76,6 @@ table.diff {
+ text-align: center;
+
+ -webkit-border-radius: 2px;
+- float: left;
+ }
+
+ #multiselect {
+@@ -94,4 +92,4 @@ table.diff {
+ border: 5px solid #EEE;
+ margin: -5px;
+ padding-left: 20px;
+-}
+\ No newline at end of file
++}
+diff --git a/html/views/history/history.css b/html/views/history/history.css
+index 7c1aaf8..ff505aa 100644
+--- a/html/views/history/history.css
++++ b/html/views/history/history.css
+@@ -48,7 +48,7 @@ a.servicebutton{
+ }
+
+ .property_name {
+- width: 50px;
++ width: 6em;
+ color:#7F7F7F;
+ text-align: right;
+ font-weight: bold;
+diff --git a/html/views/history/history.js b/html/views/history/history.js
+index 258310c..ee94436 100644
+--- a/html/views/history/history.js
++++ b/html/views/history/history.js
+@@ -40,11 +40,34 @@ var Commit = function(obj) {
+ }
+
+ this.reloadRefs = function() {
+- this.refs = this.object.refs;
++ this.refs = this.object.refs();
+ }
+
+ };
+
++
++var confirm_gist = function(confirmation_message) {
++ if (!Controller.isFeatureEnabled_("confirmGist")) {
++ gistie();
++ return;
++ }
++
++ // Set optional confirmation_message
++ confirmation_message = confirmation_message || "Yes. Paste this commit.";
++ var deleteMessage = Controller.getConfig_("github.token") ? " " : "You might not be able to delete it after posting.
";
++ var publicMessage = Controller.isFeatureEnabled_("publicGist") ? "
public" : "private";
++ // Insert the verification links into div#notification_message
++ var notification_text = 'This will create a ' + publicMessage + ' paste of your commit to
http://gist.github.com/' +
++ deleteMessage +
++ 'Are you sure you want to continue?
' +
++ '
No. Cancel. | ' +
++ '
' + confirmation_message + '';
++
++ notify(notification_text, 0);
++ // Hide img#spinner, since it?s visible by default
++ $("spinner").style.display = "none";
++}
++
+ var gistie = function() {
+ notify("Uploading code to Gistie..", 0);
+
+@@ -60,9 +83,9 @@ var gistie = function() {
+ if (token && login) {
+ parameters.login = login;
+ parameters.token = token;
+- } else {
+- parameters.private = true;
+ }
++ if (!Controller.isFeatureEnabled_("publicGist"))
++ parameters.private = true;
+
+ var params = [];
+ for (var name in parameters)
+@@ -223,8 +246,22 @@ var enableFeatures = function()
+
+ var loadExtendedCommit = function(commit)
+ {
+- if (commit.author_email)
+- $("authorID").innerHTML = commit.author_name + " <
" + commit.author_email + ">";
++ var formatEmail = function(name, email) {
++ return email ? name + " <
" + email + ">" : name;
++ }
++
++ $("authorID").innerHTML = formatEmail(commit.author_name, commit.author_email);
++
++ if (commit.committer_name != commit.author_name) {
++ $("committerID").parentNode.style.display = "";
++ $("committerID").innerHTML = formatEmail(commit.committer_name, commit.committer_email);
++
++ $("committerDate").parentNode.style.display = "";
++ $("committerDate").innerHTML = commit.committer_date;
++ } else {
++ $("committerID").parentNode.style.display = "none";
++ $("committerDate").parentNode.style.display = "none";
++ }
+
+ $("date").innerHTML = commit.author_date;
+ $("message").innerHTML = commit.message.replace(/\n/g,"
");
+diff --git a/html/views/history/index.html b/html/views/history/index.html
+index c120e01..65117c3 100644
+--- a/html/views/history/index.html
++++ b/html/views/history/index.html
+@@ -14,7 +14,7 @@
+
+
+
+@@ -33,6 +33,14 @@
+
Date: |
+
Pieter de Bie |
+
++
++ | Committer: |
++ Pieter de Bie |
++
++
++ | Commit Date: |
++ Pieter de Bie |
++
+
+ | Subject: |
+ Pieter de Bie |
+@@ -48,7 +56,7 @@
+
+
+
+
+diff --git a/speedtest.m b/speedtest.m
+index 2d96213..18173bb 100644
+--- a/speedtest.m
++++ b/speedtest.m
+@@ -6,18 +6,36 @@
+ // Copyright 2008 Pieter de Bie. All rights reserved.
+ //
+
+-#import "speedtest.h"
+ #import "PBGitRepository.h"
+-#import "PBGitRevList.h"
++#import "PBGitRevSpecifier.h"
++#import "PBGitCommit.h"
++#import "PBGitRevPool.h"
+
+ int main()
+ {
+- PBGitRepository *repo = [[PBGitRepository alloc] initWithURL:[NSURL URLWithString:@"file:///Users/pieter/projects/git"]];
+- PBGitRevList *revList = [[PBGitRevList alloc] initWithRepository:repo];
+- PBGitRevSpecifier *revSpecifier = [[PBGitRevSpecifier alloc] initWithParameters:[NSArray arrayWithObject:@"master"]];
++ PBGitRepository *repo = [[PBGitRepository alloc] initWithURL:[NSURL URLWithString:@"file:///Users/pieter/projects/External/git"]];
++ //PBGitRevList *revList = [[PBGitRevList alloc] initWithRepository:repo];
++ PBGitRevSpecifier *revSpecifier = [[PBGitRevSpecifier alloc] initWithParameters:[NSArray arrayWithObject:@"HEAD"]];
++ PBGitRevPool *revPool = [[PBGitRevPool alloc] initWithRepository:repo];
+
+ //[repo reloadRefs];
+- [revList walkRevisionListWithSpecifier:revSpecifier];
+-
++ [revPool loadRevisions:revSpecifier];
++// [revPool listCommits];
++
++ NSDate *start = [NSDate date];
++ PBGitCommit *commit = [revPool commitWithSha:@"6270bae2fe7b13a0809061760ddb2b03ce2ca33a"];
++ NSMutableArray *array = [NSMutableArray array];
++ while (commit)
++ {
++ [array addObject:[commit realSha]];
++ if (commit.nParents)
++ commit = [revPool commitWithOid:commit.parentShas[0]];
++ else
++ commit = NULL;
++ }
++ NSTimeInterval duration = [[NSDate date] timeIntervalSinceDate:start];
++
++ NSLog(@"Walked all refs in %f seconds", duration);
++ NSLog(@"%@", [array componentsJoinedByString:@"\n"]);
+ return 0;
+ }
+\ No newline at end of file
+