Commit Graph

312 Commits

Author SHA1 Message Date
Shawn O. Pearce
ab0d33c438 git-gui: Protect against bad translation strings
If a translation string uses a format character we don't have an
argument for then it may throw an error when we attempt to format
the translation.  In this case switch back to the default format
that comes with the program (aka the English translation).

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-10-26 03:08:37 -04:00
Shawn O. Pearce
a5bb31fb63 git-gui: Paper bag fix the global config parsing
git-config won't honor any options after --list.  We must supply
the --global option in front of --list if we really want to load
the global configuration options.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-10-17 03:38:00 -04:00
Shawn O. Pearce
d6db1ad51a git-gui: Ensure copyright message is correctly read as UTF-8
On Windows using the native Tcl/Tk the copyright header is
being read from the script using the system encoding, which
may not be utf-8.  This causes the multi-byte copyright symbol
(which is actually encoded as utf-8) to read as two characters
and not as a proper copyright symbol.  Explicitly asking Tcl
to read this sequence of bytes as utf-8 corrects the issue.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-10-12 23:06:36 -04:00
Steffen Prohaska
24f7c64b21 git-gui: offer a list of recent repositories on startup
If git-gui is started outside a work tree the repository chooser
will offer a list of recently opened repositories.  Clicking on
any list entry directly opens the repository.

The list of recently opened repositories is stored in the config
as the multi-valued option gui.recentrepo. If the list grows beyond
10 entries it will be truncated by removing one of the older entries.

Only repositories that are opened through the repository chooser
will get added to the recent list.  Repositories opened from the
shell will not yet be added to the recent list, as users are likely
to have a way to easily return to the same directory via their shell.

[sp: This is actually a combined work from both Steffen and myself.
     Most of the ideas are Steffen's, as is the basic outline of
     the code, but any outstanding bugs are entirely my fault.]

Signed-off-by: Steffen Prohaska <prohaska@zib.de>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-10-12 01:13:55 -04:00
Shawn O. Pearce
85f7a94b3c git-gui: Support LFs embedded in config file values
Using the new --null option added to git-config in git 1.5.3 we
can safely accept LFs that are embedded in configuration options.
This does require a completely different configuration file parser
then the pre 1.5.3 version as we are splitting on very different
values.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-10-12 00:54:15 -04:00
Shawn O. Pearce
f00d504a6f git-gui: Refactor git-config --list parsing
The parsing for the output of `git config --list` is the same for
both the global options and the current repository's options so we
can really just use the same parser between them.

I'm currently just refactoring the parser so we can use a different
one depending on the version of git available to us at runtime.  My
next change will add support for 1.5.3's --null option.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-10-12 00:42:17 -04:00
Shawn O. Pearce
69f85ffaa2 git-gui: Move load_config procedure below git-version selection
To better handle configuration options that contain LFs in their
values we want to use the new -z option available in git-config
version 1.5.3 and later.  To configure load_config based upon the
git version we need to move thos below the git-version computation.

No logic changes yet, just a minor reordering of the code.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-10-12 00:34:04 -04:00
Johannes Sixt
a0592d3f57 git-gui: Change main window layout to support wider screens
The layout is changed to have the file lists at the left (Unstaged
Changes at the top, Staged Changes below it) and the diff window
at the right (with the commit area below it).

  +----------+---------------------+
  | Unstaged |  Diff area          |
  |          |                     |
  |          |                     |
  |          |                     |
  +----------+                     |
  | Staged   |                     |
  |          +---------------------+
  |          |  Commit area        |
  |          |                     |
  +----------+---------------------+

The advantages are:

  - The height of the file lists can be adjusted independently to
    fit the files that they contain.
  - The diff viewer is higher.

On wide screens it is ok that the main window is now generally
wider, too.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-10-12 00:14:33 -04:00
Steffen Prohaska
be700fe30f git-gui: add directory git-gui is located in to PATH (on Windows)
This commit modifies PATH to include a good guess where git
could be found. The first location to search for executable is
the directory git-gui is installed in. This is a good guess for
a sane installation.

Even if git is not available in PATH, git-gui is now able
to find it. Hence git-gui can be passed to wish as an absolute
path without caring about the environment.

We must modify PATH to be able to spawn shell based git commands.
For builtins it would be sufficient to located them and execute
them with their absolute path. But for shell based git commmands
PATH needs to be modified.

Signed-off-by: Steffen Prohaska <prohaska@zib.de>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-10-10 02:26:00 -04:00
Shawn O. Pearce
c73ce762f0 git-gui: Shorten the staged/unstaged changes title bar text
The titles for the staged and unstaged areas were usually opening
up too narrow by default, causing the text to be clipped by Tcl as
it tried to center the text in the middle of the available area.
This meant that users who were new to git-gui did not get to see
the entire header and may be unclear about what the different lists
are.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-10-10 01:12:18 -04:00
Shawn O. Pearce
13824e2df2 git-gui: Bind Cmd-, to Preferences on Mac OS X
A Mac OS X UI convention is to have Cmd-, be the accelerator key
for the preferences window, which by convention is located in the
apple menu under a separator below the about command.  We also now
call this "Preferences..." as that is the conventional term used
in English.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-10-10 01:12:18 -04:00
Shawn O. Pearce
6bdf5e5f20 git-gui: Consolidate the Fetch and Push menus into a Remote menu
Sometimes the Fetch menu looks really odd, such as if you are in a
repository that has no remotes configured when you start git-gui.
Here we didn't have any items to add to the Fetch menu so it was a
tad confusing for the end-user to see an empty menu on the menu bar.

We now place all of the commands related to fetching and pushing of
changes into a single "Remote" menu.  This way we have a better class
of bucket that we can drop additional remote related items into such
as doing a remote merge or editing the remote configuration specs.

The shortcuts to execute fetch/remote prune/push on existing remote
specifications are now actually submenus listing the remotes by name.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-10-10 01:12:17 -04:00
Shawn O. Pearce
b7d68258a3 Merge branch 'maint'
* maint:
  git-gui: accept versions containing text annotations, like 1.5.3.mingw.1
2007-10-10 01:09:41 -04:00
Steffen Prohaska
96f11953c0 git-gui: accept versions containing text annotations, like 1.5.3.mingw.1
This commit teaches git-gui to accept versions with annotations
that start with text and optionally end with a dot followed by
a number.

This is needed by the current versioning scheme of msysgit,
which uses versions like 1.5.3.mingw.1. However, the changes
is not limited to this use case. Any version of the form
<numeric version>.<anytext>.<number> would be parsed and only
the starting <numeric version> used for validation.

[sp: Minor edit to remove unnecessary group matching]

Signed-off-by: Steffen Prohaska <prohaska@zib.de>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-10-07 17:15:27 -07:00
Shawn O. Pearce
e73bfa7709 Merge branch 'maint'
* maint:
  git-gui: Don't crash when starting gitk from a browser session
  git-gui: Allow gitk to be started on Cygwin with native Tcl/Tk

Conflicts:

	git-gui.sh
2007-10-03 00:17:19 -04:00
Shawn O. Pearce
906ab7f6c0 git-gui: Don't crash when starting gitk from a browser session
If the user has started git-gui from the command line as a browser
we offer the gitk menu options but we didn't create the main status
bar widget in the "." toplevel.  Trying to access it while starting
gitk just results in Tcl errors.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-10-03 00:16:04 -04:00
Shawn O. Pearce
501e4c6f23 git-gui: Allow gitk to be started on Cygwin with native Tcl/Tk
gitk expects $env(GIT_DIR) to be valid as both a path that core Git
and Tcl/Tk can resolve to a valid directory, but it has no special
handling for Cygwin style UNIX paths and Windows style paths.  So
we need to do that for gitk and ensure that only relative paths are
fed to it, thus allowing both Cygwin style and UNIX style paths to
be resolved.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-10-03 00:14:18 -04:00
Shawn O. Pearce
0b2bc460fc git-gui: Refer to ourselves as "Git Gui" and not "git-gui"
When displaying the name of the application in window titles
and menu options (e.g. "About [appname]") we would prefer to
call ourselves "Git Gui" over "git-gui" as the former name is
now being actively used in the Mac OS X UI strings and just
plain looks better to the reader.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-09-27 22:17:01 -04:00
Shawn O. Pearce
1bdd8a1535 git-gui: Use Henrik Nyh's git logo icon on Windows systems
Rather than displaying the stock red "Tk" icon in our window
title bars and on the task bar we now show a Git specific logo.
This is Henrik Nyh's logo that we also use in the startup wizard,
scaled to a 16x16 image for Windows task bar usage with a proper
transparent background.

Signed-off-by: Shawn O. Pearce <shawn.o.pearce@bankofamerica.com>
2007-09-27 22:15:54 -04:00
Shawn O. Pearce
ab08b36304 git-gui: Allow users to choose/create/clone a repository
If we are started outside of a git repository than it is likely
the user started us from some sort of desktop shortcut icon in
the operating system.  In such a case the user is expecting us to
prompt them to locate the git repository they want to work on,
or to help them make a new repository, or to clone one from an
existing location.  This is a very simple wizard that offers the
user one of these three choices.

When we clone a repository we always use the name `master` in the
local repository, even if the remote side does not appear to point
to that name.  I chose this as a policy decision.  Much of the Git
documentation talks about `master` being the default branch in a
repository and that's what git-init does too.  If the remote side
doesn't call its default branch `master` most users just don't care,
they just want to use Git the way the documentation describes.

Rather than relying on the git-clone Porcelain that ships with
git we build the new repository ourselves and then obtain content
by git-fetch.  This technique simplifies the entire clone process
to roughly: `git init && git fetch && git pull`.  Today we use
three passes with git-fetch; the first pass gets us the bulk of
the objects and the branches, the second pass gets us the tags,
and the final pass gets us the current value of HEAD to initialize
the default branch.

If the source repository is on the local disk we try to use a
hardlink to connect the objects into the new clone as this can
be many times faster than copying the objects or packing them and
passing the data through a pipe to index-pack.  Unlike git-clone
we stick to pure Tcl [file link -hard] operation thus avoiding the
need to fork a cpio process to setup the hardlinks.  If hardlinks
do not appear to be supported (e.g. filesystem doesn't allow them or
we are crossing filesystem boundaries) we use file copying instead.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-09-23 04:57:31 -04:00
Shawn O. Pearce
a4bee59713 git-gui: Refactor some UI init to occur earlier
I'm starting to setup a main window that the user can use to
locate an existing repository, clone an existing repository,
or create a new repository from scratch.  To help do that I
want most of our common UI support already defined before we
start to look for the Git repository, this way if it was not
found we can open a window to help the user locate it.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-09-22 01:32:00 -04:00
Shawn O. Pearce
f31c14b30b Merge branch 'maint'
* maint:
  git-gui: Ensure .git/info/exclude is honored in Cygwin workdirs
  git-gui: Handle starting on mapped shares under Cygwin
  git-gui: Display message box when we cannot find git in $PATH

Conflicts:

	git-gui.sh
2007-09-21 22:03:27 -04:00
Shawn O. Pearce
2fe167b67a git-gui: Ensure .git/info/exclude is honored in Cygwin workdirs
If we are using Cygwin and the git repository is actually a
workdir (by way of git-new-workdir) but this Tcl process is
a native Tcl/Tk and not the Cygwin Tcl/Tk then we are unable
to traverse the .git/info path as it is a Cygwin symlink and
not a standard Windows directory.

So we actually need to start a Cygwin process that can do the
path translation for us and let it test for .git/info/exclude
so we know if we can include that file in our git-ls-files or
not.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-09-21 21:58:38 -04:00
Shawn O. Pearce
299077fb40 git-gui: Handle starting on mapped shares under Cygwin
I really cannot explain Cygwin's behavior here but if we start
git-gui through Cygwin on a local drive it appears that Cygwin
is leaving $env(PATH) in Unix style, even if it started a native
(non-Cygwin) Tcl/Tk process to run git-gui.  Yet starting that
same git-gui and Tcl/Tk combination through Cygwin on a network
share causes it to automatically convert $env(PATH) into Windows
style, which broke our internal "which" implementation.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-09-21 21:58:37 -04:00
Shawn O. Pearce
183a1d1496 git-gui: Display message box when we cannot find git in $PATH
If we cannot find the git executable in the user's $PATH then
we cannot function correctly.  Because we need that to get the
version so we can load our library correctly we cannot rely on
the library function "error_popup" here, as this is all running
before the library path has been configured, so error_popup is
not available to us.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-09-21 21:58:37 -04:00
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