Since we now have that gorgeous sidebar and commit list with branch filters,
command line arguments to gitx should utilize these to greater effect.
For example, if I pass:
"--local" >> read current branch and set the branch filter to "Local"
"--all" >> same as above but set "All" branch filter
- partial or full SHA-1 >> should get the branch most likely associated with
that SHA, select it in the sidebar and scroll the commit list to the commit
with the passed SHA.
- partial ref like "xyz/master" >> select the master branch
of the "xyz" folder in the sidebar and scroll the commit list to its most
recent commit.
"--subject=Test" >> filter commit list using a predicate on the commit list's
array controller (basically populating the search field programmatically).
For other "--..." CLI switches it's the same, just the filter predicate is a
bit different each time. You get the idea.
To accomplish this we make the following changes:
- gitx sets two environment variables via setenv(), one for a concatenated
version of the CLI args, and one for the indicator that we launched from gitx.
Using setenv() is unfortunate but I couldn't find a way to do it through DO
and PBCLIProxy since that proxy will do it's processing far too late into
the app's event cycle.
- the now shared application controller stores the two env vars in a BOOL
'launchedFromGitx' and an NSString 'cliArgs'.
- Because GitX makes heavy use of KVO and context switching during the app
launch we introduce the notion of a deferred selection so that we can worry
about selecting the branch and commit the user has passed to gitx in some
form or another, when the app has finished launching completely and all
KVO notifications up to this point have been handled.
- ApplicationController does the bulk work. It stores most state
changes, handles most command line switches (except for a few still in gitx.m),
deals with the deferredSelectObject.
- PBGitSidebarController populateList includes logic for fixing up a ref or
a partial SHA when appController.launchedFromGitx is true. If it can be
resolved we set this as the deferred select object so it can be selected
later on.
I'll leave the excess NSLogs in there for this commit so another can see
what went into this before.
Specifying these helps to improve DO performance and it should also help
with the NSURL passed byref thingy (see PBCLIProxy.m), although we don't
really need that anymore because we changed the parameters to be NSString's
which by default are passed bycopy.
Specifying "oneway void" creates a fire-and-forget situation where the
distant object will not wait for the value returned.
in PBGitHistoryController, since this will prevent commit list selection
changes while a deferred selection is undergoing.
A deferred selection is processed when a launch from CLI occurrs with CLI
args containing strings like "<SHA>", or "--subject=<word>", etc.
(see gitx.m).
What happens is that a 0.5s delayed selector will be performed from the
ApplicationController after the CLI args where processed. After this has
happened, launchedFromGitx will be NO and thus KVO can continue as it
normally would.
Add method decl signatures for updateKeys and scrollSelectionToTopOfViewFrom:
- Call preferencesChangedWithNotification: on self when the notification is
received. This gives us the opportunity to refresh the history controller's
commit list in case defaults like the relative dates option have changed.
This makes the effect of switching that option while the prefs panel is still
open instant.
- Change return type from void to BOOL to convey if selecting succeeded
or not.
- Return NO if the cliArgs from sharedApplicationController contain "--commit",
since then we need to just show the commit stage. Updating the commit list
selection is not necessary. In fact, it will confuse order among consequent
calls.
- If the oldIndex equals NSNotFound, try to get the index of the currently
selected object by finding it among the content object of the commitController.
If we find it we save the result in an ivar called selectedCommit so that
subsequent calls will always have this available as an alternative back-up
plan.
- Rearrange some ivar declarations and bunch IBOutlets etc. together for better
visual acuity.
- Add readonly properties for searchField, commitList and webView.
These use BMScript which may be overkill considering we have like a whole load
of PBEasyPipe commands and their wrappers in the repository but I just found for
one or two tasks where I really had to work with a full featured shell script
PBEasyPipe was a bit limited.
- Add a shaExists method that takes string with a SHA and either returns the full
SHA if it exists or nil if not.
- Add a completeRefForString: method which completes partial refs like "xyz/master"
to "refs/remotes/xyz/master" for example.
- Add a checkRefFormatForBranch: method which does the same as checkRefFormat
except it also works with partial branch refs like "xyz/master".
- Add headRefForSHA skeleton to encapsulate the shell-script-fu from populateList
in PBGitSidebarController that deals with getting the head ref for a SHA.
If the current branch filter is switched to "All" or "Local" the index that's
calculated as being the targeted index to scroll to visible, is off by the amount
in Y that the bottom split view separator is off from a multiple of rows.
-adjustScroll: on PBCommitList is called automatically whenever the list needs
laying out.
An ivar keeps track if we come from the -scrollSelectionToTopOfViewFrom: method
of PBGitHistoryController.
I'll leave the commented out NSLogs in there in case they're needed for debugging
again later.
Now, I know conceptually the Remotes segmented control was down there because it is
related to the repository and the current branch, but I really grew tired having to
travel all the way down the monitor real estate just to click a button.
And you can't just fast travel down, you need be quite specific with the click.
Edit install.sh to use gitx_askpasswd so that a password dialog is shown whenever
sudo is used in the install script.
Also split the install logic in install.sh based on BUILD_STYLE so that
installing GitX and gitx (CLI) is possible each on its own.
I was confusing KVO with Notifications earlier, as the GC Programming Guide
explicitly says one should not unregister notifications in a finalize method
when using GC.
To do this we use a modified gitx_askpasswd to ask for sudo permissions during build.
Modifications to gitx_askpasswd include:
- Ability to specify the dialog info text (or title) via STDIN or a GITX_ASKPASSWD_DIALOG_TITLE env variable.
Install.sh uses the env var in 'sudo -A -E' to kindly request the password.
The point of this is to provide a sensible title which lets the user/dev know why he has to enter his password in a dialog that is obviously not from Mac OS X.
Install.sh will now also create the folder hierarchy needed for the install paths set in Install.xcconfig using 'sudo -A -E' if neccessary (if the folders don't exist).