gdiff.git
14 years agoAdd GPL headers to source files master
Wincent Colaiuta [Wed, 14 Nov 2007 16:41:56 +0000 (17:41 +0100)] 
Add GPL headers to source files

In addition to the accompanying LICENSE.txt file previously added.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoCorrect typo in sample README
Wincent Colaiuta [Wed, 14 Nov 2007 16:15:11 +0000 (17:15 +0100)] 
Correct typo in sample README

Was "popular", should have been "populate".

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoAdd LICENSE
Wincent Colaiuta [Wed, 14 Nov 2007 15:29:31 +0000 (16:29 +0100)] 
Add LICENSE

Now that the source is publicly available, make the license (the GPL) text
available as well.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoDefine macro for "/dev/null"
Wincent Colaiuta [Tue, 2 Oct 2007 12:35:52 +0000 (14:35 +0200)] 
Define macro for "/dev/null"

Reduce the likelihood of typing errors by defining a symbolic macro for
"/dev/null", which has special meaning in Git. If this ever changes in Git
the macro can be modified and gdiff should continue to work.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoMake file source list table column uneditable
Wincent Colaiuta [Tue, 2 Oct 2007 11:20:13 +0000 (13:20 +0200)] 
Make file source list table column uneditable

This is for display purposes only, not editing.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoDraw top and bottom borders in file source list
Wincent Colaiuta [Tue, 2 Oct 2007 11:17:58 +0000 (13:17 +0200)] 
Draw top and bottom borders in file source list

This is a preliminary attempt at drawing top and bottom borders in the file
source list. Some visual glitches may be visible near the bottom border if
the window is rapidly resized; the cause of these will need to be
investigated. Also, given that the borders are being drawn just inside the
view it is possible that they could overlap content inside the view; it may
be necessary to find a way to somehow inset the content or instead perform
the drawing elsewhere (the split view itself may be a good candidate for
this as it would localize all top and bottom border drawing to a single
place in the code).

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoFix drawing glitches in source list
Wincent Colaiuta [Tue, 2 Oct 2007 11:08:22 +0000 (13:08 +0200)] 
Fix drawing glitches in source list

The cause of the drawing glitches was a missing super call in the drawRect:
method in the subclass template. Not only are the glitches fixed but the
background color now draws as well.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoUse source list selection highlighting
Wincent Colaiuta [Tue, 2 Oct 2007 11:04:30 +0000 (13:04 +0200)] 
Use source list selection highlighting

Use the new NSTableViewSelectionHighlightStyleSourceList selection
highlighting in the files outline view.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoAdd source list
Wincent Colaiuta [Tue, 2 Oct 2007 10:57:05 +0000 (12:57 +0200)] 
Add source list

Add a source list for showing files included in a patch. This is a
(currently NSOutlineView subclass); note that in swapping out NSOutlineView
for the subclass there are serious drawing glitches of the focus ring. A
fairly typical pattern in AppKit (empty subclass behaves radically different
to superclass) but hopefully won't be too painful to troubleshoot.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoSwitch to NSTextView and prepopulate with test data
Wincent Colaiuta [Mon, 1 Oct 2007 22:53:14 +0000 (00:53 +0200)] 
Switch to NSTextView and prepopulate with test data

Now WOFileView is an NSTextView subclass rather than just a direct NSView
subclass. This required extensive fiddling in order to get the desired
auto-resizing and wrapping behavior. To show that it works the views are
prepopulated with the sample data.

There are still some rough edges and other things to take care of, namely:
the horizontal scroll bars don't appear until the window size is
manipulated, and; text is drawn aliased (would prefer unaliased text in this
case).

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoShow placeholder line number in WOGutterView
Wincent Colaiuta [Mon, 1 Oct 2007 22:45:23 +0000 (00:45 +0200)] 
Show placeholder line number in WOGutterView

Strictly for testing purposes, draw a single line number into the gutter
view column.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoChange scroll view nesting
Wincent Colaiuta [Mon, 1 Oct 2007 22:44:00 +0000 (00:44 +0200)] 
Change scroll view nesting

Instead of putting the gutter views and file views inside a scroll view put
only the file views inside; this change is apparently necessary because
otherwise I can't get the autoresizing behaviour and auto-showing/hiding of
the horizontal scroll bar to work.

I am not sure whether this is a limitation of the Cocoa text system or there
is some kind of magic incantation that would have enabled it to work the
other way, but without access to the source code it seems doubtful that it
would be worth the effort of trying to figure out what's going on in the
bowels of AppKit.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoFix inappropriate 1-pixel inset inside grouping views
Wincent Colaiuta [Mon, 1 Oct 2007 19:20:46 +0000 (21:20 +0200)] 
Fix inappropriate 1-pixel inset inside grouping views

Fix alignment bug introduced along with the addition of upper and lower
borders. Only the outermost subviews need to be inset by one pixel;
additional subviews nested inside the outermost subviews automatically
inherit that base positioning and therefore shouldn't specify an
additional inset.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoTeach WODiffView to draw top and bottom borders
Wincent Colaiuta [Mon, 1 Oct 2007 18:44:08 +0000 (20:44 +0200)] 
Teach WODiffView to draw top and bottom borders

WODiffView now draws 1-pixel-wide light gray borders at the top and bottom
of its bounds.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoTeach glue view to draw borders
Wincent Colaiuta [Mon, 1 Oct 2007 13:58:37 +0000 (15:58 +0200)] 
Teach glue view to draw borders

The WOGlueView class now also draws light gray separator borders (1 pixel
thick) on the left and right.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoAvoid unnecessary re-setting of color
Wincent Colaiuta [Mon, 1 Oct 2007 13:51:56 +0000 (15:51 +0200)] 
Avoid unnecessary re-setting of color

If left border was already drawn, no need to re-set the border color again
before drawing the right border.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoMove WO_BORDER_WIDTH macro into global header
Wincent Colaiuta [Mon, 1 Oct 2007 13:46:27 +0000 (15:46 +0200)] 
Move WO_BORDER_WIDTH macro into global header

Make WO_BORDER_WIDTH macro globally accessible so that it can be used by
both WOGutterView and WOGlueView. Also clarify Doxygen comments about the
unit of measurement used when specifying dimensions.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoConditionalize border drawing
Wincent Colaiuta [Mon, 1 Oct 2007 13:44:01 +0000 (15:44 +0200)] 
Conditionalize border drawing

Only attempt drawing if the border's rectangle intersects with the visible
area.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoDraw borders in gutter views
Wincent Colaiuta [Mon, 1 Oct 2007 13:39:52 +0000 (15:39 +0200)] 
Draw borders in gutter views

Equip WOGutterView with border-drawing code and set up the left gutter view
to draw a border on the right and the right gutter view to draw a border on
the left.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoMove test setup code into windowControllerDidLoadNib
Wincent Colaiuta [Mon, 1 Oct 2007 13:13:29 +0000 (15:13 +0200)] 
Move test setup code into windowControllerDidLoadNib

In order to do some additional set-up for the test code, move it into the
windowControllerDidLoadNib: method (which is called after the nib is already
set up and the WODiffView has been initialized).

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoAdd file property to WODiffView
Wincent Colaiuta [Mon, 1 Oct 2007 13:11:33 +0000 (15:11 +0200)] 
Add file property to WODiffView

Let WODiffView have a reference to its represented file object.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoAdd files property to WODiff
Wincent Colaiuta [Mon, 1 Oct 2007 13:02:53 +0000 (15:02 +0200)] 
Add files property to WODiff

Expose the WODiff object's files array to outside world.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoSplit WOFileView into superclass with two subclasses
Wincent Colaiuta [Mon, 1 Oct 2007 10:22:15 +0000 (12:22 +0200)] 
Split WOFileView into superclass with two subclasses

WOFileView is now a superclass of two new subclasses, WOFromFileView and
WOToFileView. Almost all of the behaviour will be in the superclass with
minor overrides in the subclasses. Basically the only difference in
behaviour is which part of the represented WOFile object the subclass
represents.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoAdd stepper to document window
Wincent Colaiuta [Sun, 30 Sep 2007 23:57:36 +0000 (01:57 +0200)] 
Add stepper to document window

Add placeholder stepper and text to the document window. This will later be
used to step through changes within a file (option-click will allow you to
cross file boundaries if you wish) while showing status text of the form,
"Showing change %d of %d (%s)" (two numbers and a change-type string such as
"insertion", "deletion" or "edit").

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoUse WOParameterCheck
Wincent Colaiuta [Sun, 30 Sep 2007 23:51:35 +0000 (01:51 +0200)] 
Use WOParameterCheck

Add reference WOPublic and swap out instances of NSParameterAssert for
WOParameterCheck where necessary to guarantee fulfilment of the API
contract.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoMove subview initialization into WODiffView
Wincent Colaiuta [Fri, 28 Sep 2007 11:51:24 +0000 (13:51 +0200)] 
Move subview initialization into WODiffView

WODocument is a controller class which previously set up its own document
window and all the subviews. Now all of the subview initialization has been
moved into WODiffView.

This results in a much simpler controller implementation, and there is
better locality now that all subview management is encapsulated in
WODiffView (previously only the autoresizing code was there).

When the controller needs to access the subviews (for example to initiate
scrolling) I will add the appropriate properties or action methods to the
WODiffView class.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoRemove debugging log statement
Wincent Colaiuta [Fri, 28 Sep 2007 11:29:37 +0000 (13:29 +0200)] 
Remove debugging log statement

Fix another mistake in the botched history rewrite (see 4679d86 for more
information); this is a debugging log statement that should have been
removed but which was left in.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoAllow horizontal scrollers when necessary
Wincent Colaiuta [Fri, 28 Sep 2007 11:25:00 +0000 (13:25 +0200)] 
Allow horizontal scrollers when necessary

Although we don't want our scroll views to have vertical scrollers we do
want them to have horizontal ones if the displayed content is too wide.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoRemove setHasVerticalScroller calls
Wincent Colaiuta [Fri, 28 Sep 2007 11:21:06 +0000 (13:21 +0200)] 
Remove setHasVerticalScroller calls

According to the documentation, programmatically created NSScrollViews have
no scrollers, so remove the redundant calls to the setHasVerticalScroller:
method.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoAdd second of two scroll views
Wincent Colaiuta [Fri, 28 Sep 2007 11:18:21 +0000 (13:18 +0200)] 
Add second of two scroll views

Completing the work started in 390c5b3, the right hand side is now also
located inside a scroll view with no vertical scroll bar. The NSScroller
that was previously grouped along with the left file view and its gutter
has now been move outside of the group (it makes no sense to have a
scroller inside the document view of an NSScrollView).

This required some reworking of the WODiffView autoresizing code, and in
the process I discovered that the incorporation of the "slack" in the
glue view (introduced in commit 50b3dbc) was being thrown away during
window resizes; so as part of the updates to the autoresizing code I now
ensure that the slack is accommodated by the glue view during window
resizing as well.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoLet glue view pick up any pixel slack
Wincent Colaiuta [Fri, 28 Sep 2007 10:59:41 +0000 (12:59 +0200)] 
Let glue view pick up any pixel slack

Previously we used the right view to pick up the one-pixel slack caused by
dividing the window in two when there were on odd number of pixels
available. This was slightly ugly because it introduced an arbitrary
difference between the left and right views and therefore incurred a slight
maintenance penalty.

Now we use the glue view for picking up that slack when necessary. Seeing
as there is only one glue view, it is in the center of the window, and its
purpose is to draw curves rather than proportional characters it is the
ideal candidate for this role.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoRemove no-op NSView overrides
Wincent Colaiuta [Fri, 28 Sep 2007 10:48:32 +0000 (12:48 +0200)] 
Remove no-op NSView overrides

The default NSView subclass templates include no-op methods that can be
overridden. Seeing as the WODiffView class is unlikely to ever need to
override these methods, remove them and fall through to the super class
implementations.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoAdd first of two scroll views
Wincent Colaiuta [Fri, 28 Sep 2007 10:44:57 +0000 (12:44 +0200)] 
Add first of two scroll views

Rather than replicate all the work done by NSScrollView (and behind the
scenes NSClipView) I am going to try letting NSScrollView do as much as
possible. This commit starts the migration, placing the content on the
left-hand side inside a programmatically created scrollview.

The previously used NSView that was used for grouping purposes is still
required seeing as an NSScrollView expects a single document view. The
autoresizing machinery works without modification using the scrollview
as a drop-in replacement for the NSView.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoAdd missing header import
Wincent Colaiuta [Fri, 28 Sep 2007 10:39:24 +0000 (12:39 +0200)] 
Add missing header import

Add back in a missing header import. This was actually in there before but I
shot myself in the foot trying to amend the last commit (used git-reset when
I should have used git-checkout; all I wanted to do was exclude a file from
the commit that I really wanted to be in a separate, later commit). In
reconstructing the history I missed out the header import. Rather than
rewrite the history again I'll just chalk this up as a lesson learned and do
this as a separate commit.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoRead in sample files at launch
Wincent Colaiuta [Thu, 27 Sep 2007 22:58:46 +0000 (00:58 +0200)] 
Read in sample files at launch

As proof that commit 6c21acf really works, here we read the sample files in
at launch time upon initializing the document controller. This is temporary
code that will be used for prototyping purposes only.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoSkip preambles before starting diff matching
Wincent Colaiuta [Thu, 27 Sep 2007 22:55:40 +0000 (00:55 +0200)] 
Skip preambles before starting diff matching

In setting up the test sample files I inadvertently included a sample file
generated using "git-show COMMIT_ID", thus producing a commit description
including the commit message and other preamble prior to the diff (in
contrast to the "naked" output that you would get from "git-diff").

This commit modifies the state machine to skip over any such preamble prior
to attempting to recognize the "meat" of the diff. This means that gdiff
will be able to operate not only on the bare diff output of "git-diff" but
also on that of "git-show" and potentially other sources as well (patch
emails are a possibility, for example, although they may require some
pre-processing if they are encoded using a transport encoding).

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoAdd sample files
Wincent Colaiuta [Thu, 27 Sep 2007 22:53:28 +0000 (00:53 +0200)] 
Add sample files

Add some sample files that will be used to scaffold development of the gdiff
view code. These files are expected to be in the ~/tmp directory at runtime.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoReplace nibs with xibs
Wincent Colaiuta [Thu, 27 Sep 2007 19:26:08 +0000 (21:26 +0200)] 
Replace nibs with xibs

Use Interface Builder's new SCM-friendly file format.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoUse new thread APIs
Wincent Colaiuta [Thu, 27 Sep 2007 18:28:56 +0000 (20:28 +0200)] 
Use new thread APIs

Replace use of the NSThread detachNewThreadSelector:toTarget:withObject: API
with the new NSObject performSelectorInBackground:withObject: API. This is a
readability improvement which more clearly expresses the intention behind
the creation of the new thread.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoAdd Doxygen target
Wincent Colaiuta [Thu, 27 Sep 2007 18:04:43 +0000 (20:04 +0200)] 
Add Doxygen target

This commit adds a Doxygen target for producing code-level documentation.
At the moment, the latest Doxygen release (1.5.3) doesn't build on Leopard
although a pre-built binary does run. Doxygen does not yet understand the
property syntax of Objective-C 2.0.

Likewise, the latest version of Graphviz (2.8) (whose "dot" tool is invoked
by Doxygen to depict inheritance hierarchies) doesn't yet build on Leopard,
although I suspect an existing binary would work without problems.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoMake installation window key
Wincent Colaiuta [Thu, 27 Sep 2007 12:47:12 +0000 (14:47 +0200)] 
Make installation window key

When bringing up the installation window don't just order it to the front;
actually make it the key window as well. In this way the user can just hit
the Return or Enter keys to initiate the default install.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoReturn success status from installer tool
Wincent Colaiuta [Thu, 27 Sep 2007 12:44:15 +0000 (14:44 +0200)] 
Return success status from installer tool

The installer tool wasn't indicating success status to the parent, only
failure.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoAdd missing NULL in call to execve
Wincent Colaiuta [Thu, 27 Sep 2007 12:41:42 +0000 (14:41 +0200)] 
Add missing NULL in call to execve

The execve call wasn't working because the envp array was empty rather than
NULL terminated.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoUse waitpid consistently in installer tool and parent application
Wincent Colaiuta [Thu, 27 Sep 2007 12:33:29 +0000 (14:33 +0200)] 
Use waitpid consistently in installer tool and parent application

Make usage of waitpid consistent across the installer tool and the parent
application (where it incorrectly used WNOHANG).

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoYet another early return bug
Wincent Colaiuta [Thu, 27 Sep 2007 12:06:55 +0000 (14:06 +0200)] 
Yet another early return bug

Ensure that the exit status of installer tool is used to determine whether
installation was considered to be successful.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoAdd another missing early return
Wincent Colaiuta [Thu, 27 Sep 2007 12:04:04 +0000 (14:04 +0200)] 
Add another missing early return

During forced failure testing discovered another missing early return; when
the installer tool was failure to communicate its process id back to the
parent the main appliction wasn't aborting.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoFactor out calls to AuthorizationFree
Wincent Colaiuta [Thu, 27 Sep 2007 11:58:42 +0000 (13:58 +0200)] 
Factor out calls to AuthorizationFree

This commit creates a new method that handles the call to AuthorizationFree
and prints a diagnostic message as appropriate. This cleans up some
repetition in the code (AuthorizationFree was previously called in three
places) and enables for cleaner program flow around the call to
AuthorizationExecuteWithPrivileges; specifically, we now handle one error as
a special case (failure to execute the tool), then all other errors (general
authorization failures) and finally the success case.

This commit also fixes a bug wherein the failure cases did not result in the
early termination of the method.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoUse shared support folder for executables
Wincent Colaiuta [Thu, 27 Sep 2007 11:40:04 +0000 (13:40 +0200)] 
Use shared support folder for executables

Using the shared support folder rather than the localizable resources folder
should be more secure as it reduces the number of possible sites in which an
attacker could substitute a hostile binary.

As noted elsewhere in the source, these types of security measures are an
unwinnable battle; basically any application that runs with elevated
privileges should be considered vulnerable of other users have write access
to any part of it. Despite this, a "defense in depth" strategy suggests that
plugging these minor holes is still a worthwhile idea, especially when the
effort of doing so is minimal.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoLocate installer-tool as normal resource
Wincent Colaiuta [Thu, 27 Sep 2007 11:28:50 +0000 (13:28 +0200)] 
Locate installer-tool as normal resource

The pathForAuxiliaryExecutable: method works for Foundation tools
(Objective-C executables linked against the Objective-C runtime) but not for
pure C executables. So must use pathForResource:ofType: to locate the
installer tool instead.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoAdd missing early return when authorization denied
Wincent Colaiuta [Thu, 27 Sep 2007 11:19:11 +0000 (13:19 +0200)] 
Add missing early return when authorization denied

Abort early if authorization is denied.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoAdditional check in current-user installation method
Wincent Colaiuta [Thu, 27 Sep 2007 11:14:51 +0000 (13:14 +0200)] 
Additional check in current-user installation method

Make sure that the gdiff helper tool really is where we expect it to be
inside the main GUI app's bundle.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoCatch exceptions during NSTask launch
Wincent Colaiuta [Thu, 27 Sep 2007 10:56:31 +0000 (12:56 +0200)] 
Catch exceptions during NSTask launch

Although ditto should be present on all Mac OS X systems (it is included in
the base install) NSTask could conceivably throw an exception if the launch
path is not accessible (for example if the user has manually removed ditto);
catch those exceptions.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoBuild installer tool as pure C, nor Objective-C
Wincent Colaiuta [Thu, 27 Sep 2007 10:42:18 +0000 (12:42 +0200)] 
Build installer tool as pure C, nor Objective-C

The installer tool doesn't (and shouldn't) use the Objective-C runtime, so
compile it as pure C rather than Objective-C.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoProvide installation back end
Wincent Colaiuta [Thu, 27 Sep 2007 10:37:38 +0000 (12:37 +0200)] 
Provide installation back end

First draft of installation back end added to main application controller.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoHook up user interface for tool installation
Wincent Colaiuta [Wed, 26 Sep 2007 11:40:06 +0000 (13:40 +0200)] 
Hook up user interface for tool installation

Add a menu item to bring up the installer dialog, set up the bindings and
connections for initiating installation in response to button clicks, show a
progress indicator and disable the buttons when an install is in action.

This is only the user interface; the back end has not yet been put in place.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoAdd installer tool
Wincent Colaiuta [Wed, 26 Sep 2007 10:59:50 +0000 (12:59 +0200)] 
Add installer tool

Due to shortcomings in Apple's AuthorizationExecuteWithPrivileges API
(namely, the fact that it doesn't return the exit code or the process id of
the executed process) it is necessary to interpose an intermediary wrapper
process that explicitly communicates its process id back to the parent
process prior to executing the real installer.

Hideously cumbersome approach but it's the way the Apple sample code does
it.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoAdd window for auto-installation of helper tool
Wincent Colaiuta [Tue, 25 Sep 2007 15:39:55 +0000 (17:39 +0200)] 
Add window for auto-installation of helper tool

Add a prototype version of the installation dialog to the main menu nib.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoCustomize main menu
Wincent Colaiuta [Tue, 25 Sep 2007 15:23:42 +0000 (17:23 +0200)] 
Customize main menu

Replace generic references to the application in the default main menu nib
with its actual name.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoAdd application controller
Wincent Colaiuta [Tue, 25 Sep 2007 15:21:58 +0000 (17:21 +0200)] 
Add application controller

Add a (currently blank) application controller to the main menu nib. This will
later be used to manage any application-wide aspects such as preferences (if
any) and installation of the command-line tool.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoUpdate Info.plist to reflect new document class
Wincent Colaiuta [Tue, 25 Sep 2007 15:14:17 +0000 (17:14 +0200)] 
Update Info.plist to reflect new document class

The refactoring tools provided with Xcode don't actually handle all the places
where renaming a class may require changes to be made. In this case the
Info.plist file's NSDocumentClass key still had a stale value.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoRemove redundant system header imports
Wincent Colaiuta [Tue, 25 Sep 2007 15:11:28 +0000 (17:11 +0200)] 
Remove redundant system header imports

The prefix header already covers the majority of system header imports
throughout the code, so remove those unnecessary imports, saving a few
lines in many different files.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoRestore WODocument class
Wincent Colaiuta [Tue, 25 Sep 2007 15:09:34 +0000 (17:09 +0200)] 
Restore WODocument class

This class is the result of refactoring the original MyDocument class, but due
to an oversight the renamed files weren't added to the repository.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoFix syntax error in tool
Wincent Colaiuta [Tue, 25 Sep 2007 15:08:11 +0000 (17:08 +0200)] 
Fix syntax error in tool

A previous commit included a variable rename, but one instance of the old name
was left behind.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoRefactoring of path utilities for readability
Wincent Colaiuta [Tue, 25 Sep 2007 15:03:40 +0000 (17:03 +0200)] 
Refactoring of path utilities for readability

For better readability, break out two chunks of the path_for_tool function
and place them in dedicated functions of their own:
get_search_path_from_environment and get_search_path_from_sysctl. This
makes the program flow a little more readable and also enables some neater
handling of resource cleanup, seeing as now only one of the function
explicitly mallocs memory.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoFactor out path_for_tool function
Wincent Colaiuta [Tue, 25 Sep 2007 14:45:39 +0000 (16:45 +0200)] 
Factor out path_for_tool function

Move tool-locating code into a separate function where it can be used by both
the command-line tool (to locate git-diff) and the GUI tool (to locate
git-cat-file).

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoTeach tool new ways to get input
Wincent Colaiuta [Tue, 25 Sep 2007 14:25:02 +0000 (16:25 +0200)] 
Teach tool new ways to get input

The tool now has three modes of operation:

(1) When supplied no arguments reads Git diff output from the standard input.
This allows usages such as:

  git-diff ARGUMENTS | gdiff
  cat PATCHFILES... | gdiff

(2) As a special case, when supplied a single argument, "--help", shows usage
information.

(3) In all other cases tries to invoke git-diff, passing along the supplied
arguments and capturing the input. That is:

  gdiff foo bar

Will invoke:

  git-diff foo bar

And capture the output.

The git-diff tool is searched for in the locations defined by the PATH
environment variable, and if no PATH is set the search falls back to the
locations specified by the user.cs_path sysctl setting.

At the moment the tool doesn't actually do anything with the input. A future
commit will add the ability to locate the GUI application and pass the input
to it for processing.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoRefactor: rename MyDocument.nib to Document.nib
Wincent Colaiuta [Tue, 25 Sep 2007 12:34:13 +0000 (14:34 +0200)] 
Refactor: rename MyDocument.nib to Document.nib

Once again, override default name for the document nib, this time losing the
unnecessary "My" prefix.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoRefactor: rename MyDocument to WODocument
Wincent Colaiuta [Tue, 25 Sep 2007 12:32:14 +0000 (14:32 +0200)] 
Refactor: rename MyDocument to WODocument

Replace default NSDocument subclass name with something more specific.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoRoll tool into Xcode project
Wincent Colaiuta [Tue, 25 Sep 2007 12:11:10 +0000 (14:11 +0200)] 
Roll tool into Xcode project

Rather than having a tool subdirectory and a gui subdirectory the top-level
directory now corresponds to a single Xcode project which contains two
targets, one for the GUI and one for the command-line tool.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoSplit Ragel generation into two phases
Wincent Colaiuta [Tue, 25 Sep 2007 11:33:40 +0000 (13:33 +0200)] 
Split Ragel generation into two phases

In an effort to fix the spurious rebuilds mentioned in commit 828150d I split
the Ragel generation into two phases, each with a separate build rule.

The first phase operates on ".rl" files, feeding them into ragel to produce
XML files with a ".ragel" extension.

The second phase takes those ".ragel" files and uses rlgen-cd to produce the
Objective-C source.

The generation of dot files was removed entirely to eliminate a potential
source of complication in the dependency analysis (although it should work
with any number of files).

Although the spurious rebuilds persist (curiously only in Release builds, not
in Debug builds) I am going to keep this commit as I think the two phase
approach is more robust. I can later add in dot-file generation as a separate
target if desired.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoRoll Ragel generation into Xcode build
Wincent Colaiuta [Tue, 25 Sep 2007 11:19:13 +0000 (13:19 +0200)] 
Roll Ragel generation into Xcode build

Migrate the WODiffMachine class to the GUI application build as well using a
custom build rule to generate the Objective-C (.m) file from the Ragel (.rl)
source.

Although this works there appears to be a problem in the Xcode dependency
analysis wherein ragel is run on every single build even when no files have
been changed; this in turn causes the built WODiffMachine Objective-C file
to itself be rebuilt, and the project relinked. Hopefully will be able to
isolate the cause of these unnecessary rebuilds and eliminate them.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoMove model classes from tool into GUI app
Wincent Colaiuta [Tue, 25 Sep 2007 11:02:52 +0000 (13:02 +0200)] 
Move model classes from tool into GUI app

Move WOChange, WODiff and WOFile into the GUI app; the tool will be modified
to merely locate and call the GUI application.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoAdd scroller target methods
Wincent Colaiuta [Tue, 25 Sep 2007 10:57:07 +0000 (12:57 +0200)] 
Add scroller target methods

Add skeletal methods called whenever the user interacts with the scroller. For
the time being doesn't actually do anything, pending the addition of the model
code.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoAdd pragma mark navigation aids to MyDocument
Wincent Colaiuta [Tue, 25 Sep 2007 10:33:00 +0000 (12:33 +0200)] 
Add pragma mark navigation aids to MyDocument

Use pragma mark directives to add headings and separators to groups of
related methods in the MyDocument class.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoReplace prefix header with global header
Wincent Colaiuta [Tue, 25 Sep 2007 10:28:08 +0000 (12:28 +0200)] 
Replace prefix header with global header

Fall back to standard use of <Cocoa/Cocoa.h> as prefix header and create a
separate target-specific global header for target-specific macros.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoSet up default pbxuser settings
Wincent Colaiuta [Tue, 25 Sep 2007 10:20:48 +0000 (12:20 +0200)] 
Set up default pbxuser settings

Add default.pbxuser in the Xcode project bundle.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoPrototype view hierarchy
Wincent Colaiuta [Tue, 25 Sep 2007 10:18:23 +0000 (12:18 +0200)] 
Prototype view hierarchy

Introduce the basic view hierarchy, using the MyDocument class as a controller
which instantiates and configures a WODiffView and its subviews.

WODiffView is a simple container view that implements the auto-resizing logic,
ensuring that when the parent window is resized the subviews are appropriately
adjusted to match.

On the left we have an NSView which is used to group together a WOGutterView
(for displaying line numbers) and a WOFileView (for displaying the contents of
a blob). In the middle we have an WOGlueView which is used to draw shaded
curves which visually link together changes made on one side (the "from" file)
and those made on the other (the "to" file). Finally, on the right we have
another NSView which is used to group together another WOFileView, another
WOGutterView and an NSScroller.

When resizing the window all "columns" should remain fixed in width except for
the two WOFileViews, which should grow and shrink as required to fill all of
the available space. All columns resize vertically to fill all available
space.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoPrepare WOFile class for storing blob contents
Wincent Colaiuta [Tue, 25 Sep 2007 00:39:02 +0000 (02:39 +0200)] 
Prepare WOFile class for storing blob contents

Add properties for holding the contents of the "from" and "to" blobs.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoUpdates for Objective-C 2.0
Wincent Colaiuta [Mon, 24 Sep 2007 23:35:07 +0000 (01:35 +0200)] 
Updates for Objective-C 2.0

Convert classes to use Objective-C 2.0 properties and use shorter-form
initializations that become possible under Garbage Collection.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoUse Wincent Buildtools for configuration
Wincent Colaiuta [Mon, 24 Sep 2007 22:38:41 +0000 (00:38 +0200)] 
Use Wincent Buildtools for configuration

Clean up build settings by using standard configuration files from the Wincent
Buildtools.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoXcode project bundle cleanup
Wincent Colaiuta [Mon, 24 Sep 2007 22:35:37 +0000 (00:35 +0200)] 
Xcode project bundle cleanup

Remove user-specific mode file that shouldn't have been in the repository.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoRename "English.lproj" to "en.lproj"
Wincent Colaiuta [Mon, 24 Sep 2007 22:32:26 +0000 (00:32 +0200)] 
Rename "English.lproj" to "en.lproj"

Rename resources folder to match Apple's recommendations.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoSet up ignores for project bundle
Wincent Colaiuta [Mon, 24 Sep 2007 22:31:34 +0000 (00:31 +0200)] 
Set up ignores for project bundle

Ignore all "*.mode" and "*.pbxuser" files except for "default.pbxuser".

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoInitial import of GUI project
Wincent Colaiuta [Mon, 24 Sep 2007 22:29:37 +0000 (00:29 +0200)] 
Initial import of GUI project

This is just the freshly-created template for the GUI part of gdiff, with
default content as provided by Xcode.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoMove files into "tool" subdirectory
Wincent Colaiuta [Mon, 24 Sep 2007 22:26:08 +0000 (00:26 +0200)] 
Move files into "tool" subdirectory

Move all existing files into a "tool" subdirectory, to keep them isolated from
the development of the GUI front-end (in the "gui" subdirectory).

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoReport parse errors on failure
Wincent Colaiuta [Sun, 23 Sep 2007 21:59:46 +0000 (23:59 +0200)] 
Report parse errors on failure

In addition to returning nil when a parse failure occurs, we now print a
diagnostic message to the console containing line number information.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoReplace atoi() with explicit conversion
Wincent Colaiuta [Sun, 23 Sep 2007 18:58:04 +0000 (20:58 +0200)] 
Replace atoi() with explicit conversion

Ripping out the atoi() calls allows another great simplification to the state
machine: instead of having to maintain multiple pointers to the starting
characters of the desired substrings it is sufficient to have a simple
accumulator variable and use a Ragel "all transitions" action ($) to perform
an incremental ASCII-to-integer conversion.

This not only saves a few lines of code, it should also be faster due to the
saved function calls.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoBe encoding-agnostic with respect to paths
Wincent Colaiuta [Sun, 23 Sep 2007 18:44:31 +0000 (20:44 +0200)] 
Be encoding-agnostic with respect to paths

While thinking about how to handle possible different, platform-dependent text
encodings in path names I realized that the best thing to do would be to be
encoding-agnostic and do what Git goes: display the raw bytes of the path
using escape sequences for non-ASCII and non-printable characters.

gdiff doesn't actually need the paths in order to show the file contents (it
will ask Git for the blobs based on their hash identifiers) so the paths are
for display purposes only. For display the non-ambiguous format using escape
markers is actually much better. This simplifies the code greatly and makes it
much more robust.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoCapture blob ids
Wincent Colaiuta [Sun, 23 Sep 2007 14:04:34 +0000 (16:04 +0200)] 
Capture blob ids

Update the state machine to capture blob ids and store them in the WOFile
objects. This is a simple ASCII capture which requires a pointer to be set on
seeing the start of the desired substring and then actually creating a new
object based on the subtring upon reaching the end.

Note that these are abbreviated SHA-1 hashes, not full numeric hashes, so I
store them as strings rather than numbers. I will later be passing these
strings to other Git tools (such as git-show) so there is no point in using
a numeric representation.

Given that this requires the addition of the ASCII capture machinery I also
use it for capturing unquoted paths, seeing as it is simpler and faster.

At this point I did some experimentation and discovered that quoted paths and
numeric escapes of the form "\ddd" are used whenever a path contains non-ASCII
characters in it. This commit includes some proof-of-concept code for
recognizing and recording these numeric escapes, although as noted in the
comments to make it actually work I'll need to instead capture raw bytes one
by one (most likely into an NSMutableData object) and finally converting the
data to a string in one shot rather than working at the per-character level as
I currently do.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoRecord filenames
Wincent Colaiuta [Fri, 21 Sep 2007 14:38:37 +0000 (16:38 +0200)] 
Record filenames

Updates to WOFile and WODiffMachine to record filenames during scanning. At
this point the WOFile class is basically complete as all it has to do is
track filenames and changes.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoShow usage information when no arguments supplied
Wincent Colaiuta [Fri, 21 Sep 2007 12:27:11 +0000 (14:27 +0200)] 
Show usage information when no arguments supplied

Add stub function for displaying usage information; will need to flesh out
this information as options are added.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoFlesh out model classes
Wincent Colaiuta [Fri, 21 Sep 2007 11:57:50 +0000 (13:57 +0200)] 
Flesh out model classes

Provide basic implementations of the model classes that are used to represent
diffs, and modify the state machine implementation to make use of them. In its
current form gdiff can now produce WODiff objects containing a list of WOFile
objects which themselves contain a list of WOChange objects for the sample
input files (basic diffs); support for special case diffs is still to be
added.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoWhitespace cleanup
Wincent Colaiuta [Fri, 21 Sep 2007 00:07:29 +0000 (02:07 +0200)] 
Whitespace cleanup

Fix unwanted trailing whitespace that crept in with the last commit.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoThin class wrapper for state machine
Wincent Colaiuta [Fri, 21 Sep 2007 00:04:26 +0000 (02:04 +0200)] 
Thin class wrapper for state machine

This commit refactors the previous implementation, splitting it off into a
thin objective wrapper with a separate main executable implementation.
In addition the basic models which the state machine will use to build up a
representation of the diff (diffs, files, changes) have been added.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoAdd Makefile
Wincent Colaiuta [Thu, 20 Sep 2007 21:56:47 +0000 (23:56 +0200)] 
Add Makefile

Simple Makefile for going from a Ragel input file to an executable (.rl to
.xml, .xml to .m or .dot, .m to executable, .dot to .png).

Signed-off-by: Wincent Colaiuta <win@wincent.com>
14 years agoInitial import of diff.rl file
Wincent Colaiuta [Thu, 20 Sep 2007 21:55:06 +0000 (23:55 +0200)] 
Initial import of diff.rl file

This is a skeletal implementation of a Ragel state machine for parsing the
output of "git diff". At this stage it doesn't actually do anything other than
recognize the diff and print logging statements along the way to show what
input it is seeing.

Signed-off-by: Wincent Colaiuta <win@wincent.com>