Hi,

recently I've made a local fork and slightly adjusted this great
software for my everyday needs by adding the features of:
* checkout commit (without a ref)
* marking the current (even detached) commit
* and a rudimentary support of the cherry-pick -n.

Today I checked the push/pull experimental branch @ 
http://github.com/brotherbard/gitx
and see that it renders most of my additions unnecessary to publish
upstream. With the one small exception of the current commit
highlighting by setting the internals of the commit circle to the
yellow color ( screenshot: http://twitpic.com/1emhis ). The patch is
based on the 096a176fbd169d7d93ebf71c3ec605bb6cabd366 (Show the full
width of text in the file content text view):

>From 9148d485d2726308c6e9b2445b412145ec1f7991 Mon Sep 17 00:00:00 2001
From: ngu <[email protected]>
Date: Sat, 10 Apr 2010 20:46:17 +0300
Subject: [PATCH] Highlight the current commit with a yellow circle

---
 PBGitRepository.h   |    1 +
 PBGitRepository.m   |    6 +++++-
 PBGitRevisionCell.m |   18 +++++++++++++++++-
 3 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/PBGitRepository.h b/PBGitRepository.h
index 4ef3dac..6be0223 100644
--- a/PBGitRepository.h
+++ b/PBGitRepository.h
@@ -33,6 +33,7 @@ enum branchFilterTypes {
        NSMutableDictionary *refs;

        PBGitRevSpecifier *_headRef; // Caching
+       NSString* _headSha;
 }

 - (void) cloneRepositoryToPath:(NSString *)path bare:(BOOL)isBare;
diff --git a/PBGitRepository.m b/PBGitRepository.m
index efc5600..4b27f46 100644
--- a/PBGitRepository.m
+++ b/PBGitRepository.m
@@ -234,6 +234,7 @@ - (void) addRef: (PBGitRef *) ref fromParameters:
(NSArray *) components
 - (void) reloadRefs
 {
        _headRef = nil;
+       _headSha = nil;

        refs = [NSMutableDictionary dictionary];
        NSMutableArray *oldBranches = [branches mutableCopy];
@@ -292,7 +293,10 @@ - (PBGitRevSpecifier *)headRef

 - (NSString *) headSHA
 {
-       return [self shaForRef:[[self headRef] ref]];
+       if (! _headSha)
+               _headSha = [self shaForRef:[[self headRef] ref]];
+
+       return _headSha;
 }

 - (PBGitCommit *) headCommit
diff --git a/PBGitRevisionCell.m b/PBGitRevisionCell.m
index 0a129f1..688358d 100644
--- a/PBGitRevisionCell.m
+++ b/PBGitRevisionCell.m
@@ -54,6 +54,16 @@ - (void) drawLineFromColumn: (int) from toColumn:
(int) to inRect: (NSRect) r of

 }

+- (BOOL) isCurrentCommit
+{
+       NSString* thisSha = [self.objectValue realSha];
+
+       PBGitRepository* repository = [self.objectValue repository];
+       NSString* currentSha = [repository headSHA];
+
+       return [ currentSha isEqualToString : thisSha ];
+}
+
 - (void) drawCircleInRect: (NSRect) r
 {

@@ -71,7 +81,13 @@ - (void) drawCircleInRect: (NSRect) r
        [path fill];

        NSRect smallOval = { columnOrigin.x - 3, columnOrigin.y +
r.size.height * 0.5 - 3, 6, 6};
-       [[NSColor whiteColor] set];
+
+       if ( [self isCurrentCommit ] ) {
+               [[NSColor yellowColor] set];
+       } else {
+               [[NSColor whiteColor] set];
+       }
+
        path = [NSBezierPath bezierPathWithOvalInRect:smallOval];
        [path fill];
 }
--
1.7.0.2

Disclaimer: I am a complete noob in Objective-C and Cocoa programming,
and definitely not a graphic designer. If the patch is useful I would
be glad to accept any suggestions on how to improve it.

Mykola Gurov.

P.S. Hope, it's ok to submit the patch based on the experimental fork
here.


-- 
To unsubscribe, reply using "remove me" as the subject.

Reply via email to