Commit Graph

437 Commits

Author SHA1 Message Date
Shawn O. Pearce
2f7c9a7f31 git-gui: Support native Win32 Tcl/Tk under Cygwin
Cygwin has been stuck on the 8.4.1 version of Tcl/Tk for quite some
time, even though the main Tcl/Tk distribution is already shipping
an 8.4.15.  The problem is Tcl/Tk no longer supports Cygwin so
apparently building the package for Cygwin is now a non-trivial task.

Its actually quite easy to build the native Win32 version of Tcl/Tk
by compiling with the -mno-cygwin flag passed to GCC but this means
we lose all of the "fancy" Cygwin path translations that the Tcl
library was doing for us.  This is particularly an issue when we
are trying to start git-gui through the git wrapper as the git
wrapper is passing off a Cygwin path for $0 and Tcl cannot find
the startup script or the library directory.

We now use `cygpath -m -a` to convert the UNIX style paths to Windows
style paths in our startup script if we are building on Cygwin.
Doing so allows either the Cygwin-ized Tcl/Tk 8.4.1 that comes with
Cygwin or a manually built 8.4.15 that is running the pure Win32
implementation to read our script.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-09-20 23:16:53 -04:00
Shawn O. Pearce
e7deec6c72 Merge branch 'maint'
* maint:
  git-gui: Avoid using bold text in entire gui for some fonts
2007-09-20 13:01:32 -04:00
Simon Sasburg
ae0754ac9a git-gui: Avoid using bold text in entire gui for some fonts
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-09-20 12:59:45 -04:00
Shawn O. Pearce
704396bc2a Merge branch 'maint'
* maint:
  git-gui: Disable native platform text selection in "lists"

Conflicts:

	lib/browser.tcl
2007-09-16 23:15:21 -04:00
Shawn O. Pearce
3849bfba84 git-gui: Disable native platform text selection in "lists"
Sometimes we use a Tk text widget as though it were a listbox.
This happens typically when we want to show an icon to the left
of the text label or just when a text widget is generally a better
choice then the native listbox widget.

In these cases if we want the user to have control over the selection
we implement our own "in_sel" tag that shows the selected region
and we perform our own selection management in the background
via keybindings and mouse bindings.  In such uses we don't want
the user to be able to activate the native platform selection by
dragging their mouse through the text widget.  Doing so creates a
very confusing display and the user is left wondering what it may
mean to have two different types of selection in the same widget.

Tk doesn't allow us to delete the "sel" tag that it uses internally
to manage the native selection but it will allow us to make it
invisible by setting the tag to have the same display properties
as unselected text.  So long as we don't actually use the "sel"
tag for anything in code its effectively invisible.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-09-16 23:12:19 -04:00
Shawn O. Pearce
31bb1d1b2d git-gui: Paper bag fix missing translated strings
The Tcl expression "[append [mc Foo] Bar]" does not return the string
"FooBar" after translation; instead it is setting the variable Foo to
the value Bar, or if Foo is already defined it is appending Bar onto
the end of it.  This is *not* what we wanted to have happen here.

Tcl's join function is actually the correct function but its default
joinStr argument is a single space.  Unfortunately all of our call
sites do not want an extra space added to their string.  So we need
a small wrapper function to make the call to join with an empty
join string.  In C this is (roughly) the job of the strcat function.
Since strcat is not yet used at the global level it is a reasonable
name to use here.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-09-14 01:51:18 -04:00
Michele Ballabio
c8c4854bec git-gui: add some strings to translation
Most of these changes were suggested by Shawn Pearce in an answer
to Johannes Schindelin.

Some strings for the blame module were added too.

[sp: Minor edits in blame module formatting]

Signed-off-by: Michele Ballabio <barra_cuda@katamail.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-09-13 20:43:26 -04:00
Shawn O. Pearce
e7034d66ec git-gui: Make backporting changes from i18n version easier
This is a very trivial hack to define a global mc procedure that
does not actually perform i18n translations on its input strings.
By declaring an mc procedure here in our maint version of git-gui
we can take patches that are intended for the latest development
version of git-gui and easily backport them without needing to
tweak the mc calls first.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-09-13 19:04:14 -04:00
Harri Ilari Tapio Liusvaara
a9813cb51d git-gui: Disambiguate "commit"
Commit is used as both verb and noun. While these happen to be
the same in some languages, they are not the same in all
languages, so disambiguate them using context-sensitive i18n.

Signed-off-by: Harri Ilari Tapio Liusvaara <hliusvaa@cc.hut.fi>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-09-12 16:51:54 -04:00
Shawn O. Pearce
146d73a365 git-gui: Support context-sensitive i18n
Ocassionally, one would want to translate the same string used in
different contexts in diffrent ways. This patch provides a wrapper
for msgcat::mc that trims "@@" and anything coming after it, whether
or not the string actually got translated.

Proposed-by: Harri Ilari Tapio Liusvaara <hliusvaa@cc.hut.fi>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-09-12 16:47:06 -04:00
Shawn O. Pearce
c8dd7f62e8 Merge branch 'maint'
* maint:
  git-gui: Don't delete send on Windows as it doesn't exist
2007-09-11 18:57:26 -04:00
Shawn O. Pearce
63c4024ff0 git-gui: Don't delete send on Windows as it doesn't exist
The Windows port of Tk does not have the send command so we
cannot delete it from our global namespace, but the Mac OS
X and X11 ports do have it.  Switching this delete attempt
into a catch makes send go away, or stay away.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-09-11 18:57:18 -04:00
Shawn O. Pearce
5f51ccd259 Merge branch 'maint'
* maint:
  git-gui: Trim trailing slashes from untracked submodule names
  git-gui: Assume untracked directories are Git submodules
  git-gui: handle "deleted symlink" diff marker
  git-gui: show unstaged symlinks in diff viewer
2007-09-09 21:02:57 -04:00
Shawn O. Pearce
8938410189 git-gui: Trim trailing slashes from untracked submodule names
Oddly enough `git ls-files --others` supplies us the name of an
untracked submodule by including the trailing slash but that
same git version will not accept the name with a trailing slash
through `git update-index --stdin`.  Stripping off that final
slash character before loading it into our file lists allows
git-gui to stage changes to submodules just like any other file.

This change should give git-gui users some basic submodule support,
but it is strictly at the plumbing level as we do not actually know
about calling the git-submodule porcelain that is a recent addition
to git 1.5.3.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-09-09 20:39:47 -04:00
Shawn O. Pearce
b2bd31006f Merge branch 'maint'
* maint:
  git-gui: Avoid use of libdir in Makefile
  git-gui: Disable Tk send in all git-gui sessions
  git-gui: lib/index.tcl: handle files with % in the filename properly
2007-09-09 05:04:43 -04:00
Shawn O. Pearce
cff93397ab git-gui: Disable Tk send in all git-gui sessions
The Tk designers blessed us with the "send" command, which on X11
will allow anyone who can connect to your X server to evaluate any
Tcl code they desire within any running Tk process.  This is just
plain nuts.  If git-gui wants someone running Tcl code within it
then would ask someone to supply that Tcl code to it; waiting for
someone to drop any random Tcl code into us is not fantastic idea.

By renaming send to the empty name the procedure will be removed
from the global namespace and Tk will stop responding to random Tcl
evaluation requests sent through the X server.  Since there is no
facility to filter these requests it is unlikely that we will ever
consider enabling this command.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-09-08 23:47:10 -04:00
Shawn O. Pearce
4b08aa3fef Merge branch 'maint'
* maint:
  git-gui: Properly set the state of "Stage/Unstage Hunk" action
  git-gui: Fix detaching current branch during checkout
  git-gui: Correct starting of git-remote to handle -w option

Conflicts:

	git-gui.sh
2007-09-03 23:07:59 -04:00
Shawn O. Pearce
047d94d505 git-gui: Properly set the state of "Stage/Unstage Hunk" action
Today I found yet another way for the "Stage Hunk" and "Unstage
Hunk" context menu actions to leave the wrong state enabled in
the UI.  The problem this time was that I connected the state
determination to the value of $::current_diff_side (the side the
diff is from).  When the user was last looking at a diff from the
index side and unstages everything the diff panel goes empty, but
the action stayed enabled as we always assumed unstaging was a
valid action.

This change moves the logic for determining when the action is
enabled away from the individual side selection, as they really
are two unrelated concepts.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-09-03 23:03:52 -04:00
Shawn O. Pearce
6e4ba05c7f git-gui: Correct starting of git-remote to handle -w option
Current versions of git-remote apparently are passing the -w option
to Perl as part of the shbang line:

  #!/usr/bin/perl -w

this caused a problem in git-gui and gave the user a Tcl error with
the message: "git-remote not supported: #!/usr/bin/perl -w".

The fix for this is to treat the shbang line as a Tcl list and look
at the first element only for guessing the executable name.  Once
we know the executable name we use the remaining elements (if any
exist) as arguments to the executable, before the script filename.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-09-03 23:01:44 -04:00
Shawn O. Pearce
b86882eda0 git-gui: Correct stock message for 'Invalid font specified in %s'
This particular message is talking about a specific option in the
configuration file named "gui.$name".  This option is not localized
so we cannot localize the "gui." that denotes the section the option
$name is found within.  Currently there are no plans to localize the
configuration options for git-gui, but if that were to change in the
future then it would be necessary to localize not only the "gui."
section prefix but also the $name (fontui and fontdiff).

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-09-03 00:22:19 -04:00
Christian Stimming
1ac17950e9 Mark strings for translation.
The procedure [mc ...] will translate the strings through msgcat.
Strings must be enclosed in quotes, not in braces, because otherwise
xgettext cannot extract them properly, although on the Tcl side both
delimiters would work fine.

[jes: I merged the later patches to that end.]

Signed-off-by: Christian Stimming <stimming@tuhh.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2007-09-02 16:54:48 +01:00
Shawn O. Pearce
d4b0ccd931 git-gui: Initialize Tcl's msgcat library for internationalization
Tcl's msgcat library and corresponding mc procedure can locate a
translated string for any user message, provided that it is first
given a directory where the *.msg files are located containing the
translations.

During installation we will place the translations in lib/msgs/,
so we need to inform msgcat of this location once we determine it
during startup.  Our source code tree however will store all of
the translations within the po/ directory, so we need to special
case this variant.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-09-01 22:22:42 -04:00
Shawn O. Pearce
fc703c209d git-gui: Locate the library directory early during startup
To support a localized version of git-gui we need to locate the
library directory early so we can initialize Tcl's msgcat package
to load translated messages from.  This needs to occur before we
declare our git-version proc so that errors related to locating
git or assessing its version can be reported to the end-user in
their preferred language.  However we have to keep the library
loading until after git-version has been declared, otherwise we
will fail to start git-gui if we are using a fake tclIndex that
was generated by our Makefile.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-09-01 21:58:29 -04:00
Shawn O. Pearce
c80d25dbce git-gui: Correct 'git gui blame' in a subdirectory
David Kastrup pointed out that the following sequence was not
working as we had intended:

  $ cd lib
  $ git gui blame console.tcl
  fatal: cannot stat path lib/console.tcl: No such file or directory

The problem here was we disabled the chdir to the root of the
working tree when we are running with a "bare allowed" feature
such as blame or browser, but we still kept the prefix we found via
`git rev-parse --show-prefix`.  This caused us to try and look for
the file "console.tcl" within the subdirectory but also include
the subdirectory's own path from the root of the working tree.
This is unlikely to succeed, unless the user just happened to have
a "lib/lib/console.tcl" file in the repository, in which case we
would produce the wrong result.

In the case of a bare repository we shouldn't get back a value from
`rev-parse --show-prefix`, so really $_prefix should only be set
to the non-empty string if we are in a working tree and we are in a
subdirectory of that working tree.  If this is true we really want
to always be at the top level of the working tree, as all paths are
accessed as though they were relative to the top of the working tree.
Converting $_prefix to a ../ sequence is a fairly simple approach
to moving up the requisite levels.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-08-24 23:15:50 -04:00
Shawn O. Pearce
9c9f5fa97f git-gui: Do not offer to stage three-way diff hunks into the index
git-apply does not accept a patch that was generated as a three-way
combined diff format such as we see during merge conflicts.  If we
get such a diff in our diff viewer and try to send it to git-apply
it just errors out and the user is left confused wondering why they
cannot stage that hunk.

Instead of feeding a known to be unacceptable hunk to git-apply we
now just disable the stage/unstage context menu option if the hunk
came from a three way diff.  The user may still be confused about
why they cannot work with a combined diff, but at least they are
only confused as to why git-gui is not offering them the action.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-08-23 02:44:13 -04:00
Shawn O. Pearce
9f4119eb76 git-gui: Refactor diff pane popup support for future improvements
The current popup_diff_menu procedure is somewhat messy as it has a
few duplications of the same logic in each of the different legs of
the routine.  We can simplify these by setting a few state variables
in the different legs.

No functional change, just a cleanup to make it easier to implement
future functional changes within this block.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-08-23 02:39:45 -04:00
Shawn O. Pearce
875b7c9368 git-gui: Fix "unoptimized loading" to not cause git-gui to crash
If the tclsh command was not available to us at the time we were
"built" our lib/tclIndex just lists all of our library files and
we source all of them at once during startup, rather than trying
to lazily load only the procedures we need.  This is a problem as
some of our library code now depends upon the git-version proc,
and that proc is not defined until after the library was fully
loaded.

I'm moving the library loading until after we have determined the
version of git we are talking to, as this ensures that the required
git-reversion procedure is defined before any library code can be
loaded.  Since error_popup is defined in the library we instead use
tk_messageBox directly for errors found during the version detection.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-08-22 02:41:00 -04:00
Shawn O. Pearce
ce015c213f git-gui: Paper bag fix "Stage Hunk For Commit" in diff context menu
In a13ee29b97 I totally broke the
"Stage Hunk For Commit" feature by making this menu item always
appear in a disabled state, so it was never invokable.  A "teaser
feature", just sitting there taunting the poor user who has become
used to having it available.

The issue caused by a13ee was I added a test to look at the data
in $file_states, but I didn't do that test correctly as it was
always looking at a procedure local $file_states array, which is
not defined, so the test was always true and we always disabled
the menu entry.

Instead we only want to disable the menu entry if the current file
we are looking at has no file state information (git-gui is just a
very confused little process) or it is an untracked file (and we
cannot stage individual hunks).

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-08-21 02:22:53 -04:00
Shawn O. Pearce
c6951ddb52 git-gui: Fix window manager problems on ion3
cehteh on #git noticed that secondary windows such as console
windows from push/fetch/merge or the blame browser failed on ion
when we tried to open them a second time.

The issue turned out to be the fact that on ion [winfo ismapped .]
returns false if . is not visible right now because it has been
obscured by another window in the same panel.  So we need to keep
track of whether or not the root window has been displayed for this
application, and once it has been we cannot ever assume that ismapped
is going to return true.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-08-20 00:38:13 -04:00
Väinö Järvelä
51b8c5021a git-gui: Added support for OS X right click
OS X sends Button-2 on a "real" right click, such as with a three
button mouse, or by using the two-finger trackpad click.

Signed-off-by: Väinö Järvelä <v@pp.inet.fi>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-08-04 02:47:30 -04:00
Shawn O. Pearce
a13ee29b97 git-gui: Avoid Tcl error in popup menu on diff viewer
If there is no path currently shown in the diff viewer then we
were getting Tcl errors anytime the user right-clicked on the
diff viewer to bring up its popup menu.  The bug here is caused
by trying to get the file_state for the empty string; this path
is never seen so we never have file_state for it.  In such cases
we now disable the Stage Hunk For Commit option.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-08-02 22:55:22 -04:00
Shawn O. Pearce
dac7089263 git-gui: Use more modern looking icons in the tree browser
This is a replacement of all of the icons in our tree browser
window, as the prior icons just looked too 1980s Tk-ish.  The
icons used here are actually from a KDE themed look, so they
might actually be familiar to some users of git-gui.

Aside from using more modern looking icons we now have a special
icon for executable blobs, to make them stand out from the normal
non-executable blobs.  We also denote symlinks now with a different
icon, so they stand out from the other types of objects in the tree.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-29 23:44:52 -04:00
Shawn O. Pearce
37e2199c4c git-gui: Don't offer to stage hunks from untracked files
If the user looks at an untracked file in our diff pane we used
to offer "Stage Hunk For Commit" in the context menu when they
right-clicked in that pane.  The problem is we don't actually
have any diff hunks in untracked files, so there is nothing to
really select for staging.  So we now grey out the menu item,
so the user cannot invoke it and think its broken when it does
not perform any useful action.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-29 23:44:51 -04:00
Shawn O. Pearce
94a4dd9bfd git-gui: Honor core.excludesfile when listing extra files
Recent git versions have a git-status that honors the core.excludesfile
configuration option when it reports on untracked files.  Unfortunately
I missed the introduction of this configuration option in the core
porcelain implementation, so it was not reflected here in git-gui.

Found and reported by Lars Noschinski <lars@public.noschinski.de>.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-29 03:22:27 -04:00
Christian Stimming
360cc106e7 git-gui: Unify wording to say "to stage" instead of "to add"
Also, the warning message when clicking "Reset" is adapted to
the wording "Reset" rather than a confusion "Cancel commit?".

Signed-off-by: Christian Stimming <stimming@tuhh.de>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-29 03:09:07 -04:00
Shawn O. Pearce
1e0a92fdf7 git-gui: Don't kill modified commit message buffer with merge templates
If the user is in the middle of a merge and has already started to
modify their commit message we were losing the user's changes when
they pressed 'Rescan' after resolving issues or making changes in
the working directory.

The problem here was our background timer that saves the commit
message buffer.  It marks the commit message buffer as not being
modified when it writes it out to disk, so during the rescan we
assumed the buffer should be replaced with what we read from the
MERGE_MSG file.  So we now only read these files from .git if we
have a valid backup file.  Since we clear it on commit this will
only have an impact while the user is actively editing the current
commit.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-27 02:30:15 -04:00
Shawn O. Pearce
a8139888f8 git-gui: Refactor current branch menu items to make i18n easier
The i18n team has also identified a rather ugly block of code in
git-gui that is used to make a pair of Repository menu items show
the current branch name.  This code is difficult to convert to use
[mc ...] to lookup the translation, so I'm refactoring it into a
procedure.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-23 01:11:08 -04:00
Shawn O. Pearce
83751fc109 git-gui: Refactor diff popup into a procedure to ease i18n work
The folks working on the i18n version of git-gui have had some
trouble trying to convert these English strings into [mc] calls
due to the double evaluation.  Moving this block into a standard
procedure eliminates the double evaluation, making their work
easier.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-23 00:36:39 -04:00
Shawn O. Pearce
e7d7b1a34e git-gui: Clarify meaning of add tracked menu option
Junio recently pointed out on the mailing list that our "Add Existing"
feature is a lot like `git add -u`, which is generally described as
"(Re)Add Tracked Files".  This came up during discussion of how to
translate "Add Existing" into Japanese, as the individual working on
the translation was not quite sure what the option meant and therefore
had some trouble selecting the best translation.

I'm changing the menu option to "Add Tracked Files To Commit" and the
button to "Add Tracked".  This should help new users to better understand
the actions behind those GUI widgets.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-23 00:12:30 -04:00
Shawn O. Pearce
854ffd3046 git-gui: Completely remove my Tools/Migrate hack
This menu option of Tools/Migrate has been living inside of git-gui
as a local hack to support some coworkers of mine.  It has no value
to anyone outside of my day-job team and never really should have
been in a release version of git-gui.  So I'm pulling it out, so
that nobody else has to deal with this garbage.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-22 03:08:34 -04:00
Shawn O. Pearce
4578c5cb69 git-gui: Automatically backup the user's commit buffer
A few users have been seeing crashes in Tk when using the undo key
binding to undo the last few keystroke events in the commit buffer.
Unfortunately that means the user loses their commit message and
must start over from scratch when the user restarts the process.

git-gui now saves the user's commit message buffer every couple of
seconds to a temporary file under .git (specifically .git/GITGUI_BCK).
At exit time we rename this file to .git/GITGUI_MSG if there is a
message, the file exists, and it is currently synchronized with the
Tk buffer.  Otherwise we do our usual routine of saving the Tk buffer
to .git/GITGUI_MSG and delete .git/GITGUI_BCK, if it exists.

During startup we favor .git/GITGUI_BCK over .git/GITGUI_MSG.  This
way a crash doesn't take out the user's message buffer but instead
will cause the user to lose only a few keystrokes.  Most people do
not type more than 200 WPM, and with 30 possible saves per minute
we are unlikely to lose more than 7 words.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-21 04:57:57 -04:00
Shawn O. Pearce
d36cd96837 git-gui: Avoid unnecessary global statements when possible
Running global takes slightly longer than just accessing the variable
via its package name, especially if the variable is just only once in
the procedure, or isn't even used at all in the procedure.  So this is
a minor cleanup for some of our commonly invoked procedures.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-19 00:43:16 -04:00
Shawn O. Pearce
a870ddc099 git-gui: Bind Ctrl/Cmd-M to merge action
Users who merge often may want to access the merge action quickly,
so we now bind M to the merge action.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-19 00:39:23 -04:00
Shawn O. Pearce
dc5ccdc6ca Don't offer my special Tools/Migrate hack unless in multicommit
Users shouldn't see this menu option if they startup a browser or
blame from the command line, especially if they are doing so on a
bare repository.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-18 23:52:18 -04:00
Shawn O. Pearce
4040971269 git-gui: Clarify the visualize history menu options
Users who are new to Git may not realize that visualizing things in
a repository involves looking at history.  Adding in a small amount
of text to the menu items really helps to understand what the action
might do, before you invoke it.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-18 01:48:41 -04:00
Shawn O. Pearce
8e891facbe git-gui: Allow users to browse any branch, not just the current one
We now allow users to pick which commit they want to browse through
our revision picking mega-widget.  This opens up in a dialog first,
and then opens a tree browser for that selected commit.  It is a very
simple approach and requires minimal code changes.

I also clarified the language a bit in the Repository menu, to show
that these actions will access files.  Just in case a user is not
quite sure what specific action they are looking for, but they know
they want some sort of file thing.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-18 01:39:27 -04:00
Shawn O. Pearce
85d2d59760 git-gui: Allow browser subcommand to start in subdirectory
Like our blame subcommand the browser subcommand now accepts both
a revision and a path, just a revision or just a path.  This way
the user can start the subcommand on any branch, or on any subtree.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-18 00:53:14 -04:00
Shawn O. Pearce
c52c94524b git-gui: Allow blame/browser subcommands on bare repositories
A long time ago Linus Torvalds tried to run git-gui on a bare
repository to look at the blame viewer, but it failed to start
because we required that the user run us only from within a
working directory that had a normal git repository associated
with it.

This change relaxes that requirement so that you can start the
tree browser or the blame viewer against a bare repository. In
the latter case we do require that you provide a revision and a
pathname if we cannot find the pathname in the current working
directory.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-17 23:58:56 -04:00
Shawn O. Pearce
ba7cc6609e git-gui: Move feature option selection before GIT_DIR init
By moving our feature option determination up before we look for GIT_DIR
we can make a decision about whether or not we need a working tree up
front, before we look for GIT_DIR.  A future change could then allow
us to start in a bare Git repository if we only need access to the ODB.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-17 23:23:56 -04:00
Shawn O. Pearce
3972b987d3 git-gui: Delay the GC hint until after we are running
I'm moving the code related to looking to see if we should GC now
into a procedure closer to where it belongs, the database module.
This reduces our script by a few lines for the single commit case
(aka citool).  But really it just is to help organize the code.

We now perform the check after we have been running for at least
1 second.  This way the main window has time to open up and our
dialog (if we open it) will attach to the main window, instead of
floating out in no-mans-land like it did before on Mac OS X.

I had to use a wait of a full second here as a wait of 1 millisecond
made our console install itself into the main window.  Apparently we
had a race condition with the console code where both the console and
the main window thought they were the main window.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-17 23:20:56 -04:00
Shawn O. Pearce
301dfaa9da git-gui: Let the user continue even if we cannot understand git version
Some users may do odd things, like tag their own private version of
Git with an annotated tag such as 'testver', then compile that git
and try to use it with git-gui.  In such a case `git --version` will
give us 'git version testver', which is not a numeric argument that
we can pass off to our version comparsion routine.

We now check that the cleaned up git version is a going to pass the
version comparsion routine without failure.  If it has a non-numeric
component, or lacks at least a minor revision then we ask the user to
confirm they really want to use this version of git within git-gui.
If they do we shall assume it is git 1.5.0 and run with only the code
that will support.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-17 23:09:31 -04:00
Shawn O. Pearce
d164b7548a git-gui: Change our initial GC hint to be an estimate
Instead of running a full git-count-objects to count all of the loose
objects we can get a reasonably close approximation by counting the
number of files in the .git/objects/42 subdirectory. This works out
reasonably well because the SHA-1 hash has a fairly even distribution,
so every .git/objects/?? subdirectory should get a relatively equal
number of files.  If we have at least 8 files in .git/objects/42 than it
is very likely there is about 8 files in every other directory, leaving
us with around 2048 loose objects.

This check is much faster, as we need to only perform a readdir of
a single directory, and we can do it directly from Tcl and avoid the
costly fork+exec.

All of the credit on how clever this is goes to Linus Torvalds; he
suggested using this trick in a post commit hook to repack every so
often.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-17 22:49:44 -04:00
Shawn O. Pearce
6f62b4f782 git-gui: Delay searching for 'nice' until its really asked for
Not every caller of 'git' or 'git_pipe' wants to use nice to lower the
priority of the process its executing.  In many cases we may never use
the nice process to launch git.  So we can avoid searching our $PATH
to locate a suitable nice if we'll never actually use it.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-17 22:31:16 -04:00
Julian Phillips
91464dfb10 git-gui: Handle git versions of the form n.n.n.GIT
The git-gui version check doesn't handle versions of the form
n.n.n.GIT which you can get by installing from an tarball produced by
git-archive.

Without this change you get an error of the form:
'Error in startup script: expected version number but got "1.5.3.GIT"'

Signed-off-by: Julian Phillips <julian@quantumfyre.co.uk>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-17 21:48:57 -04:00
Shawn O. Pearce
6eb420ef61 git-gui: Always disable the Tcl EOF character when reading
On Windows (which includes Cygwin) Tcl defaults to leaving the EOF
character of input file streams set to the ASCII EOF character, but
if that character were to appear in the data stream then Tcl will
close the channel early.  So we have to disable eofchar on Windows.
Since the default is disabled on all platforms except Windows, we
can just disable it everywhere to prevent any sort of read problem.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-17 01:50:10 -04:00
Shawn O. Pearce
ec4fceece4 git-gui: Brown paper bag "dirty git version fix"
My prior change to allow git-gui to run with a version of Git
that was built from a working directory that had uncommitted
changes didn't account for the pattern starting with -, and
that confused Tcl.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-16 18:44:23 -04:00
Shawn O. Pearce
2dfa54c6cb git-gui: Skip -dirty suffix on core git versions
If the user is running a 'dirty' version of git (one compiled in a
working directory with modified files) we want to just assume it
was a committed version, as we really only look at the part that
came from a real annotated tag anyway.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-16 02:39:07 -04:00
Shawn O. Pearce
7eafa2f157 git-gui: Improve the Windows and Mac OS X shortcut creators
We now embed any GIT_* and SSH_* environment variables as well as
the path to the git wrapper executable into the Mac OS X .app file.
This should allow us to restore the environment properly when
we restart.

We also try to use proper Bourne shell single quoting when we can,
as this avoids any sort of problems that might occur due to a path
containing shell metacharacters.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-09 03:38:10 -04:00
Shawn O. Pearce
74c4763c76 git-gui: Teach console widget to use git_read
Now that we are pretty strict about setting up own absolute paths to
any git helper (saving a marginal runtime cost to resolve the tool)
we can do the same in our console widget by making sure all console
execs go through git_read if they are a git subcommand, and if not
make sure they at least try to use the Tcl 2>@1 IO redirection if
possible, as it should be faster than |& cat.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-09 03:07:05 -04:00
Shawn O. Pearce
c136f2b8b9 git-gui: Perform our own magic shbang detection on Windows
If we cannot locate a .exe for a git tool that we want to run than
it may just be a Bourne shell script as these are popular in Git.
In such a case the first line of the file will say "#!/bin/sh" so
a UNIX kernel knows what program to start to parse and run that.
But Windows doesn't support shbang lines, and neither does the Tcl
that comes with Cygwin.

We can pass control off to the git wrapper as that is a real Cygwin
program and can therefore start the Bourne shell script, but that is
at least two fork+exec calls to get the program running.  One to do
the fork+exec of the git wrapper and another to start the Bourne shell
script.  If the program is run multiple times it is rather expensive
as the magic shbang detection won't be cached across executions.

On MinGW/MSYS we don't have the luxury of such magic detection.  The
MSYS team has taught some of this magic to the git wrapper, but again
its slower than it needs to be as the git wrapper must still go and
run the Bourne shell after it is called.

We now attempt to guess the shbang line on Windows by reading the
first line of the file and building our own command line path from
it.  Currently we support Bourne shell (sh), Perl and Python.  That
is the entire set of shbang lines that appear in git.git today.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-09 02:47:33 -04:00
Shawn O. Pearce
70a7595cc0 git-gui: Treat git version as git --version
We know that the version subcommand of git is special.  It does not
currently have an executable link installed into $gitexecdir and we
therefore would never match it with one of our file exists tests.
So we forward any invocations to it directly to the git wrapper, as
it is a builtin within that executable.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-09 02:30:24 -04:00
Shawn O. Pearce
c67298902c git-gui: Assume unfound commands are known by git wrapper
If we cannot locate a command in $gitexecdir on our own then it may
just be because we are supposed to run it by `git $name` rather than
by `git-$name`.  Many commands are now builtins, more are likely to
go in that direction, and we may see the hardlinks in $gitexecdir go
away in future versions of git.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-09 02:13:00 -04:00
Shawn O. Pearce
02efd48f52 git-gui: Correct gitk installation location
The master Makefile in git.git installs gitk into bindir, not
gitexecdir, which means gitk is located as a sibling of the git
wrapper and not as though it were a git helper tool.

We can also avoid some Tcl concat operations by letting eval do
all of the heavy lifting; we have two proper Tcl lists ($cmd and
$revs) that we are joining together and $revs is currently never
an empty list.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-09 02:10:39 -04:00
Shawn O. Pearce
0b81261622 git-gui: Always use absolute path to all git executables
Rather than making the C library search for git every time we want
to execute it we now search for the main git wrapper at startup, do
symlink resolution, and then always use the absolute path that we
found to execute the binary later on.  This should save us some
cycles, especially on stat challenged systems like Cygwin/Win32.

While I was working on this change I also converted all of our
existing pipes ([open "| git ..."]) to use two new pipe wrapper
functions.  These functions take additional options like --nice
and --stderr which instructs Tcl to take special action, like
running the underlying git program through `nice` (if available)
or redirect stderr to stdout for capture in Tcl.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-09 01:17:09 -04:00
Shawn O. Pearce
51530d1722 git-gui: Change the main window progress bar to use status_bar
Now that we have a fancy status bar mega-widget we can reuse that
within our main window.  This opens the door for implementating
future improvements like a progress bar.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-08 22:34:54 -04:00
Shawn O. Pearce
02087abcce git-gui: Unabbreviate commit SHA-1s prior to display
If the end-user feeds us an abbreviated SHA-1 on the command line for
`git gui browser` or `git gui blame` we now unabbreviate the value
through `git rev-parse` so that the title section of the blame or
browser window shows the user the complete SHA-1 as Git determined
it to be.

If the abbreviated value was ambiguous we now complain with the
standard error message(s) as reported by git-rev-parse --verify,
so that the user can understand what might be wrong and correct
their command line.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-08 22:34:51 -04:00
Shawn O. Pearce
d41b43eb4c git-gui: Refactor branch switch to support detached head
This is a major rewrite of the way we perform switching between
branches and the subsequent update of the working directory.  Like
core Git we now use a single code path to perform all changes: our
new checkout_op class.  We also use it for branch creation/update
as it integrates the tracking branch fetch process along with a
very basic merge (fast-forward and reset only currently).

Because some users have literally hundreds of local branches we
use the standard revision picker (with its branch filtering tool)
to select the local branch, rather than keeping all of the local
branches in the Branch menu.  The branch menu listing out all of
the available branches is simply not sane for those types of huge
repositories.

Users can now checkout a detached head by ticking off the option
in the checkout dialog.  This option is off by default for the
obvious reason, but it can be easily enabled for any local branch
by simply checking it.  We also detach the head if any non local
branch was selected, or if a revision expression was entered.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-08 22:34:46 -04:00
Shawn O. Pearce
699d5601f5 git-gui: Refactor our ui_status_value update technique
I'm really starting to dislike global variables.  The ui_status_value
global varible is just one of those that seems to appear in a lot of
code and in many cases we didn't even declare it "global" within the
proc that updates it so we haven't always been getting all of the
updates we expected to see.

This change introduces two new global procs:

  ui_status $msg;   # Sets the status bar to show $msg.
  ui_ready;         # Changes the status bar to show "Ready."

The second (special) form is used because we often update the area
with this message once we are done processing a block of work and
want the user to know we have completed it.

I'm not fixing the cases that appear in lib/branch.tcl right now
as I'm actually in the middle of a huge refactoring of that code
to support making a detached HEAD checkout.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-08 21:12:57 -04:00
Shawn O. Pearce
311e02a4a5 git-gui: Better handling of detached HEAD
If the current branch is not a symbolic-ref that points to a
name in the refs/heads/ namespace we now just assume that the
head is a detached head.  In this case we return the special
branch name of HEAD rather than empty string, as HEAD is a
valid revision specification and the empty string is not.

I have also slightly improved the current-branch function by
using string functions to parse the symbolic-ref data.  This
should be slightly faster than using a regsub.  I think the
code is clearer too.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-08 21:12:56 -04:00
Shawn O. Pearce
7cf0442667 git-gui: Option to default new branches to match tracking branches
In some workflows users will want to almost always just create a new
local branch that matches a remote branch.  In this type of workflow
it is handy to have the new branch dialog default to "Match Tracking
Branch" and "Starting Revision"-Tracking Branch", with the focus in
the branch filter field.  This can save users working on this type
of workflow at least two mouse clicks every time they create a new
local branch or switch to one with a fast-forward.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-08 21:12:54 -04:00
Shawn O. Pearce
3206c63d0a git-gui: Refactor the delete branch dialog to use class system
A simple refactoring of the delete branch dialog to allow use of
the class construct to better organize the code and to reuse the
revision selection code of our new choose_rev mega-widget.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-08 21:12:47 -04:00
Shawn O. Pearce
b1fa2bfff3 git-gui: Abstract the revision picker into a mega widget
This rather large change pulls the "Starting Revision" part of the
new branch dialog into a mega widget that we can use anytime we
need to select a commit SHA-1.  To make use of the mega widget I
have also refactored the branch dialog to use the class system,
much like the delete remote branch dialog already does.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-08 21:12:46 -04:00
Shawn O. Pearce
d696702209 git-gui: New Git version check support routine
Some newer features of git-gui want to rely on features that are
new to Git 1.5.3.  Since they were added as part of the 1.5.3
development series we cannot use those features with versions of
Git that are older than 1.5.3, such as from the stable 1.5.2 series.

We introduce [git-version >= 1.5.3] to allow the caller to get a
response of 0 if the current version of git is < 1.5.3 and 1 if
the current version of git is >= 1.5.3.  This makes it easy to
setup conditional code based upon the version of Git available to
us at runtime.

Instead of parsing the version text by hand we now use the Tcl
[package vcompare] subcommand to compare the two version strings.
This works nicely, as Tcl as already done all of the hard work
of doing version comparsions.  But we do have to remove the Git
specific components such as the Git commit SHA-1, commit count and
release candidate suffix (rc) as we want only the final release
version number.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-08 19:18:01 -04:00
Shawn O. Pearce
f8186e92e3 Merge branch 'maint'
* maint:
  git-gui: Ensure windows shortcuts always have .bat extension
  git-gui: Include a Push action on the left toolbar
  git-gui: Bind M1-P to push action
  git-gui: Don't bind F5/M1-R in all windows

Conflicts:

	git-gui.sh
2007-07-06 04:03:24 -04:00
Shawn O. Pearce
87b49a533b git-gui: Include a Push action on the left toolbar
Pushing changes to a remote system is a very common action for
many users of git-gui, so much so that in some workflows a user
is supposed to push immediately after they make a local commit
so that their change(s) are immediately available for their
teammates to view and build on top of.

Including the push button right below the commit button on the
left toolbar indicates that users should probably perform this
action after they have performed the commit action.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-06 04:02:02 -04:00
Shawn O. Pearce
840bcfa7b5 git-gui: Bind M1-P to push action
Users often need to be able to push the current branch so that they
can publish their recent changes to anyone they are collaborating
with on the project.  Associating a keyboard action with this will
make it easier for keyboard-oriented users to quickly activate the
push features.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-06 04:01:31 -04:00
Shawn O. Pearce
f1e031bbeb git-gui: Don't bind F5/M1-R in all windows
We actually only want our F5/M1-R keystroke bound in the main window.
Within a browser/blame/console window pressing these keys should not
execute the rescan action.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-07-06 03:59:34 -04:00
Shawn O. Pearce
f10c1c7743 Merge branch 'maint'
* maint:
  git-gui: properly popup error if gitk should be started but is not installed
2007-07-03 10:42:43 -04:00
Gerrit Pape
7aecb12877 git-gui: properly popup error if gitk should be started but is not installed
On 'Visualize ...', a gitk process is started.  Since it is run in the
background, catching a possible startup error doesn't work, and the error
output goes to the console git-gui is started from.  The most probable
startup error is that gitk is not installed; so before trying to start,
check for the existence of the gitk program, and popup an error message
unless it's found.

This was noticed and reported by Paul Wise through
 http://bugs.debian.org/429810

Signed-off-by: Gerrit Pape <pape@smarden.org>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-06-30 00:43:20 -04:00
Shawn O. Pearce
03d25622a5 Merge branch 'maint'
* maint:
  git-gui: Don't require a .pvcsrc to create Tools/Migrate menu hack
  git-gui: Don't nice git blame on MSYS as nice is not supported
  git-gui: Don't require $DISPLAY just to get --version
2007-06-27 00:36:38 -04:00
Shawn O. Pearce
7e508eb1a2 git-gui: Don't require a .pvcsrc to create Tools/Migrate menu hack
The Tools/Migrate menu option is a hack just for me.  Yes, that's
right, git-gui has a hidden feature that really only works for me,
and the users that I support within my day-job's great firewall.
The menu option is not supported outside of that environment.

In the past we only enabled Tools/Migrate if our special local
script 'gui-miga' existed in the proper location, and if there
was a special '.pvcsrc' in the top level of the working directory.
This latter test for the '.pvcsrc' file is now failing, as the file
was removed from all Git repositories due to changes made to other
tooling within the great firewall's realm.

I have changed the test to only work on Cygwin, and only if the
special 'gui-miga' is present.  This works around the configuration
changes made recently within the great firewall's realm, but really
this entire Tools/Migrate thing should be abstracted out into some
sort of plugin system so other users can extend git-gui as they need.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-06-27 00:35:30 -04:00
Shawn O. Pearce
4e817d1ac4 git-gui: Don't require $DISPLAY just to get --version
Junio asked that we don't force the user to have a valid X11 server
configured in $DISPLAY just to obtain the output of `git gui version`.
This makes sense, the user may be an automated tool that is running
without an X server available to it, such as a build script or other
sort of package management system.  Or it might just be a user working
in a non-GUI environment and wondering "what version of git-gui do I
have installed?".

Tcl has a lot of warts, but one of its better ones is that a comment
can be continued to the next line by escaping the LF that would have
ended the comment using a backslash-LF sequence.  In the past we have
used this trick to escape away the 'exec wish' that is actually a Bourne
shell script and keep Tcl from executing it.

I'm using that feature here to comment out the Bourne shell script and
hide it from the Tcl engine.  Except now our Bourne shell script is a
few lines long and checks to see if it should print the version, or not.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-06-22 01:10:12 -04:00
Shawn O. Pearce
03e1bed4a4 Merge branch 'maint'
* maint:
  git-gui: Save geometry before the window layout is damaged
  git-gui: Give amend precedence to HEAD over MERGE_MSG
2007-06-11 23:58:11 -04:00
Shawn O. Pearce
39fa2a983d git-gui: Save geometry before the window layout is damaged
Because Tk does not assure us the order that it will process
children in before it destroys the main toplevel we cannot safely
save our geometry data during a "bind . <Destroy>" event binding.
The geometry may have already changed as a result of a one or
more children being removed from the layout.  This was pointed
out in gitk by Mark Levedahl, and patched over there by commit
b6047c5a81.

So we now also use "wm protocol . WM_DELETE_WINDOW" to detect when
the window is closed by the user, and forward that close event to
our main do_quit routine.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-06-11 23:52:43 -04:00
Shawn O. Pearce
b2f3bb1b66 git-gui: Give amend precedence to HEAD over MERGE_MSG
Apparently git-commit.sh (the command line commit user interface in
core Git) always gives precedence to the prior commit's message if
`commit --amend` is used and a $GIT_DIR/MERGE_MSG file also exists.

We actually were doing the same here in git-gui, but the amended
message got lost if $GIT_DIR/MERGE_MSG already existed because
we started a rescan immediately after loading the prior commit's
body into the edit buffer.  When that happened the rescan found
MERGE_MSG existed and replaced the commit message buffer with the
contents of that file.  This meant the user never saw us pick up
the commit message of the prior commit we are about to replace.

Johannes Sixt <J.Sixt@eudaptics.com> found this bug in git-gui by
running `git cherry-pick -n $someid` and then trying to amend the
prior commit in git-gui, thus combining the contents of $someid
with the contents of HEAD, and reusing the commit message of HEAD,
not $someid.  With the recent changes to make cherry-pick use the
$GIT_DIR/MERGE_MSG file Johannes saw git-gui pick up the message
of $someid, not HEAD.  Now we always use HEAD if we are amending.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-06-11 19:48:41 -04:00
Shawn O. Pearce
32af629ab5 Merge branch 'maint'
* maint: (38 commits)
  git-gui: Changed blame header bar background to match main window
  git-gui: Favor the original annotations over the recent ones
  git-gui: Improve our labeling of blame annotation types
  git-gui: Use three colors for the blame viewer background
  git-gui: Jump to original line in blame viewer
  git-gui: Display both commits in our tooltips
  git-gui: Run blame twice on the same file and display both outputs
  git-gui: Display the "Loading annotation..." message in italic
  git-gui: Rename fields in blame viewer to better descriptions
  git-gui: Label the uncommitted blame history entry
  git-gui: Switch internal blame structure to Tcl lists
  git-gui: Cleanup redundant column management in blame viewer
  git-gui: Better document our blame variables
  git-gui: Remove unused commit_list from blame viewer
  git-gui: Automatically expand the line number column as needed
  git-gui: Make the line number column slightly wider in blame
  git-gui: Use lighter colors in blame view
  git-gui: Remove unnecessary space between columns in blame viewer
  git-gui: Remove the loaded column from the blame viewer
  git-gui: Clip the commit summaries in the blame history menu
  ...
2007-06-11 02:14:21 -04:00
Shawn O. Pearce
debcd0fd02 git-gui: Display the "Loading annotation..." message in italic
If the user clicks on a line region that we haven't yet received
an annotation for from git-blame we show them "Loading annotation".
But I don't want the user to confuse this loading message with a
commit whose first line is "Loading annotation" and think we messed
up our display somehow.  Since we never use italics for anything
else, I'm going with the idea that italic slant can be used to show
data is missing/elided out at the time being.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-06-06 01:26:51 -04:00
Shawn O. Pearce
19ed9a7e74 Merge branch 'maint'
* maint:
  New selection indication and softer colors
2007-06-06 01:22:47 -04:00
Matthijs Melchior
9adccb057e New selection indication and softer colors
The default font was already bold, so marking the selected file with bold
font did not work.  Change that to lightgray background.
Also, the header colors are now softer, giving better readability.

Signed-off-by: Matthijs Melchior <mmelchior@xs4all.nl>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-06-06 01:14:12 -04:00
Shawn O. Pearce
22faa032ca Merge branch 'maint'
* maint:
  Revert "Make the installation target of git-gui a little less chatty"
  git-gui: Verify Tcl/Tk is new enough for our needs
  git-gui: Attach font_ui to all spinbox widgets
2007-06-02 21:05:13 -04:00
Shawn O. Pearce
cfb07cca7d git-gui: Verify Tcl/Tk is new enough for our needs
For quite a while we have been assuming the user is running on
a Tcl/Tk 8.4 or later platform.  This may not be the case on
some very old systems.  Unfortunately I am pretty far down the
path of using the Tcl/Tk 8.4 commands and options and cannot
easily work around them to support earlier versions of Tcl/Tk.
So we'll check that we are using the correct version up front,
and if not we'll stop with a related error message.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-06-02 20:00:55 -04:00
Shawn O. Pearce
6309172ea5 git-gui: Attach font_ui to all spinbox widgets
Earlier I missed making sure our spinbox widgets used the same font
as the other widgets around them.  This meant that using a main font
with a size of 20 would make every widget in the options dialog huge,
but the spinboxes would be left with whatever the OS native font is.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-06-02 19:56:27 -04:00
Shawn O. Pearce
f7e1d2d4ac Merge branch 'maint'
* maint:
  git-gui: Don't quit when we destroy a child widget
  Make the installation target of git-gui a little less chatty
2007-06-01 23:28:15 -04:00
Shawn O. Pearce
160e82284e git-gui: Don't quit when we destroy a child widget
Its wrong to exit the application if we destroy a random widget
contained withing something else; especially if its some small
trivial thing that has no impact on the overall operation.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-06-01 23:12:56 -04:00
Shawn O. Pearce
fc4e8da727 git-gui: Internalize symbolic-ref HEAD reading logic
To improve performance on fork+exec impoverished systems (such as
Windows) we want to avoid running git-symbolic-ref on every rescan
if we can do so.  A quick way to implement such an avoidance is to
just read the HEAD ref ourselves; we'll either see it as a symref
(starts with "ref: ") or we'll see it as a detached head (40 hex
digits).  In either case we can treat that as our current branch.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-05-31 23:37:34 -04:00
Shawn O. Pearce
71a9db534a Merge branch 'maint'
* maint:
  git-gui: Allow as few as 0 lines of diff context
2007-05-31 23:34:24 -04:00
Shawn O. Pearce
b8848f7753 git-gui: Allow as few as 0 lines of diff context
Johannes Sixt pointed out that dropping to 0 lines of context
does allow the user to get more fine-grained hunk selection,
especially since we don't currently support "highlight and
apply (or revert)".

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-05-31 23:32:54 -04:00
Shawn O. Pearce
fc8ce406fa git-gui: Expose the merge.diffstat configuration option
Recently git-merge learned to avoid generating the diffstat after
a merge by reading the merge.diffstat configuration option.  By
default this option is assumed to be true, as that is the old
behavior.  However we can force it to false by setting it as a
standard boolean option.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-05-28 17:58:07 -04:00
Shawn O. Pearce
aa252f194b git-gui: Allow users to delete remote branches
Git has supported remote branch deletion for quite some time, but
I've just never gotten around to supporting it in git-gui.  Some
workflows have users push short-term branches to some remote Git
repository, then delete them a few days/weeks later when that topic
has been fully merged into the main trunk.  Typically in that style
of workflow the user will want to remove the branches they created.

We now offer a "Delete..." option in the Push menu, right below the
generic "Push..." option.  When the user opens our generic delete
dialog they can select a preconfigured remote, or enter a random
URL.  We run `git ls-remote $url` to obtain the list of branches and
tags known there, and offer this list in a listbox for the user to
select one or more from.

Like our local branch delete dialog we offer the user a way to filter
their selected branch list down to only those branches that have been
merged into another branch.  This is a very common operation as the
user will likely want to select a range of topic branches, but only
delete them if they have been merged into some sort of common trunk.

Unfortunately our remote merge base detection is not nearly as strict
as the local branch version.  We only offer remote heads as the test
commit (not any local ones) and we require that all necessary commits
to successfully run git-merge-base are available locally.  If one or
more is missing we suggest that the user run a fetch first.

Since the Git remote protocol doesn't let us specify what the tested
commit was when we evaluated our decision to execute the remote delete
there is a race condition here.  The user could do a merge test against
the trunk, determine a topic branch was fully merged, but before they
can start pushing the delete request another user could fast-forward
the remote topic branch to a new commit that is not merged into the
trunk.  The delete will arrive after, and remove the topic, even though
it was not fully merged.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-05-28 17:50:42 -04:00
Shawn O. Pearce
61f82ce79a git-gui: Allow users to rename branches through 'branch -m'
Git's native command line interface has had branch renaming
support for quite a while, through the -m/-M options to the
git-branch command line tool.  This is an extremely useful
feature as users may decide that the name of their current
branch is not an adequate description, or was just entered
incorrectly when it was created.

Even though most people would consider git-branch to be a
Porcelain tool I'm using it here in git-gui as it is the
only code that implements the rather complex set of logic
needed to successfully rename a branch in Git.  Currently
that is along the lines of:

 *) Backup the ref
 *) Backup the reflog
 *) Delete the old ref
 *) Create the new ref
 *) Move the backed up reflog to the new ref
 *) Record the rename event in the reflog
 *) If the current branch was renamed, update HEAD
 *) If HEAD changed, record the rename event in the HEAD reflog
 *) Rename the [branch "$name"] section in the config file

Since that is some rather ugly set of functionality to implement
and get right, and some of it isn't easily accessible through the
raw plumbing layer I'm just cheating by relying on the Porcelain.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-05-28 17:50:42 -04:00
Shawn O. Pearce
f60fdd0eaa git-gui: Disable tearoff menus on Windows, Mac OS X
The Windows and Mac OS X platforms do not generally use the tearoff
menu feature found on traditional X11 based systems.  On Windows the
Tk engine does support the feature, but it really is out of place and
just confuses people who aren't used to working on a UNIX system.  On
Mac OS X its not supported for the root menu bar and its submenus, as
it doesn't fit into the overall platform UI model.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-05-28 17:50:41 -04:00
Shawn O. Pearce
f837170663 git-gui: Provide fatal error if library is unavailable
If we cannot locate our git-gui library directory, or we find it
but the tclIndex file is not present there (or it is present but
is not something we are allowed to read) the user cannot use the
application.  Rather than silently ignoring the errors related to
the tclIndex file being unavailable we report them up front and
display to the user why we cannot start.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-05-28 17:50:41 -04:00
Shawn O. Pearce
cd12901b8f git-gui: Enable verbose Tcl loading earlier
When we are using our "non-optimized" tclIndex format (which is
just a list of filenames, in the order necessary for source'ing)
we are doing all of our loading before we even tested to see if
GITGUI_VERBOSE was set in the environment.  This meant we never
showed the files as we sourced them into the environment.

Now we setup our overloaded auto_load and source scripts before
we attempt to define our library path, or source the scripts that
it mentions.  This way GITGUI_VERBOSE is always honored if set.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-05-28 17:50:41 -04:00
Shawn O. Pearce
26ae37d6fc git-gui: Show the git-gui library path in 'About git-gui'
Because we now try to automatically guess the library directory
in certain installations users may wonder where git-gui is getting
its supporting files from.  We now display this location in our
About dialog, and we also include the location we are getting our
Git executables from.

Unfortunately users cannot use this 'About git-gui' dialog to
troubleshoot library loading problems; the dialog is defined by
code that exists in the library directory, creating a catch-22.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-05-28 17:50:41 -04:00
Shawn O. Pearce
5b6ffff644 git-gui: GUI support for running 'git remote prune <name>'
In some workflows it is common for a large number of temporary
branches to be created in a remote repository, get fetched to
clients that typically only use git-gui, and then later have
those branches deleted from the remote repository once they have
been fully merged into all destination branches.  Users of git-gui
would obviously like to have their local tracking branches cleaned
up for them, otherwise their local tracking branch namespace would
grow out of control.

The best known way to remove these tracking branches is to run
"git remote prune <remotename>".  Even though it is more of a
Porcelain command than plumbing I'm invoking it through the UI,
because frankly I don't see a reason to reimplement its ls-remote
output filtering and config file parsing.

A new configuration option (gui.pruneduringfetch) can be used to
automatically enable running "git remote prune <remotename>" after
the fetch of that remote also completes successfully.  This is off
by default as it require an additional network connection and is
not very fast on Cygwin if a large number of tracking branches have
been removed (due to the 2 fork+exec calls per branch).

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-05-28 17:50:40 -04:00
Shawn O. Pearce
ea75ee3598 git-gui: Guess our share/git-gui/lib path at runtime if possible
Johannes Sixt asked me to try to avoid embedding the runtime location
of git-gui's library directory in the executable script.  Not embedding
it helps the MinGW to be relocatable to another directory should a user
wish to install the programs in a directory other than the location the
packager wanted them to be installed into.

Most of this is a hack.  We try to determine if the path of our master
git-gui script will be able to locate the lib by ../share/git-gui/lib.
This should be true if $(gitexecdir) and $(libdir) have the same prefix.
If they do then we defer the assignment of $(libdir) until runtime, and
we get it from $argv0 rather than embedding it into the script itself.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-05-27 00:03:37 -04:00
Shawn O. Pearce
3d5793bf52 Correct key bindings to Control-<foo>
Alberto Bertogli reported on #git that git-gui was exiting with
alt-q, while gitk on the same system was exiting with ctrl-q.
That was not what I wanted.  I really wanted M1B to be bound to
the Control key on most non-Mac OS X platforms, but according to
Sam Vilain M1 on most systems means alt.  Since gitk always does
control, I'm doing the same thing for all non-Mac OS X systems.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-05-24 02:33:13 -04:00
Shawn O. Pearce
306fc12462 git-gui: Tighten internal pattern match for lib/ directory
Our GITGUI_LIBDIR macro was testing only for @@ at the start of
the path, assuming nobody would ever find that to be a reasonable
prefix for a directory to install our library into.  That is most
likely a valid assumption, but its even more unlikely they would
have the start be @@GITGUI_ and the end be @@.  Note that we
cannot use the full string here because that would get expanded
by the sed replacement in our Makefile.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-05-22 03:22:51 -04:00
Shawn O. Pearce
b9e7efb8b5 git-gui: Gracefully handle bad TCL_PATH at compile time
Petr Baudis pointed out the main git.git repository's Makefile dies
now if git-gui 0.7.0-rc1 or later is being used and TCL_PATH was not
set to a working tclsh program path.  This breaks people who may have
a working build configuration today and suddenly upgrade to the latest
git release.

The tclIndex is required for git-gui to load its associated lib files,
but using the Tcl auto_load procedure to source only the files we need
is a performance optimization.  We can emulate the auto_load by just
source'ing every file in that directory, assuming we source class.tcl
first to initialize our crude class system.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-05-17 18:10:26 -04:00
Shawn O. Pearce
6b3d8b97cb git-gui: Paperbag fix blame in subdirectory
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-05-10 17:53:34 -04:00
Shawn O. Pearce
a0db0d61fb git-gui: Generate blame on uncommitted working tree file
If the user doesn't give us a revision parameter to our blame
subcommand then we can generate blame against the working tree
file by passing the file path off to blame with the --contents
argument.  In this case we cannot obtain the contents of the
file from the ODB; instead we must obtain the contents by
reading the working directory file as-is.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-05-08 22:48:47 -04:00
Shawn O. Pearce
3e45ee1ef2 git-gui: Smarter command line parsing for browser, blame
The browser subcommand now optionally accepts a single revision
argument; if no revision argument is supplied then we use the
current branch as the tree to browse.  This is very common, so
its a nice option.

Our blame subcommand now tries to perform the same assumptions
as the command line git-blame; both the revision and the file
are optional.  We assume the argument is a filename if the file
exists in the working directory, otherwise we assume the argument
is a revision name.  A -- can be supplied between the two to force
parsing, or before the filename to force it to be a filename.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-05-08 22:36:01 -04:00
Shawn O. Pearce
c6127856eb git-gui: Use prefix if blame is run in a subdirectory
I think it was Andy Parkins who pointed out that git gui blame HEAD f
does not work if f is in a subdirectory and we are currently running
git-gui within that subdirectory.  This is happening because we did
not take the user's prefix into account when we computed the file
path in the repository.

We now assume the prefix as returned by rev-parse --show-prefix is
valid and we use that during the command line blame subcommand when
we apply the parameters.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-05-08 21:58:25 -04:00
Shawn O. Pearce
685caf9af6 git-gui: Convert blame to the "class" way of doing things
Our blame viewer code has historically been a mess simply
because the data for multiple viewers was all crammed into
a single pair of Tcl arrays.  This made the code hard to
read and even harder to maintain.

Now that we have a slightly better way of tracking the data
for our "meta-widgets" we can make use of it here in the
blame viewer to cleanup the code and make it easier to work
with long term.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-05-08 21:38:55 -04:00
Shawn O. Pearce
c74b6c66f0 git-gui: Convert browser, console to "class" format
Now that we have a slightly easier method of working with per-widget
data we should make use of that technique in our browser and console
meta-widgets, as both have a decent amount of information that they
store on a per-widget basis and our current approach of handling
it is difficult to follow.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-05-08 21:38:54 -04:00
Shawn O. Pearce
f0bc498ec1 Merge branch 'maint'
* maint:
  git-gui: Call changes "Staged" and "Unstaged" in file list titles.
2007-05-08 10:42:16 -04:00
Johannes Sixt
a1a4975824 git-gui: Call changes "Staged" and "Unstaged" in file list titles.
All menu entries talk about "staging" and "unstaging" changes, but the
titles of the file lists use different wording, which may confuse
newcomers.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-05-08 10:35:58 -04:00
Shawn O. Pearce
a6c9b081b6 git-gui: Move merge support into a namespace
Like the console procs I have moved the code related to merge
support into their own namespace, so that they are isolated
from the rest of the world.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-05-07 23:35:51 -04:00
Shawn O. Pearce
60aa065f69 git-gui: Allow vi keys to scroll the diff/blame regions
Users who are used to vi and recent versions of gitk may want
to scroll the diff region using vi style keybindings.  Since
these aren't bound to anything else and that widget does not
accept focus for data input, we can easily support that too.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-05-07 23:35:51 -04:00
Shawn O. Pearce
f522c9b5ed git-gui: Refactor into multiple files to save my sanity
I'm finding it difficult to work with a 6,000+ line Tcl script
and not go insane while looking for a particular block of code.
Since most of the program is organized into different units of
functionality and not all users will need all units immediately
on startup we can improve things by splitting procs out into
multiple files and let auto_load handle things for us.

This should help not only to better organize the source, but
it may also improve startup times for some users as the Tcl
parser does not need to read as much script before it can show
the UI.  In many cases the user can avoid reading at least half
of git-gui now.

Unfortunately we now need a library directory in our runtime
location.  This is currently assumed to be $(sharedir)/git-gui/lib
and its expected that the Makefile invoker will setup some sort of
reasonable sharedir value for us, or let us assume its going to be
$(gitexecdir)/../share.

We now also require a tclsh (in TCL_PATH) to just run the Makefile,
as we use tclsh to generate the tclIndex for our lib directory.  I'm
hoping this is not an unncessary burden on end-users who are building
from source.

I haven't really made any functionality changes here, this is just a
huge migration of code from one file to many smaller files.  All of
the new changes are to setup the library path and install the library
files.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-05-07 23:35:48 -04:00
Shawn O. Pearce
dc6716b83d git-gui: Refactor to use our git proc more often
Whenever we want to execute a git subcommand from the plumbing
layer (and on rare occasion, the more porcelain-ish layer) we
tend to use our proc wrapper, just to make the code slightly
cleaner at the call sites.  I wasn't doing that in a couple of
places, so this is a simple cleanup to correct that.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-05-02 13:06:11 -04:00
Shawn O. Pearce
7416bbc65c git-gui: Use option database defaults to set the font
Rather than passing "-font font_ui" to every widget that we
create we can instead reconfigure the option database for
all widget classes to use our font_ui as the default widget
font.  This way Tk will automatically setup their defaults
for us, and we can reduce the size of the application.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-05-02 13:06:10 -04:00
Shawn O. Pearce
2739291b77 git-gui: Cleanup common font handling for font_ui
An earlier change tossed these optionMenu font configurations
all over the code, when really we can just rename the proc to
a hidden internal name and provide our own wrapper to install
the font configuration we really want.

We also don't need to set these option database entries in all
of the procedures that open dialogs; instead we should just set
one time, them after we have the font configuration ready for use.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-05-02 13:06:10 -04:00
Shawn O. Pearce
d45b52b540 git-gui: Correct line wrapping for too many branch message
Since Tk automatically wraps lines for us in tk_messageBox
widgets we don't need to try to wrap them ourselves.  Its
actually worse that we linewrapped this here in the script,
as not all fonts will render this dialog nicely.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-05-02 13:06:10 -04:00
Shawn O. Pearce
1afd1ec107 git-gui: Warn users before making an octopus merge
A coworker who was new to git-gui recently tried to make an octopus
merge when he did not quite mean to.  Unfortunately in his case the
branches had file level conflicts and failed to merge with the octopus
strategy, and he didn't quite know why this happened.  Since most users
really don't want to perform an octopus merge this additional safety
valve in front of the merge process is a good thing.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-05-02 13:06:09 -04:00
Shawn O. Pearce
2f1a955b99 git-gui: Include the subject in the status bar after commit
Now that the command line git-commit has made displaying
the subject (first line) of the newly created commit popular
we can easily do the same thing here in git-gui, without the
ugly part of forking off a child process to obtain that first
line.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-05-02 13:06:09 -04:00
Shawn O. Pearce
3f28f63f5a Merge branch 'maint'
* maint:
  git-gui: Allow spaces in path to 'wish'
2007-05-02 12:45:31 -04:00
Shawn O. Pearce
681bfd59ce git-gui: Allow spaces in path to 'wish'
If the path of our wish executable that are running under
contains spaces we need to make sure they are escaped in
a proper Tcl list, otherwise we are unable to start gitk.

Reported by Randal L. Schwartz on #git.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-05-02 12:44:44 -04:00
Shawn O. Pearce
f20db5ff30 git-gui: Correctly handle UTF-8 encoded commit messages
Uwe Kleine-König discovered git-gui mangled his surname and did
not send the proper UTF-8 byte sequence to git-commit-tree when
his name appeared in the commit message (e.g. Signed-Off-By line).

Turns out this was related to other trouble that I had in the past
with trying to use "fconfigure $fd -encoding $enc" to select the
stream encoding and let Tcl's IO engine do all of the encoding work
for us.  Other parts of git-gui were just always setting the file
channels to "-encoding binary" and then performing the encoding
work themselves using "encoding convertfrom" and "convertto", as
that was the only way I could make UTF-8 filenames work properly.

I found this same bug in the amend code path, and in the blame
display.  So its fixed in all three locations (commit creation,
reloading message for amend, viewing  message in blame).

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-04-24 02:11:40 -04:00
Shawn O. Pearce
19c821487b git-gui: Display the directory basename in the title
By showing the basename of the directory very early in the
title bar I can more easily locate a particular git-gui
session when I have 8 open at once and my  Windows taskbar
is overflowing with items.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-04-15 00:35:13 -04:00
Shawn O. Pearce
d025d1e322 Merge branch 'er/ui'
* er/ui:
  Always bind the return key to the default button
  Do not break git-gui messages into multiple lines.
  Improve look-and-feel of the git-gui tool.
  Teach git-gui to use the user-defined UI font everywhere.
  Allow wish interpreter to be defined with TCLTK_PATH
2007-04-15 00:34:28 -04:00
Shawn O. Pearce
f6f2aa39ef git-gui: Brown paper bag fix division by 0 in blame
If we generate a blame status string before we have obtained
any annotation data at all from the input file, or if the input
file is empty, our total_lines will be 0.  This causes a division
by 0 error when we blindly divide by the 0 to compute the total
percentage of lines loaded.  Instead we should report 0% done.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-04-04 12:08:46 -04:00
Shawn O. Pearce
4372da3441 Always bind the return key to the default button
If a dialog/window has a default button registered not every
platform associates the return key with that button, but all
users do.  We have to register the binding of the return key
ourselves to make sure the user's expectations of pressing
return will activate the default button are met.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-04-04 11:45:33 -04:00
Eygene Ryabinkin
53a291a435 Do not break git-gui messages into multiple lines.
Many git-gui messages were broken into a multiple lines to make
good paragraph width. Unfortunately in reality it breaks the paragraph
width completely, because the dialog window width does not coincide
with the paragraph width created by the current font.

Tcl/Tk's standard dialog boxes are breaking the long lines
automatically, so it is better to make long lines and let the
interpreter do the job.

Signed-off-by: Eygene Ryabinkin <rea-git@codelabs.ru>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-04-04 11:37:57 -04:00
Eygene Ryabinkin
df0cd69558 Improve look-and-feel of the git-gui tool.
Made the default buttons on the dialog active and focused upon the
dialog appearence.

Bound 'Escape' and 'Return' keys to the dialog dismissal where it
was appropriate: mainly for dialogs with only one button and no
editable fields, but on console output dialogs as well.

Signed-off-by: Eygene Ryabinkin <rea-git@codelabs.ru>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-04-04 11:37:56 -04:00
Eygene Ryabinkin
3cf0bad830 Teach git-gui to use the user-defined UI font everywhere.
Some parts of git-gui were not respecting the default GUI font.
Most of them were catched and fixed.

Signed-off-by: Eygene Ryabinkin <rea-git@codelabs.ru>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-04-04 11:37:56 -04:00
Shawn O. Pearce
756d846fea git-gui: Allow 'git gui version' outside of a repository
I got a little surprise one day when I tried to run 'git gui version'
outside of a Git repository to determine what version of git-gui was
installed on that system.  Turns out we were doing the repository
check long before we got around to command line argument handling.

We now look to see if the only argument we have been given is
'version' or '--version', and if so, print out the version and
exit immediately; long before we consider looking at the Git
version or working directory.  This way users can still get to
the git-gui version number even if Git's version cannot be read.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-03-12 13:26:06 -04:00
Shawn O. Pearce
bb616ddd15 git-gui: Revert "git-gui: Display all authors of git-gui."
This reverts commit 871f4c97ad.

Too many users have complained about the credits generator in
git-gui, so I'm backing the entire thing out.  This revert will
finish that series.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-03-12 13:26:04 -04:00
Shawn O. Pearce
c7bafad10d git-gui: Allow committing empty merges
Johannes Sixt noticed that git-gui would not let the user commit
a merge created by `git merge -s ours` as the ours strategy does
not alter the tree (that is HEAD^1^{tree} = HEAD^{tree} after the
merge).  The same issue arises from amending such a merge commit.

We now permit an empty commit (no changed files) if we are doing
a merge commit.  Core Git does this with its command line based
git-commit tool, so it makes sense for the GUI to do the same.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-03-12 13:03:47 -04:00
Shawn O. Pearce
c3e8a0a4dd git-gui: Remove unnecessary /dev/null redirection.
Git 1.5.0 and later no longer output useless messages to standard
error when making the initial (or what looks to be) commit of a
repository.  Since /dev/null does not exist on Windows in the
MinGW environment we can't redirect there anyway.  Since Git
does not output anymore, I'm removing the redirection.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-03-01 14:37:34 -05:00
Shawn O. Pearce
51bd9d7b8c git-gui: Don't create empty (same tree as parent) commits.
Mark Levedahl noticed that git-gui will let you create an empty
normal (non-merge) commit if the file state in the index is out
of whack.  The case Mark was looking at was with the new autoCRLF
feature in git enabled and is actually somewhat difficult to create.

I found a different way to create an empty commit:  turn on the
Trust File Modifications flag, touch a file, rescan, then move
the file into the "Changes To Be Committed" list without looking
at the file's diff.  This makes git-gui think there are files
staged for commit, yet the update-index call did nothing other
than refresh the stat information for the affected file.  In
this case git-gui allowed the user to make a commit that did
not actually change anything in the repository.

Creating empty commits is usually a pointless operation; rarely
does it record useful information.  More often than not an empty
commit is actually an indication that the user did not properly
update their index prior to commit.  We should help the user out
by detecting this possible mistake and guiding them through it,
rather than blindly recording it.

After we get the new tree name back from write-tree we compare
it to the parent commit's tree; if they are the same string and
this is a normal (non-merge, non-amend) commit then something
fishy is going on.  The user is making an empty commit, but they
most likely don't want to do that.  We now pop an informational
dialog and start a rescan, aborting the commit.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-02-26 11:47:14 -05:00
Shawn O. Pearce
fd234dfdb7 git-gui: Add Reset to the Branch menu.
cehteh on #git noticed that there was no way to perform a reset --hard
from within git-gui.  When I pointed out this was Merge->Abort Merge
cehteh said this is not very understandable, and that most users would
never guess to try that option unless they were actually in a merge.

So Branch->Reset is now also a way to cause a reset --hard from within
the UI.  Right now the confirmation dialog is the same as the one used
in Merge->Abort Merge.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-02-26 11:22:10 -05:00
Shawn O. Pearce
9b28a8b9c2 git-gui: Relocate the menu/transport menu code.
This code doesn't belong down in the main window UI creation,
its really part of the menu system and probably should be
located with it.  I'm moving it because I could not find
the code when I was looking for it earlier today, as it was
not where I expected it to be found.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-02-26 11:17:11 -05:00
Shawn O. Pearce
981193786f git-gui: Don't crash in citool mode on initial commit.
Attempting to use `git citool` to create an initial commit caused
git-gui to crash with a Tcl error as it tried to add the newly
born branch to the non-existant branch menu.  Moving this code
to after the normal commit cleanup logic resolves the issue, as
we only have a branch menu if we are not in singlecommit mode.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-02-21 01:33:59 -05:00
Shawn O. Pearce
c0f7a6c33d git-gui: Include browser in our usage message.
Now that the 'browser' subcommand can be used to startup the tree
browser, it should be listed as a possible subcommand option in
our usage message.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-02-21 01:24:57 -05:00
Shawn O. Pearce
019f42a4ff git-gui: Change summary of git-gui.
Since git-gui does more than create commits, it is unfair to call
it "a commit creation tool".  Instead lets just call it a graphical
user interface.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-02-21 00:11:02 -05:00
Shawn O. Pearce
871f4c97ad git-gui: Display all authors of git-gui.
Now that git-gui has been released to the public as part of Git 1.5.0
I am starting to see some work from other people beyond myself and
Paul.  Consequently the copyright for git-gui is not strictly the
two of us anymore, and these others deserve to have some credit
given to them.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-02-21 00:11:01 -05:00
Shawn O. Pearce
ee40599330 git-gui: Use mixed path for docs on Cygwin.
The Firefox browser requires that a URL use / to delimit directories.
This is instead of \, as \ gets escaped by the browser into its hex
escape code and then relative URLs are incorrectly resolved, Firefox
no longer sees the directories for what they are.  Since we are
handing the browser a true URL, we better use the standard / for
directories.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-02-21 00:11:01 -05:00
Shawn O. Pearce
372ef954a1 git-gui: Correct crash when saving options in blame mode.
Martin Waitz noticed that git-gui crashed while saving the user's
options out if the application was started in blame mode.  This
was caused by the do_save_config procedure invoking reshow_diff
incase the number of context lines was modified by the user.
Because we bypassed main window UI setup to enter blame mode we
did not set many of the globals which were accessed by reshow_diff,
and reading unset variables is an error in Tcl.

Aside from moving the globals to be set earlier, I also modified
reshow_diff to not invoke clear_diff if there is no path currently
in the diff viewer.  This way reshow_diff does not crash when in
blame mode due to the $ui_diff command not being defined.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-02-18 02:12:32 -05:00
Shawn O. Pearce
b90d479255 git-gui: Expose the browser as a subcommand.
Some users may find being able to browse around an arbitrary
branch to be handy, so we now expose our graphical browser
through `git gui browse <committish>`.

Yes, I'm being somewhat lazy and making the user give us
the name of the branch to browse.  They can always enter
HEAD.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-02-16 00:24:03 -05:00
Martin Koegler
101e3ae7a6 git-gui: Create new branches from a tag.
I'm missing the possibility to base a new branch on a tag.
The following adds a tag drop down to the new branch dialog.

Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-02-15 01:34:40 -05:00
Shawn O. Pearce
ed3adde081 git-gui: Print version on the console.
Like `git version`, `git gui version` (or `git gui --version`) shows
the version of git-gui, in case the user needs to know this, without
looking at it in the GUI about dialog.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-02-14 00:28:00 -05:00
Shawn O. Pearce
5ac58f5ba1 git-gui: More consistently display the application name.
I started to find it confusing that git-gui would refer to itself
as git-citool when it was started through the citool hardlink, or
with the citool subcommand.  What was especially confusing was the
options dialog and the about dialog, as both seemed to imply they
were somehow different from the git-gui versions.  In actuality
there is no difference at all.

Now we just call our options menu item 'Options...' (skipping the
application name) and our About dialog now always shows git-gui
within the short description (above the copyleft notice) and in
the version field.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-02-14 00:10:20 -05:00
Shawn O. Pearce
cdf6e08880 git-gui: Permit merging tags into the current branch.
It was pointed out on the git mailing list by Martin Koegler that
we did not show tags as possible things to merge into the current
branch.  They actually are, and core Git's Grand Unified Merge
Driver will accept them just like any other commit.

So our merge dialog now requests all refs/heads, refs/remotes and
refs/tags named refs and attempts to match them against the commits
not in HEAD.  One complicating factor here is that we must use the
%(*objectname) field when talking about an annotated tag, as they
will not appear in the output of rev-list.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-02-13 23:43:48 -05:00
Shawn O. Pearce
54acdd95b8 git-gui: Basic version check to ensure git 1.5.0 or later is used.
This is a very crude (but hopefully effective) check against the
`git` executable found in our PATH.  Some of the subcommands and
options that git-gui requires to be present to operate were created
during the 1.5.0 development cycle, so 1.5 is the minimum version
of git that we can expect to support.

There actually are early releases of 1.5 (e.g. 1.5.0-rc0) that
don't have everything we expect (like `blame --incremental`) but
these are purely academic at this point.  1.5.0 final was tagged
and released just a few hours ago.  The release candidates will
(hopefully) fade into the dark quickly.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-02-13 23:15:25 -05:00
Shawn O. Pearce
8134722306 git-gui: Refactor 'exec git subcmd' idiom.
As we frequently need to execute a Git subcommand and obtain
its returned output we are making heavy use of [exec git foo]
to run foo.  As I'm concerned about possibly needing to carry
environment data through a shell on Cygwin for at least some
subcommands, I'm migrating all current calls to a new git
proc.  This actually makes the code look cleaner too, as
we aren't saying 'exec git' everywhere.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-02-13 21:32:52 -05:00
Shawn O. Pearce
7e81d4eead git-gui: Rename GIT_VERSION to GITGUI_VERSION.
Now that the decision has been made to treat git-gui as a
subproject, rather than merging it directly into git, we
should use a different substitution for our version value
to avoid any possible confusion.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-02-12 16:12:04 -05:00
Shawn O. Pearce
0960f7d6db git-gui: Stop deleting gitk preferences.
Now that git 1.5.0 and later contains a version of gitk that uses
correct geometry on Windows platforms, even if ~/.gitk exists, we
should not delete the user's ~/.gitk to work around the bug.  It
is downright mean to remove a user's preferences for another app.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-02-11 17:19:38 -05:00
Shawn O. Pearce
d585e782b0 git-gui: Focus into blame panels on Mac OS.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-02-09 02:28:32 -05:00
Shawn O. Pearce
486ef5270c git-gui: Improve annotated file display.
Rather than trying to mark the background color of the line numbers
to show which lines have annotated data loaded, we now show a ruler
between the line numbers and the file data.  This ruler is just 1
character wide and its background color is set to grey to denote
which lines have annotation ready.  I had to make this change as I
kept loosing the annotation marker when a line was no longer colored
as part of the current selection.

We now color the lines blamed on the current commit in yellow, the
lines in the commit which came after (descendant) in red (hotter,
less tested) and the lines in the commit before (ancestor) in blue
(cooler, better tested).

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-02-09 01:59:38 -05:00
Shawn O. Pearce
1351ba13e5 git-gui: Jump to the first annotation block as soon as its available.
To help clue users into the fact that annotation data arrives
incrementally, and that they should try to locate the region
they want while the tool is running, we jump to the first line
of the first annotation if the user has not already clicked on
a line they are interested in and if the window is still looking
at the very top of the file.

Since it takes a second (at least on my PowerBook) to even generate
the first annotation for git-gui.sh, the user should have plenty of
time to adjust the scrollbar or click on a line even before we get
that first annotation record in, which allows the user to bypass
our automatic jumping.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-02-08 22:41:51 -05:00
Shawn O. Pearce
6910ae80d0 git-gui: Redesign the display of annotated files.
Using 180 columns worth of screen space to display just 20 columns of
file data and 160 columns worth of annotation information is not
practically useful.  Users need/want to see the file data, and have
the anotation associated with it displayed in a detail pane only when
they have focused on a particular region of the file.

Now our file viewer has a small 10-line high pane below the file
which shows the commit message for the commit this line was blamed
on.  The columns have all been removed, except the current line
number column as that has some real value when trying to locate an
interesting block.

To keep the user entertained we have a progress meter in the status
bar of the viewer which lets them know how many lines have been
annotated, and how much has been completed.  We use a grey background
on the line numbers for lines which we have obtained annotation from,
and we color all lines in the current commit with a yellow background,
so they stand out when scanning through the file.  All other lines
are kept with a white background, making the yellow really pop.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-02-08 21:39:27 -05:00
Shawn O. Pearce
df6287ecd7 git-gui: Use git-config now over git-repo-config.
Now that core Git has "renamed" git-repo-config to git-config,
we should do the same.  I don't know how long core Git will
keep the repo-config command, and since git-gui's userbase
is so small and almost entirely on some flavor of 1.5.0-rc2
or later, where the rename has already taken place, it should
be OK to rename now.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-02-08 19:53:36 -05:00
Shawn O. Pearce
24d2bf2f02 git-gui: Relabel the Add All action.
One user that I spoke with recently was confused why the 'Add All'
button did not add all of his 'Changed But Not Updated' files.
The particular files in question were new, and thus not known to
Git.  Since the 'Add All' routine only updates files which are
already tracked, they were not added automatically.

I suspect that calling this action 'Add Existing' would be less
confusing, so I'm renaming it.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-02-08 19:44:49 -05:00
Shawn O. Pearce
258871d305 git-gui: Select subcommands like git does.
If we are invoked as `git-foo`, then we should run the `foo` subcommand,
as the user has made some sort of link from `git-foo` to our actual
program code.  So we should honor their request.

If we are invoked as `git-gui foo`, the user has not made a link (or
did, but is not using it right now) so we should execute the `foo`
subcommand.

We now can start the single commit UI mode via `git-citool` and also
through `git gui citool`.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-02-08 19:41:32 -05:00
Shawn O. Pearce
2ebba528dc git-gui: View blame from the command line.
Viewing annotated files is one of those tasks that is relatively
difficult to do in a simple vt100 terminal emulator.  The user
really wants to be able to browse through a lot of information,
and to interact with it by navigating through revisions.

Now users can start our file viewer with annotations by running
'git gui blame commit path', thereby seeing the contents of the
given file at the given commit.  Right now I am being lazy by
not allowing the user to omit the commit name (and have us thus
assume HEAD).

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-02-08 19:10:52 -05:00
Shawn O. Pearce
db7f34d4c5 git-gui: Optionally save commit buffer on exit.
If the commit area does not exist, don't save the commit message to
a file, or the window geometry.  The reason I'm doing this is I want
to make the main window entirely optional, such as if the user has
asked us to show a blame from the command line.  In such cases the
commit area won't exist and trying to get its text would cause an
error.

If we are running without the commit message area, we cannot save
our window geometry either, as the root window '.' won't be a normal
commit window.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-02-08 18:14:44 -05:00
Shawn O. Pearce
64a906f861 git-gui: Separate transport/branch menus from multicommit.
These are now controlled by the transport and branch options, rather
than the multicommit option.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-02-08 18:10:05 -05:00
Shawn O. Pearce
cf25ddc8b3 git-gui: Refactor single_commit to a proc.
This is a minor code cleanup to make working with what used to be the
$single_commit flag easier.  Its also to better handle various UI
configurations, depending on command line parameters given by the
user, or perhaps user preferences.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-02-08 18:03:41 -05:00
Shawn O. Pearce
42b922fcf6 git-gui: Replace \ with \\ when showing paths.
We already replace \n with \\n so that Tk widgets don't start a new
display line with part of a file path which is just unlucky enough
to contain an LF.  But then its confusing to read a path whose name
actually contains \n as literal characters.  Escaping \ to \\ would
make that case display as \\n, clarifying the output.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-02-08 17:13:51 -05:00
Shawn O. Pearce
9bccb782c3 git-gui: Support keyboard traversal in browser.
Users want to navigate the file list shown in our branch browser
windows using the keyboard.  So we now support basic traversal
with the arrow keys:

  Up/Down:  Move the "selection bar" to focus on a different name.

  Return:   Move into the subtree, or open the annotated file.
  M1-Right: Ditto.

  M1-Up:    Move to the parent tree.
  M1-Left:  Ditto.

Probably the only feature missing from this is to key a leading part
of the file name and jump directly to that file (or subtree).

This change did require a bit of refactoring, to pull the navigation
logic out of the mouse click procedure and into more generic routines
which can also be used in bindings.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-02-08 17:07:59 -05:00
Shawn O. Pearce
63faf4df6e git-gui: Update known branches during rescan.
If the user has created (or deleted) a branch through an external tool,
and uses Rescan, they probably are trying to make git-gui update to show
their newly created branch.

So now we load all known heads and update the branch menu during any
rescan operation, just in-case the set of known branches was modified.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-02-08 15:59:39 -05:00
Shawn O. Pearce
37f1db80a4 git-gui: Assign background colors to each blame hunk.
To help the user visually see which lines are associated with each other
in the file we attempt to sign a unique background color to each commit
and then render all text associated with that commit using that color.

This works out OK for a file which has very few commits in it; but
most files don't have that property.

What we really need to do is look at what colors are used by our
neighboring commits (if known yet) and pick a color which does not
conflict with our neighbor.  If we have run out of colors then we
should force our neighbor to recolor too.  Yes, its the graph coloring
problem.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-01-29 06:56:00 -05:00
Shawn O. Pearce
747c0cf93c git-gui: Use a grid layout for the blame viewer.
Using a panedwindow to display the blame viewer's individual columns
just doesn't make sense.  Most of the important data fits within the
columns we have allocated, and those that don't the leading part fits
and that's good enough.  There are just too many columns within this
viewer to let the user sanely control individual column widths.  This
change shouldn't really be an issue for most git-gui users as their
displays should be large enough to accept this massive dump of data.

We now also have a properly working horizontal scrollbar for the
current file data area.  This makes it easier to get away with a
narrow window when screen space is limited, as you can still scroll
around within the file content.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-01-29 06:23:12 -05:00
Shawn O. Pearce
e7fb6c69f7 git-gui: Install column headers in blame viewer.
I started to get confused about what each column meant in the blame
viewer, and I'm the guy who wrote the code!  So now git-gui hints to
the user about what each column is by drawing headers at the top.
Unfortunately this meant I had to use those dreaded frame objects
which seem to cause so much pain on Windows.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-01-29 05:51:49 -05:00
Shawn O. Pearce
915616e4eb git-gui: Display original filename and line number in blame.
When we annotate a file and show its line data, we're already asking
for copy and movement detection (-M -C).  This costs extra time, but
gives extra data.  Since we are asking for the extra data we really
should show it to the user.

Now the blame UI has two additional columns, one for the original
filename (in the case of a move/copy between files) and one for the
original line number of the current line of code.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-01-29 05:33:27 -05:00
Shawn O. Pearce
8f6c07b902 git-gui: Correctly handle spaces in filepaths.
Anytime are about to open a pipe on what may be user data we need to
make sure the value is escaped correctly into a Tcl list, so that the
executed subprocess will receive the right arguments.  For the most
part we were already doing this correctly, but a handful of locations
did not.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-01-29 03:09:28 -05:00
Shawn O. Pearce
463ca37b61 git-gui: Use -M and -C when running blame.
Since we run blame incrementally in the background we might as well get
as much data as we can from the file.  Adding -M and -C definately makes
it take longer to compute the revision annotations, but since they are
streamed in and updated as they are discovered we'll get recent data
almost immediately anyway.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-01-29 03:03:29 -05:00
Shawn O. Pearce
db45378165 git-gui: Allow users to edit user.name, user.email from options.
Users may need to be able to alter their user.name or user.email
configuration settings.  If they are mostly a git-gui user they
should be able to view/set these important values from within
the git-gui environment, rather than needing to edit a raw text
file on their local filesystem.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-01-29 02:56:07 -05:00
Shawn O. Pearce
c94dd1c8c2 git-gui: Display the current branch name in browsers.
Rather than using HEAD for the current branch, use the actual name of
the current branch in the browser.  This way the user knows what a
browser is browsing if they open up different browsers while on different
branches.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-01-29 02:52:06 -05:00
Shawn O. Pearce
3eddda9843 git-gui: Improve the icons used in the browser display.
Real icons which seem to indicate going up to the parent (an up arrow)
and a subdirectory (an open folder).  Files are now drawn with the
file_mod icon, like a modified file is.  This just looks better as it
is more consistent with the rest of our UI.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-01-29 02:50:10 -05:00
Shawn O. Pearce
35874c163e git-gui: Implemented file browser and incremental blame.
This rather huge change provides a browser for the current branch.  The
browser simply shows the contents of tree HEAD, and lets the user drill
down through the tree.  The icons used really stink, as I just copied in
icon which we already had.  I really need to replace the file_dir and
file_uplevel icons with something more useful.

If the user double clicks on a file within the browser we open it in
a blame viewer.  This makes use of the new incremental blame feature
that Linus just added yesterday to core Git.  Fortunately the feature
will be in 1.5.0 final so we can rely on having it available here.

Since the blame engine is incremental the user will get blame data
for groups which can be determined early.  Git will slowly fill in
the remaining lines as it goes.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-01-29 01:12:42 -05:00
Shawn O. Pearce
20ddfcaa7e git-gui: Test for Cygwin differently than from Windows.
Running on Cygwin is different than if we were running through MinGW.

In the Cygwin case we have cygpath available to us, we need to perform
UNIX<->Windows path translation sometimes, and we need to perform odd
things like spawning our own login shells to perform network operations.
But in the MinGW case these don't occur.  Git knows native Windows file
paths, and login shells may not even exist.

Now git-gui will avoid running cygpath unless it knows its on Cygwin.
It also uses a different shortcut type when Cygwin is not present, and
it avoids invoking /bin/sh to execute hooks if Cygwin is not present.
This latter part probably needs more testing in the MinGW case.

This change also improves how we start gitk.  If the user is on any type
of Windows system its known that gitk won't start right if ~/.gitk exists.
So we delete it before starting if we are running on any type of Windows
operating system.  We always use the same wish executable which launched
git-gui to start gitk; this way on Windows we don't have to jump back to
/bin/sh just to go into the first wish found in the user's PATH.  This
should help on MinGW when we probably don't want to spawn a shell just
to start gitk.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-01-29 01:12:42 -05:00
Shawn O. Pearce
273984fc4f git-gui: Offer quick access to the HTML formatted documentation.
Users may want to be able to read Git documentation, even if they
are not command line users.  There are many important concepts and
terms covered within the standard Git documentation which would be
useful to even non command line using people.

We now try to offer an 'Online Documentation' menu option within the
Help menu.  First we try to guess to see what browser the user has
setup.  We default to instaweb.browser, if set, as this is probably
accurate for the user's configuration.  If not then we try to guess
based on the operating system and the available browsers for each.
We prefer documentation which is installed parallel to Git's own
executables, e.g. `git --exec-path`/../Documentation/index.html, as
that is how I typically install the HTML docs.  If those are not found
then we open the documentation published on kernel.org.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-01-29 01:12:42 -05:00
Shawn O. Pearce
6b90d39186 git-gui: Reword meaning of merge.summary.
OK, its official, I'm not reading documentation as well as I should be.
Core Git's merge.summary configuration option is used to control the
generation of the text appearing within the merge commit itself.  It
is not (and never has been) used to default the --no-summary command
line option, which disables the diffstat at the end of the merge.

I completely blame Git for naming two unrelated options almost the
exact same thing.  But its my own fault for allowing git-gui to
confuse the two.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-01-27 02:31:01 -05:00
Shawn O. Pearce
c539449b2d git-gui: Support merge.summary, merge.verbosity.
Changed our private merge summary config option to be the same as the
merge.summary option supported by core Git.  This means setting the
"Show Merge Summary" flag in git-gui will have the same effect on
the command line.

In the same vein I've also added merge.verbosity to the gui options,
allowing the user to adjust the verbosity level of the recursive
merge strategy.  I happen to like level 1 and suggest that other users
use that, but level 2 is the core Git default right now so we'll use
the same default in git-gui.

Unfortunately it appears as though core Git has broken support for
the merge.summary option, even though its still in the documentation
For the time being we should pass along --no-summary to git-merge if
merge.summary is false.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-01-26 04:43:43 -05:00
Shawn O. Pearce
729a6f60dd git-gui: Always offer scrollbars for branch lists.
Anytime we use a listbox to show branch names its possible for the
listbox to exceed 10 entries (actually its probably very common).
So we should always offer a scrollbar for the Y axis on these
listboxes.  I just forgot to add it when I defined them.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-01-26 04:16:39 -05:00
Shawn O. Pearce
5f39dbf64f git-gui: Don't allow merges in the middle of other things.
If the user is in the middle of a commit they have files which are
modified.  These may conflict with any merge that they may want
to perform, which would cause problems if the user wants to abort
a bad merge as we wouldn't have a checkpoint to roll back onto.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-01-26 04:11:10 -05:00
Shawn O. Pearce
dff7e88feb git-gui: Don't allow users to commit a bad octopus merge.
If an octopus merge goes horribly wrong git-merge will leave the
working directory and index dirty, but will not leave behind a
MERGE_HEAD file for a later commit.  Consequently we won't know
its a merge commit and instead would let the user resolve the
conflicts and commit a single-parent commit, which is wrong.

So now if an octopus merge fails we notify the user that the
merge did not work, tell them we will reset the working directory,
and suggest that they merge one branch at a time.  This prevents
the user from committing a bad octopus merge.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-01-26 04:07:34 -05:00
Shawn O. Pearce
ee3cfb5954 git-gui: Update status bar during a merge.
I got slightly confused when I did two merges in a row, as the status
bar said "merge completed successfully" while the second merge was
still running.  Now we show what branches are actively being merged.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-01-26 03:58:56 -05:00
Shawn O. Pearce
ce9735dfbd git-gui: Let users abort with reset --hard type logic.
If you get into the middle of a merge that turns out to be horrible
and just not something you want to do right now, odds are you need
to run `git reset --hard` to recover your working directory to a
pre-merge state.

We now offer Merge->Abort Merge for exactly this purpose, however
its also useful to thow away a non-merge, as its basically the same
logic as `git reset --hard`.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-01-26 03:54:05 -05:00
Shawn O. Pearce
e4834837a8 git-gui: Implement local merge operations.
To allow users to merge local heads and tracking branches we now offer
a dialog which lets the user select 1-15 branches and merge them using
the stock `git merge` Grand Unified Merge Driver.

Originally I had wanted to implement this merge internally within git-gui
as I consider GUMD to be mostly Porcelain-ish, but the truth is it does
its job exceedingly well and its a relatively complex chunk of code.
I'll probably circle back later and try to remove the invocation of GUMD
from git-gui, but right now it lets me get the job done faster.

Users cannot start a merge if they are currently in the middle of one,
or if they are amending a commit.  Trying to do either is just stupid
and should be stopped as early as possible.

I've also made it simple for users to startup a gitk session prior to
a merge by offering a Visualize button which runs `gitk $revs --not HEAD`,
where $revs is the list of branches currently selected in the merge
dialog.  This makes it quite simple to find out what the damage will
be to the current branch if you were to carry out the currently proposed
merge.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-01-26 03:33:56 -05:00
Shawn O. Pearce
bc7452f5e7 git-gui: Use builtin version of 'git gc'.
Technically the new git-gc command is strictly Porcelain; its invoking
multiple plumbing commands to do its work.  Since git-gui tries to not
rely on Porclain we shouldn't be invoking git-gc directly, instead we
should perform its tasks on our own.

To make this easy I've created console_chain, which takes a list of
tasks to perform and runs them all in the same console window.  If
any individual task fails then the chain stops running and the window
shows a failure bar.  Only once all tasks have been completed will it
invoke console_done with a successful status.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-01-26 02:02:09 -05:00
Shawn O. Pearce
6c3d1481ba git-gui: Refactor console success/failure handling.
Because I want to be able to run multiple output-producing commands
in a single 'console' window within git-gui I'm refactoring the
console handling routines to require the "after" argument of console_exec.
This should specify a procedure to execute which will receive two args,
the first is the console window handle and the second is the status of
the last command (0 on failure, 1 on success).

A new procedure console_done can be passed to the last console_exec
command to forward perform all cleanup and enable the Close button.
Its status argument is used to update the final status bar on the
bottom of the console window.

This isn't any real logic changing, and no new functionality is in
this patch.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-01-26 01:29:00 -05:00
Shawn O. Pearce
b972ea59e4 git-gui: Always use -v option to push.
Right now `git-push -v` is actually not that verbose; it merely adds
the URL it is pushing to.  This can be informative if you are pushing
to a configured remote, as you may not actually remember what URL that
remote is connected to.  That detail can be important if the push
fails and you attempt to communicate the errors to a 3rd party to help
you resolve the issue.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-01-26 00:49:17 -05:00
Shawn O. Pearce
86a2af6087 git-gui: Remove no longer used pull from remote code.
Because we aren't going to support single click pulling of changes from
an existing remote anytime in the near future, I'm moving the code which
used to perform that action.  Hopefully we'll be able to do something
like it in the near-future, but also support local branches just as
easily.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-01-26 00:47:44 -05:00
Shawn O. Pearce
1d6a978752 git-gui: Added arbitrary branch pushing support.
Because its common for some users to push topic branches to a remote
repository for review and merging by other parties, users need an
easy way to push one or more branches to a remote repository without
needing to edit their .git/config file anytime their set of active
branches changes.

We now provide a basic 'Push...' menu action in the Push menu which
opens a dialog allowing the user to select from their set of local
branches (refs/heads, minus tracking branches).  The user can designate
which repository to send the changes to by selecting from an already
configured remote or by entering any valid Git URL.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-01-26 00:41:01 -05:00
Shawn O. Pearce
156b29211a git-gui: Always use lsearch -exact, to prevent globbing.
Anytime we are using lsearch we are doing [lsearch -sorted] and we
are applying it to file paths (or file path like things).  Its valid
for these to contain special glob characters, but when that happens
we do not want globbing to occur.  Instead we really need exact
match semantics.  Always supplying -exact to lsearch will ensure that
is the case.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-01-26 00:41:01 -05:00
Shawn O. Pearce
5f8b70b1dc git-gui: Maintain the same file list for diff during refresh.
I just noticed that a file was always jumping to compare against HEAD
and the index during a refresh, even if the diff viewer was comparing
the index against the working directory prior to the refresh.  The
bug turned out to be caused by a foreach loop going through all file
list names searching for the path.  Since $ui_index was the first one
searched and the file was contained in that file list the loop broke
out, leaving $w set to $ui_index when it had been set by the caller
to $ui_workdir.  Silly bug caused by using a parameter as a loop
index.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-01-26 00:41:01 -05:00
Shawn O. Pearce
d070c4cb17 git-gui: Don't switch branches if changing to the current branch.
Its pointless to switch to the current branch, so don't do it. We
are already on it and the current index and working directory should
just be left alone.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-01-25 17:16:57 -05:00