Code

git.git
15 years agogitk: Provide a window icon if possible
Giuseppe Bilotta [Thu, 19 Mar 2009 08:54:17 +0000 (01:54 -0700)]
gitk: Provide a window icon if possible

Try to set up a 16x16 Tk photo image (based on the git logo) and use
it as window icon.  The code is wrapped in a catch because it may fail
in earlier Tcl/Tk 8.4 releases that don't provide 'wm iconphoto'.

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Signed-off-by: Stephen Boyd <bebarino@gmail.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Handle blobs containing a DOS end-of-file marker
Pat Thoyts [Mon, 16 Mar 2009 10:24:40 +0000 (10:24 +0000)]
gitk: Handle blobs containing a DOS end-of-file marker

If a patchset contains an EOF marker (Ctrl-Z) the blob diff terminates
at that point.  This permits gitk to ignore the eof and continue to
display any subsequent blobs and also displays a sensible representation
of the eof char.

Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Fix possible infinite loop and display corruption
Paul Mackerras [Sun, 1 Mar 2009 22:38:17 +0000 (09:38 +1100)]
gitk: Fix possible infinite loop and display corruption

This fixes an issue reported by Johannes Sixt on the git mailing list:

> This recipe sends gitk into an endless loop. In git.git do:
>
> cd t
> # remove chmod a+x A near the end of the file
> sed -i 's/chmod/: chmod/' t3400-rebase.sh
> sh t3400-rebase.sh --debug
> cd trash\ directory.t3400-rebase/
> gitk master modechange modechange@{1}
>
>
> I briefly see the history chart, but the dot that should be modechange@{1}
> is missing. One automatically selected commit is shown in the diff section
> below. But then the commit list is cleared and gitk goes into an infinite
> loop.
>
> Things work alright if either modechange@{1} is dropped, or the 'chmod'
> line is left unchanged, which is a bit strange.
>
> This is with git version 1.6.1.2.390.gba743

There were actually two problems.  This recipe created a situation where
git log would output a child commit after its parent.  This meant that
we called fix_reversal which called splitvarc, which should call modify_arc
to note the fact that it has modified the arc that it has just split.  It
wasn't, which meant that displayorder and other variables got into an
inconsistent state (a commit appearing twice in displayorder).

This then meant that the targetrow/targetid logic in drawvisible thought
it need to redraw each time.  That, together with the fact that drawvisible
called drawcommits which called drawvisible if a redraw was needed, led
to the infinite loop.

In fact drawvisible is now the only caller of drawcommits.  Thus, the
start and end row arguments to drawcommits always encompass the whole
visible area, so drawcommits doesn't need to call drawvisible to redraw;
it just needs to clear the screen and draw what it's been asked to.

This fixes these two problems by adding a call to modify_arc in
splitvarc and by taking out the call to drawvisible in drawcommits.
It also removes an unrelated left-over debugging puts in external_blame.

Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Force the focus to the main window on Windows
Johannes Sixt [Thu, 18 Dec 2008 07:30:49 +0000 (08:30 +0100)]
gitk: Force the focus to the main window on Windows

On msysGit, the focus is first on the (Tk) console.  This console is then
hidden, but keeps the focus.  Work around that by forcing the focus onto
the gitk window.

This fixes msysGit issue 14.  Diagnosed and originally fixed by
Johannes Schindelin.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Allow unbalanced quotes/braces in commit headers
Kevin Ballard [Thu, 18 Dec 2008 09:26:48 +0000 (01:26 -0800)]
gitk: Allow unbalanced quotes/braces in commit headers

When parsing commits, gitk treats the headers of the commit as tcl
lists.  This causes errors if the header contains an unbalanced quote
or open brace.  Splitting the line on spaces allows us to treat it as
a set of words instead of as a tcl list, which prevents errors.

Signed-off-by: Kevin Ballard <kevin@sb.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Update German translation
Christian Stimming [Sat, 6 Dec 2008 19:49:24 +0000 (20:49 +0100)]
gitk: Update German translation

Attached to avoid whitespace problems.

Regards,

Christian

From 282060ac531fee722142f9d39c4ff29570723cbb Mon Sep 17 00:00:00 2001
From: Christian Stimming <stimming@tuhh.de>
Date: Sat, 6 Dec 2008 20:47:15 +0100
Subject: [PATCH 2/2] gitk: Update German translation

Merged with most recent "make update-po" result.

Signed-off-by: Christian Stimming <stimming@tuhh.de>
Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Mark forgotten strings (header sentence parts in color chooser) for translation
Christian Stimming [Sat, 6 Dec 2008 19:48:30 +0000 (20:48 +0100)]
gitk: Mark forgotten strings (header sentence parts in color chooser) for translation

Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Ensure that "Reset branch" menu entry is enabled
Johannes Sixt [Wed, 3 Dec 2008 12:43:20 +0000 (13:43 +0100)]
gitk: Ensure that "Reset branch" menu entry is enabled

Consider this sequence of events:

1. Detach HEAD and fire up gitk
2. Call the context menu on some commit. Notice that the last menu entry
   says "Detached HEAD: can't reset" and it is disabled.
3. Now checkout some regular branch (e.g. 'master') using the context menu.
4. Call the context menu again on some commit.

Previously, at this point the last menu entry said "Reset master branch
to here", but it was still disabled. With this fix it is now enabled again.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Use check-buttons' -text property instead of separate labels
Johannes Sixt [Tue, 2 Dec 2008 20:42:16 +0000 (21:42 +0100)]
gitk: Use check-buttons' -text property instead of separate labels

Previously the check-buttons' labels in the Preferences were separate
widgets.  This had the disadvantage that in order to toggle the
check-button with the mouse the check-box had to be clicked.  With
this change the check-box can also be toggled by clicking the label.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Map / to focus the search box
Giuseppe Bilotta [Tue, 2 Dec 2008 01:19:22 +0000 (02:19 +0100)]
gitk: Map / to focus the search box

The / key is often used to initiate searches (less, vim, some web
browsers).  This changes the binding for the / (slash) key from 'find
next' to 'focus the search box' to follow this convention.

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Fix bugs in blaming code
Paul Mackerras [Sat, 6 Dec 2008 10:44:05 +0000 (21:44 +1100)]
gitk: Fix bugs in blaming code

The "show origin of this line" function wasn't working when gitk was
run in a subdirectory, since it passed the path relative to the
top-level directory to git blame.  This fixes it by passing the
absolute path to the file instead of the relative path.

The same problem occurs when running git gui blame, except that
git gui blame appears not to be able to accept an absolute path to the
file, so we make a relative path using a new [make_relative] function.

Finally, this fixes a bug in [show_line_source] where we weren't
setting id, resulting in an error when trying to find the origin of
a line in the fake commit for local changes not checked in, when its
parent was a real commit (i.e. there were no changes checked in).

Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Add a menu option to start git gui
Alexander Gavrilov [Thu, 13 Nov 2008 20:12:42 +0000 (23:12 +0300)]
gitk: Add a menu option to start git gui

Git gui already has menu commands to start gitk, and this makes the
relation symmetric.

[paulus@samba.org - changed "Git Gui" in the menu item to "git gui"]

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Make line origin search update the busy status
Alexander Gavrilov [Mon, 1 Dec 2008 17:30:09 +0000 (20:30 +0300)]
gitk: Make line origin search update the busy status

Currently the 'show origin of this line' feature does not update the
status field of the gitk window, so it is not evident that any
processing is going on.  It may seem at first that clicking the item
had no effect.

This commit adds calls to set and clear the busy status with an
appropriate title, similar to other search commands.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Update German translation
Christian Stimming [Sat, 25 Oct 2008 11:25:35 +0000 (13:25 +0200)]
gitk: Update German translation

This takes into account the most recent po file merge.

Signed-off-by: Christian Stimming <stimming@tuhh.de>
Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Fix bug in accessing undefined "notflag" variable
Paul Mackerras [Mon, 1 Dec 2008 22:17:46 +0000 (09:17 +1100)]
gitk: Fix bug in accessing undefined "notflag" variable

As pointed out by Johannes Sixt and Alexander Gavrilov, commit
2958228430b63f2e38c55519d1f98d8d6d9e23f3 ("gitk: Fix switch statement
in parseviewargs") exposed a latent bug in that $notflag was never
initialized.  Since it isn't used either, this removes it entirely.

Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Highlight only when search type is "containing:".
Paul Mackerras [Mon, 1 Dec 2008 22:02:46 +0000 (09:02 +1100)]
gitk: Highlight only when search type is "containing:".

When the search type is "touching paths" or "adding/removing string",
it's not very useful to highlight instances of the search string in
the commit message, headline or author name, so this disables the
highlighting in those cases.

This was suggested by Mark Burton <markb@ordern.com>, but the
implementation is different to his patch, which tested $gdttype at
each place where $markingmatches was tested.

Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Restore scrolling position of diff pane on back/forward in history
Paul Mackerras [Sun, 23 Nov 2008 02:14:23 +0000 (13:14 +1100)]
gitk: Restore scrolling position of diff pane on back/forward in history

This arranges to save the scrolling position of the diff display pane
when we move from displaying one thing to another, and then scroll the
pane to the same position when we go back to the previous thing using
the back or forward buttons.  This works if we have clicked on a commit
and are in patch display mode, or if we have clicked on a line or a tag,
or have done a diff between two commits with the context menu.  It
doesn't currently restore the pane to where it was if is was displaying
a commit in tree display mode.

For future extensibility, addtohistory now takes an extra optional
argument which is a script to invoke when moving from this thing to
another.  The script needs to return a list of pairs of variable name
and value.  If we go back to this thing, the godo procedure will set
the named variables to the values given.  At present that is just used
to store the $ctext scrolling position, but in future we will use it
to store the state of which directories are open in the file list pane.

Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Fix context menu items for generating diffs when in tree mode
Paul Mackerras [Tue, 18 Nov 2008 10:40:32 +0000 (21:40 +1100)]
gitk: Fix context menu items for generating diffs when in tree mode

Currently, if you invoke the "diff this -> selected" or "diff selected
-> this" and gitk is in "Tree" mode rather than "Patch" mode, the
diff display pane will just show the header but not the actual diff,
unless gitk has done the diff before and thus has the list of files
that differ.  This was because the logic in gettreediffline that
checked whether we had moved on to doing something else checked the
mode (Tree or Patch) before checking whether the ids we're diffing
had changed.

This fixes it.  The new logic in gettreediffline is slightly hacky
and relies on the fact that the Tree/Patch mode only applies when
we're looking at a single commit, not at the diff between two commits.

Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Avoid handling the Return key twice in Add Branch
Alexander Gavrilov [Thu, 13 Nov 2008 20:09:18 +0000 (23:09 +0300)]
gitk: Avoid handling the Return key twice in Add Branch

This reverts commit 63767d5fb8fe236d8fdeba44297ac925701b27a0.

A similar change was made as part of commit 76f15947af7, that added
bindings to all dialogs, and this duplication causes mkbrgo to be
called twice, the second time after the window has been destroyed.
As a result, an error window appears when the code tries to access
widgets.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Show local changes properly when we have a path limit
Paul Mackerras [Tue, 18 Nov 2008 08:54:14 +0000 (19:54 +1100)]
gitk: Show local changes properly when we have a path limit

Since gitk looks for the HEAD commit to attach the fake commits for
local changes to, we can miss out on seeing the fake commits if we
have a path limit and the HEAD commit doesn't alter any of the files
in the path limit.

This fixes it by running

git rev-list -1 $head -- $paths

if we have a path limit, and taking the result of that as the commit
to attach the fake commits to.  This means that we can be attaching
the fake commits to a different commit in each view, so we use a new
$viewmainhead($view) for that.

This also fixes a buglet where updatecommits would only fix up the
fake commits if the HEAD changed since the last call to updatecommits,
whereas it should fix them up if the HEAD has changed since this view
was last created or updated.

Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Fix switch statement in parseviewargs
Paul Mackerras [Tue, 18 Nov 2008 08:44:20 +0000 (19:44 +1100)]
gitk: Fix switch statement in parseviewargs

In Tcl, a comment in a switch command where a pattern would be expected
doesn't do what one would expect, so this moves the comments inside the
actions.  Doing that shows up an extra "-" which this also removes.

With this, --merge is now handled properly.

Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Index line[hnd]tag arrays by id rather than row number
Paul Mackerras [Thu, 13 Nov 2008 12:01:46 +0000 (23:01 +1100)]
gitk: Index line[hnd]tag arrays by id rather than row number

This simplifies things a bit and is better because ids are stable
but row numbers aren't.  It also means we can avoid one [rowofcommit]
call.

Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Fix linehtag undefined error with file highlighting
Paul Mackerras [Thu, 13 Nov 2008 11:39:00 +0000 (22:39 +1100)]
gitk: Fix linehtag undefined error with file highlighting

Occasionally gitk will throw a Tcl error complaining that linehtag(n)
is undefined when.  It happens when the commit list is still growing
(e.g. when updating the commit list) and gitk is set to highlight
commits that affect certain file(s).  What happens is that the changes
to the commit list set need_redisplay to indicate that the display
needs to be redrawn.  That causes the next call to drawcommits to call
clear_display, which unsets iddrawn and thus ensures that readfhighlight
won't call bolden on any rows that have moved.  However, it is possible
for readfhighlight to be called after the commit list has changed but
before drawcommits has run, meaning that readfhighlight will potentially
think that rows have been drawn when they haven't, because of the
change in the id -> row mapping (and the fact that iddrawn is indexed
by id but line[hnd]tag are indexed by row number).

This fixes it (and also optimizes things a little) by making bolden
and bolden_name check need_redisplay before doing anything.  If
need_redisplay is set, then there is no point doing anything because
the whole display is about to get cleared and redrawn, and it avoids
looking up line[hn]tag using stale row numbers.

Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Fix commit encoding support
Alexander Gavrilov [Sun, 9 Nov 2008 15:06:07 +0000 (18:06 +0300)]
gitk: Fix commit encoding support

This commit fixes two problems with commit encodings:

1) git-log actually uses i18n.logoutputencoding to generate
   its output, and falls back to i18n.commitencoding only
   when that option is not set.  Thus, gitk should use its
   value to read the results, if available.

2) The readcommit function did not process encodings at all.
   This led to randomly appearing misconverted commits if
   the commit encoding differed from the current locale.

Now commit messages should be displayed correctly, except
when logoutputencoding is set to an encoding that cannot
represent charecters in the message.  For example, it is
impossible to convert Japanese characters from Shift-JIS
to CP-1251 (although the reverse conversion works).

The reason for using git log to read the commit and then getting
Tcl to convert its output is that is essentially what happens in
the normal path through getcommitlines, hence there is less chance
for unintended differences in how commits are processed in
getcommitlines and do_readcommit.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Fix transient windows on Win32 and MacOS
Alexander Gavrilov [Tue, 11 Nov 2008 20:55:42 +0000 (23:55 +0300)]
gitk: Fix transient windows on Win32 and MacOS

Transient windows cause problems on these platforms:

- On Win32 the windows appear in the top left corner
  of the screen. In order to fix it, this patch causes
  them to be explicitly centered on their parents by
  an idle handler.

- On MacOS with Tk 8.4 they appear without a title bar.
  Since it is clearly unacceptable, this patch disables
  transient on that platform.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Add accelerators to frequently used menu commands
Alexander Gavrilov [Sun, 9 Nov 2008 10:00:45 +0000 (13:00 +0300)]
gitk: Add accelerators to frequently used menu commands

This commit documents keyboard accelerators used for menu
commands in the menu, as it is usually done, and adds some
more, e.g. F4 to invoke Edit View (or New View if the current
view is the un-editable "All files" view).

The changes include a workaround for handling Shift-F4 on
systems where XKB binds special XF86_Switch_VT_* symbols
to Ctrl-Alt-F* combinations.  Tk often receives these codes
when Shift-F* is pressed, so it is necessary to bind the
relevant actions to them as well.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agoMerge branch 'dev'
Paul Mackerras [Sun, 9 Nov 2008 11:05:50 +0000 (22:05 +1100)]
Merge branch 'dev'

15 years agogitk: Implement a user-friendly Edit View dialog
Alexander Gavrilov [Sun, 2 Nov 2008 18:59:48 +0000 (21:59 +0300)]
gitk: Implement a user-friendly Edit View dialog

Originally gitk required the user to specify all limiting
options manually in the same field with the list of commits.
It is rather unfriendly for new users, who may not know
which options can be used, or, indeed, that it is possible
to specify them at all.

This commit modifies the dialog to present the most useful
options as individual fields.  Note that options that may
be useful to an extent, but produce a severely broken view,
are deliberately not included.

It is still possible to specify options in the commit list
field, but when the dialog is reopened, they will be extracted
into their own separate fields.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Improve cherry-pick error handling
Paul Mackerras [Sat, 8 Nov 2008 10:37:09 +0000 (21:37 +1100)]
gitk: Improve cherry-pick error handling

This adds to the regexps that are used to work out what sort of error
we encountered in trying to do a cherry-pick so that it recognizes
some additional common error messages.  It adds a confirmation dialog
when the error is a merge conflict so the user can choose whether or
not to run git citool.  Finally, it arranges to update the display
after a cherry-pick failed so that any local changes made by the
cherry-pick become visible.

Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Make cherry-pick call git-citool on conflicts
Alexander Gavrilov [Sun, 2 Nov 2008 18:59:47 +0000 (21:59 +0300)]
gitk: Make cherry-pick call git-citool on conflicts

Now that git-gui has facilities to help users resolve
conflicts, it makes sense to launch it from other GUI
tools when they happen.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Make gitk dialog windows transient
Alexander Gavrilov [Sun, 2 Nov 2008 18:59:45 +0000 (21:59 +0300)]
gitk: Make gitk dialog windows transient

Transient windows are always kept above their parent, and don't occupy
any space in the taskbar, which is useful for dialogs.  Also, when
transient is used, it is important to bind windows to the correct
parent.

This commit adds transient annotations to all dialogs, ensures usage
of the correct parent for error and confirmation popups, and, as a
side job, makes gitk preserve the create tag dialog window in case of
errors.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Add Return and Escape bindings to dialogs
Alexander Gavrilov [Sun, 2 Nov 2008 18:59:44 +0000 (21:59 +0300)]
gitk: Add Return and Escape bindings to dialogs

It is often more convenient to dismiss or accept a dialog using the
keyboard, than by clicking buttons on the screen.  This commit adds
key binding to make it possible with gitk's dialogs.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Cope with unmerged files in local changes
Paul Mackerras [Tue, 4 Nov 2008 10:09:00 +0000 (21:09 +1100)]
gitk: Cope with unmerged files in local changes

This modifies gettreediffline so that it when we get both a "U" line
and an "M" line for the same file in the output from git diff-files
or git diff-index --cached (used when the user clicks on a fake commit)
we don't add the same filename to the treediff list twice.

This also makes getblobdiffline recognize the "* Unmerged path ..."
lines we get when we ask for the actual diffs, and makes a tiny
optimization in makediffhdr.

Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Make "show origin of this line" work on fake commits
Paul Mackerras [Tue, 4 Nov 2008 01:57:44 +0000 (12:57 +1100)]
gitk: Make "show origin of this line" work on fake commits

This makes the "Show origin of this line" menu item work correctly
on the fake commits that gitk shows for local uncommitted changes.
With the fake commit for changes that aren't checked in to the index,
we can actually get a 3-way diff shown, which means we might have to
blame either the parent or the commit being merged in (which we get
from .git/MERGE_HEAD).

If the parent is the fake commit which shows the changes that have
been checked in to the index, then we need to get the SHA1 of the blob
for the version of the file that is in the index, then use git cat-file
blob to get the contents of the blob, and give that to git blame with --contents - so that git blame will do the blame on the index version
of the file.  In that case, we might get the all-zeroes SHA1 back from
git blame, meaning that the line is new in the index version of the
file, so then we have to use $nullid2 (the pseudo-SHA1 of the fake
commit for the checked-in changes).

Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Unify handling of merge diffs with normal 2-way diffs
Paul Mackerras [Sun, 2 Nov 2008 11:34:47 +0000 (22:34 +1100)]
gitk: Unify handling of merge diffs with normal 2-way diffs

This adds code to getblobdiffline to make it able to recognize and
display merge diffs (i.e. N-way diffs for N >= 3) as well as normal
two-way diffs.  This means that it can also correctly display the
3-way diff of the local changes when the git repository is in the
middle of a merge with conflicts.

This also removes getmergediffline and changes mergediff to invoke
getblobdiffline rather than getmergediffline.

Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Make the background color of marked lines configurable
Paul Mackerras [Mon, 27 Oct 2008 11:37:21 +0000 (22:37 +1100)]
gitk: Make the background color of marked lines configurable

This makes it possible for the user to configure the background color
of lines that are "marked".  At the moment only the "show the origin
of this line" function marks lines.  This also makes the user's choice
persistent by saving it in ~/.gitk.

Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Add a menu item to show where a given line comes from
Paul Mackerras [Mon, 27 Oct 2008 10:36:25 +0000 (21:36 +1100)]
gitk: Add a menu item to show where a given line comes from

This adds a menu item to the pop-up menu for the diff display window
which makes gitk find which commit added the line (via git blame)
and show that commit, with the line highlighted with a light-blue
background.

Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Fix some off-by-one errors in computing which line to blame
Paul Mackerras [Mon, 27 Oct 2008 10:13:37 +0000 (21:13 +1100)]
gitk: Fix some off-by-one errors in computing which line to blame

When walking back from the line where a right-click happened to the
previous hunk separator line to calculate the line number to work on,
we were counting every line including the one clicked on.  That isn't
right; if the user clicked on the line immediately after the hunk
separator then the correct line number would be the one from the
hunk separator.  Therefore this looks at the clicked-on line to work
out which parent to blame (or whether to blame the current commit),
and then looks only at the preceding lines to work out the offset from
the line number in the hunk separator.

This also fixes an off-by-one error when we are showing files rather
than diffs.  In this case diff_menu_filebase is the line number of
the banner showing the file name, so the first line of the file is
at line $diff_menu_filebase + 1.

This also simplifies the code in find_hunk_blamespec a bit and arranges
that we don't pop up the context menu if the user clicks on a file
separator line or a hunk separator line.

Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Allow starting gui blame for a specific line
Alexander Gavrilov [Fri, 24 Oct 2008 08:13:01 +0000 (12:13 +0400)]
gitk: Allow starting gui blame for a specific line

This adds a context menu item to the diff viewer pane that calls git
gui blame, focusing it on the clicked line.  In case of combined
diffs, it also automatically deduces which parent is to be blamed.
Lines added by the diff are blamed on the current commit itself.

The context menu itself is added by this patch.  It would be possible
to add the commands from the flist menu to it.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Fix file list context menu for merge commits
Alexander Gavrilov [Wed, 8 Oct 2008 07:05:37 +0000 (11:05 +0400)]
gitk: Fix file list context menu for merge commits

Currently it displays an ugly error box, because the treediffs array
is not filled for such commits.  This fixes it by making
getmergediffline add the filenames it sees to the treediffs array
like gettreediffline does.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Allow forcing branch creation if it already exists
Alexander Gavrilov [Wed, 8 Oct 2008 07:05:35 +0000 (11:05 +0400)]
gitk: Allow forcing branch creation if it already exists

If gitk knows that the branch the user tries to create exists,
it should ask whether it should overwrite it.  This way the user
can either decide to choose a new name, or move the head while
preserving the reflog.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Turn short SHA1 names into links too
Paul Mackerras [Mon, 20 Oct 2008 23:18:12 +0000 (10:18 +1100)]
gitk: Turn short SHA1 names into links too

This changes the link detection logic to accept strings of between 6
and 40 hex characters as a possible SHA1 ID of another commit, rather
than insisting on seeing the full 40 hex characters.

To make the logic that turns a possible link into an actual link work
with abbreviated IDs, this changes the way the commitinterest array is
used, and puts the code that deals with it in a pair of new functions.
The commitinterest array is now indexed by just the first 4 characters
of the interesting SHA1 ID, and each element is a list of id + command
pairs.  This also pulls out the logic for expanding an abbreviated
SHA1 to the list of matching full IDs into its own function (the way
it is done is still the same slow way it was done before, which should
be improved some day).

This also fixes the bug where clicking on a link would take you to the
wrong commit if the line number of the target had changed since the
link was made.

This is based on a patch by Linus Torvalds, but totally rewritten by me.

Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Regenerate .po files
Paul Mackerras [Sat, 18 Oct 2008 05:24:46 +0000 (16:24 +1100)]
gitk: Regenerate .po files

This is the result of running make update-po and removing or fixing
the strings that were fuzzily matched.  The ones that were fixed were
the ones where the only change was "git rev-list" to "git log", and
the "about gitk" message where the copyright year got updated.

To get xgettext to see the menu labels as needing translation, it
was necessary for arrange for them to be preceded by "mc".  This
therefore changes makemenu to ignore the first element in each
menu item so that it can be "mc" in the makemenu call.

Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: New way of constructing menus that allows for Alt+letter accelerators
Paul Mackerras [Fri, 17 Oct 2008 11:44:42 +0000 (22:44 +1100)]
gitk: New way of constructing menus that allows for Alt+letter accelerators

This is inspired by patches from Robin Rosenberg but takes a different
approach.  This adds a "makemenu" procedure for constructing menus
that allows the menu layout to be specified in a clear fashion, and
provides one place where the alt+letter accelerators can be detected
and handled.

The alt+letter accelerator is specified by putting an ampersand (&)
before the letter for the accelerator in the menu item name.  (Two
ampersands in succession produce one ampersand in the menu item as
it appears on screen.)  This is handled in makemenu.

We also add an mca procedure which is like mc but also does the
ampersand translation, for use when we want to refer to a menu item
by name.  The mca name and the locations where we use it were
shamelessly stolen from Robin Rosenberg's patch.

This doesn't actually add any alt+letter accelerators yet.

Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Bind Key-Return to create on new branch dialog
Richard Quirk [Tue, 14 Oct 2008 20:53:25 +0000 (22:53 +0200)]
gitk: Bind Key-Return to create on new branch dialog

The Return key can now be used as well as pressing the Create button
from the dialog box that is shown when selecting "Create new branch".

Signed-off-by: Richard Quirk <richard.quirk@gmail.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Fix binding for <Return> in sha1 entry field
Paul Mackerras [Wed, 15 Oct 2008 22:57:02 +0000 (09:57 +1100)]
gitk: Fix binding for <Return> in sha1 entry field

This adds a break so that gitk doesn't go and execute the global
binding for <Return> (i.e. find next) when the user presses the
return key in the sha1 entry field to indicate that gitk should
jump to the commit identified by what they just put into the
sha1 field.

Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Clean up file encoding code and add enable/disable option
Paul Mackerras [Wed, 15 Oct 2008 11:23:03 +0000 (22:23 +1100)]
gitk: Clean up file encoding code and add enable/disable option

This adds an option allowing the user to select whether gitk should
look up per-file encoding settings using git check-attr or not.  If
not, gitk uses the global encoding set in the git config (as reported
by git config --get gui.encoding) for all files, or if that is not
set, then the system encoding.

The option is controlled by a checkbox in the Edit->Preferences
window, and defaults to off for now because git check-attr is so
slow.  When the user turns it on we discard any cached diff file
lists in treediffs, because we may not have encodings cached for
the files listed in those lists, meaning that getblobdiffline will
do it for each file, which will be really really slow.

This adjusts the limit of how many paths cache_gitattr passes to each
instance of git check-attr depending on whether we're running under
windows or not.  Passing only 30 doesn't effectively amortize the
startup costs of git check-attr, but it's all we can do under windows
because of the 32k limit on arguments to a command.  Under other OSes
we pass up to 1000.

Similarly we adjust how many lines gettreediffline processes depending
on whether we are doing per-file encodings so that we don't run for
too long.  When we are, 500 seems to be a reasonable limit, leading
to gettreediffline taking about 60-70ms under Linux (almost all of
which is in cache_gitattr, unfortunately).  This means that we can
take out the update call in cache_gitattr.

This adds a simple cache on [tclencoding].  Now that we get repeated
calls to translate the same encoding, this is useful.

This reindents the new code added in the last couple of commits to
conform to the gitk 4-space indent and makes various other improvements:
use regexp in gitattr and cache_gitattr instead of split + join + regsub,
make gui_encoding be the value from [tclencoding] to avoid having to
do [tcl_encoding $gui_encoding] in each call to get_path_encoding,
and print a warning message at startup if $gui_encoding isn't
supported by Tcl.

Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Implement batch lookup and caching of encoding attrs
Alexander Gavrilov [Mon, 13 Oct 2008 08:12:33 +0000 (12:12 +0400)]
gitk: Implement batch lookup and caching of encoding attrs

When the diff contains thousands of files, calling git-check-attr once
per file is very slow.  With this patch gitk does attribute lookup in
batches of 30 files while reading the diff file list, which leads to a
very noticeable speedup.

It may be possible to reimplement this even more efficiently, if
git-check-attr is modified to support a --stdin-paths option.
Additionally, it should quote the ':' character in file paths, or
provide a more robust way of column separation.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Tested-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Enhance file encoding support
Alexander Gavrilov [Mon, 13 Oct 2008 08:12:31 +0000 (12:12 +0400)]
gitk: Enhance file encoding support

This allows the encoding to be specified for file contents and used
when displaying files and diffs in the bottom-left pane.  When
displaying diffs, the encoding for each diff hunk is that for the file
that the diff hunk is from, so it can change through the course of the
diff.

The encoding for file contents is determined as follows:

- File encoding defaults to the system encoding.
- It can be overridden by setting the gui.encoding option.
- Finally, the 'encoding' attribute is checked on
  per-file basis; it has the last word.

Note: Since git-check-attr does not provide support for reading
attributes from trees, attribute lookup is done using files from the
working directory.

This also extends the range of supported encoding names, adding
ShiftJIS and Shift-JIS as aliases for Shift_JIS, and allowing
cp-*, cp_*, ibm-*, ibm_*, jis-* and jis_* as aliases for cp*,
ibm* and jis* respectively.

This also fixes some bugs in handling of non-ASCII filenames.  Core
git apparently supports only locale-encoded filenames, so processing
is done using the system encoding.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Tested-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Add untranslated error messages to translation
Christian Stimming [Fri, 12 Sep 2008 09:39:43 +0000 (11:39 +0200)]
gitk: Add untranslated error messages to translation

Signed-off-by: Christian Stimming <stimming@tuhh.de>
Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Fix a bug in collapsing deeply nested trees
Alexander Gavrilov [Mon, 8 Sep 2008 07:28:16 +0000 (11:28 +0400)]
gitk: Fix a bug in collapsing deeply nested trees

To reproduce: expand a tree like this, then collapse A:

+A
 +B
   C
   D

The result is:

-A
   C
   D

I.e. sub-nodes expanded from the last sub-node of the item
being collapsed are not removed.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Use <Button-2> for context menus on OSX
Paul Mackerras [Sun, 21 Sep 2008 23:11:37 +0000 (18:11 -0500)]
gitk: Use <Button-2> for context menus on OSX

An OSX user has reported that gitk's context menus are not usable
under OSX because it doesn't provide a way to generate <Button-3>
events.  Users can generate <Button-2> events with command+click,
so use that for the context menus instead on OSX.

Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Add menu item for calling git gui blame
Alexander Gavrilov [Sat, 23 Aug 2008 08:29:08 +0000 (12:29 +0400)]
gitk: Add menu item for calling git gui blame

This adds a new item to the file list popup menu, that calls git gui
blame for the selected file, starting with the first parent of the
current commit.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Add option to specify the default commit on command line
Alexander Gavrilov [Sat, 23 Aug 2008 08:27:44 +0000 (12:27 +0400)]
gitk: Add option to specify the default commit on command line

Other GUI tools may need to start gitk and make it automatically
select a certain commit.  This adds a new command-line option
--select-commit=id to make that possible.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Allow safely calling nukefile from a run queue handler
Alexander Gavrilov [Sat, 9 Aug 2008 10:41:50 +0000 (14:41 +0400)]
gitk: Allow safely calling nukefile from a run queue handler

Originally dorunq assumed that the queue entry remained first
in the queue after the script eval, and blindly removed it.
However, if the handler calls nukefile, it may not be the
case anymore, and a random queue entry gets dropped instead.

This makes dorunq remove the entry before calling the
script, and adds a global variable to allow other functions
to determine if they are called from within a dorunq handler.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Update swedish translation.
Mikael Magnusson [Sun, 3 Aug 2008 17:04:21 +0000 (19:04 +0200)]
gitk: Update swedish translation.

Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Updated German translation
Christian Stimming [Sat, 24 May 2008 20:42:30 +0000 (22:42 +0200)]
gitk: Updated German translation

This includes suggestions by Stephan Beyer.

Signed-off-by: Christian Stimming <stimming@tuhh.de>
Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Fallback to selecting the head commit upon load
Alexander Gavrilov [Sat, 26 Jul 2008 16:15:54 +0000 (20:15 +0400)]
gitk: Fallback to selecting the head commit upon load

Try selecting the head, if the previously selected commit
is not available in the new view.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Fixed automatic row selection during load
Alexander Gavrilov [Sat, 26 Jul 2008 16:13:45 +0000 (20:13 +0400)]
gitk: Fixed automatic row selection during load

- Switching views now actually preserves the selected commit.
- Reloading (also Edit View) preserves the currently selected commit.
- Initial selection does not produce weird scrolling.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Fixed broken exception handling in diff
Alexander Gavrilov [Sat, 26 Jul 2008 14:48:41 +0000 (18:48 +0400)]
gitk: Fixed broken exception handling in diff

If the tree diff command failed to start for some
random reason, treepending remained set, and thus
no more diffs were shown after that.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: On Windows, use a Cygwin-specific flag for kill
Alexander Gavrilov [Mon, 14 Jul 2008 20:35:42 +0000 (00:35 +0400)]
gitk: On Windows, use a Cygwin-specific flag for kill

MSysGit compiles git binaries as native Windows executables,
so they cannot be killed unless a special flag is specified.

This flag is implemented by the Cygwin version of kill,
which is also included in MSysGit.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Arrange to kill diff-files & diff-index on quit
Alexander Gavrilov [Sun, 13 Jul 2008 12:40:47 +0000 (16:40 +0400)]
gitk: Arrange to kill diff-files & diff-index on quit

Local change analysis can take a noticeable amount of time on large
file sets, and produce no output if there are no changes.  Register
the back-ends in commfd, so that they get properly killed on window
close.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Kill back-end processes on window close
Alexander Gavrilov [Sat, 12 Jul 2008 12:09:28 +0000 (16:09 +0400)]
gitk: Kill back-end processes on window close

When collecting commits for a rarely changed, or recently
created file or directory, rev-list may work for a noticeable
period of time without producing any output.  Such processes
don't receive SIGPIPE for a while after gitk is closed, thus
becoming runaway CPU hogs.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Handle detached heads better
Paul Mackerras [Mon, 26 May 2008 00:11:33 +0000 (10:11 +1000)]
gitk: Handle detached heads better

This draws the currently checked-out head with a yellow circle, as
suggested by Linus Torvalds, and fixes various places in the code
where we assumed that the current head always had a branch.  Now we
can display the fake commits for local changes on a detached head.

Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Fix bug introduced by "gitk: Fix "wrong # coordinates" error on reload"
Paul Mackerras [Thu, 22 May 2008 11:12:19 +0000 (21:12 +1000)]
gitk: Fix bug introduced by "gitk: Fix "wrong # coordinates" error on reload"

Commit 94503a66c56c935e77a8fbe3622f1f56b7134ccc ("gitk: Fix "wrong #
coordinates" error on reload") was correct as far as it went, but
introduced a problem because it didn't also clear out boldrows and
boldnamerows in clear_display.  This resulted in Tcl errors after
scrolling through the graph for a while if some rows were highlighted.
This fixes it.

Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Fix bug where current row number display stops working
Paul Mackerras [Tue, 20 May 2008 10:51:06 +0000 (20:51 +1000)]
gitk: Fix bug where current row number display stops working

The display of the current row number would stop working if the user
clicked on a line, or if selectedline got unset for any other reason,
because the trace on it got lost when it was unselected.  This fixes
it by changing the places that unset selectedline to set it to the
empty string instead, and the places that tested for it being set or
unset to compare it with the empty string.  Thus it never gets unset
now.  This actually simplified the code in a few places since it can
be compared for equality with a row number now without first testing
if it is set.

Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Move es.po where it belongs
Michele Ballabio [Sat, 17 May 2008 17:16:31 +0000 (19:16 +0200)]
gitk: Move es.po where it belongs

Signed-off-by: Michele Ballabio <barra_cuda@katamail.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
15 years agogitk: Fix "wrong # coordinates" error on reload
Paul Mackerras [Sun, 18 May 2008 23:48:45 +0000 (09:48 +1000)]
gitk: Fix "wrong # coordinates" error on reload

This fixes the Tk error "wrong # coordinates: expected 0 or 4, got 2"
that sometimes occurred when reloading.  The problem was that we didn't
unset the variables containing the canvas item id numbers for the
displayed rows when we cleared the canvases.  Thus make_secsel would
think it had something to do when it didn't.

Thanks to Michele Ballabio for finding a way to trigger the bug
reliably.

Signed-off-by: Paul Mackerras <paulus@samba.org>
16 years agogitk: Add a progress bar for checking out a head
Paul Mackerras [Mon, 12 May 2008 00:18:38 +0000 (10:18 +1000)]
gitk: Add a progress bar for checking out a head

Now that git checkout reports progress when checking out files, we
can use that to provide a progress bar in gitk.  We re-use the green
progress bar (formerly used when reading stuff in) for that.

Signed-off-by: Paul Mackerras <paulus@samba.org>
16 years agogitk: Show current row number and total number of rows
Paul Mackerras [Sun, 11 May 2008 12:13:02 +0000 (22:13 +1000)]
gitk: Show current row number and total number of rows

This adds a couple of fields in the bar just below the upper panes
that show the row number of the currently selected commit, and how
many rows are displayed in total.  The latter increments as commits
are read in, and thus functions to show that progress is being made.
This therefore also removes the code that showed progress using a
green oscillating bar in the progress bar window (which some people
disliked).

Signed-off-by: Paul Mackerras <paulus@samba.org>
16 years agoMerge branch 'master' into dev
Paul Mackerras [Sun, 11 May 2008 00:50:14 +0000 (10:50 +1000)]
Merge branch 'master' into dev

16 years agogitk: Allow users to view diffs in external diff viewer
Thomas Arcila [Mon, 24 Mar 2008 11:55:36 +0000 (12:55 +0100)]
gitk: Allow users to view diffs in external diff viewer

This allows gitk to run an external diff viewer such as meld.

Right-click on a file in the file list view gives "External diff"
popup menu entry, which launches the selected external diff tool.
The menu entry is only active in "Patch" mode, not in "Tree" mode.

The program to run to display the diff is configurable through
Edit/Preference/External diff tool.  The program is run with two
arguments, being the names of files containing the two versions to
diff.  Gitk will create temporary directories called
.gitk-tmp.<pid>/<n> to place these files in, and remove them when
it's finished.

If the file doesn't exist in one or other revision, gitk will supply
/dev/null as the name of the file on that side of the diff.  This may
need to be adjusted for Windows or MacOS.

[paulus@samba.org - cleaned up and rewrote some parts of the patch.]

Signed-off-by: Thomas Arcila <thomas.arcila@gmail.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
16 years agogitk: Synchronize highlighting in file view for 'f' and 'b' commands
Paul Mackerras [Sat, 10 May 2008 03:15:36 +0000 (13:15 +1000)]
gitk: Synchronize highlighting in file view for 'f' and 'b' commands

This is based on a patch by Eric Raible <raible@gmail.com>, but does
things a bit more simply.

Previously, 'b', backspace, and delete all did the same thing.
This changes 'b' to perform the inverse of 'f'.  And both of
them now highlight the filename of the currently diff.

This makes it easier to review and navigate the diffs associated
with a particular commit using only f, b, and space because the
filename of the currently display diff will be dynamically
highlighted.

Signed-off-by: Paul Mackerras <paulus@samba.org>
16 years agogitk: Make updates go faster
Paul Mackerras [Fri, 9 May 2008 00:14:07 +0000 (10:14 +1000)]
gitk: Make updates go faster

This goes back to the method of doing updates where we translate the
revisions we're given to SHA1 ids and then remove the ones we've asked
for before or that we've already come across.  This speeds up updates
enormously in most cases since it means git log doesn't have to traverse
large parts of the tree.  We used to do this, but it had bugs, and commit
468bcaedbb1589f16955e63b6bfba01c2f53e433 (gitk: Don't filter view
arguments through git rev-parse) went to the slower method to avoid the
bugs.

In order to do this properly, we have to parse the command line and
understand all the flag arguments.  So this adds a parser that checks
all the flag arguments.  If there are any we don't know about, we
disable the optimization and just pass the whole lot to git log
(except for -d/--date-order, which we remove from the list).

With this we can then use git rev-parse on the non-flag arguments to
work out exactly what SHA1 ids are included and excluded in the list,
which then enables us to ask for just the new ones when updating.
One wrinkle is that we have to turn symmetric diff arguments (of the
form a...b) back into symmetric diff form so that --left-right still
works, as git rev parse turns a...b into a b ^merge_base(a,b).

This also updates a couple of copyright notices.

Signed-off-by: Paul Mackerras <paulus@samba.org>
16 years agogitk: Disable "Reset %s branch to here" when on a detached head
Michele Ballabio [Fri, 2 May 2008 15:46:20 +0000 (17:46 +0200)]
gitk: Disable "Reset %s branch to here" when on a detached head

When we are on a detached head - since gitk does not display where
we are - reset has no sense, so disable the relevant line on the
context menu, and point out to the user that we are on a detached head.

Otherwise, a reset from gitk when on a detached head returns the
error:

can't read "headids()": no such element in array
can't read "headids()": no such element in array
    while executing
"removehead $headids($name) $name"
    (procedure "movehead" line 4)
    invoked from within
"movehead $newhead $mainhead"
    (procedure "readresetstat" line 20)
    invoked from within
"readresetstat file4"
    ("eval" body line 1)
    invoked from within
"eval $script"
    (procedure "dorunq" line 9)
    invoked from within
"dorunq"
    ("after" script)

[paulus@samba.org: changed menu item to "Detached head: can't reset"]

Signed-off-by: Michele Ballabio <barra_cuda@katamail.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
16 years agogitk: German translation again updated
Christian Stimming [Fri, 2 May 2008 19:33:34 +0000 (21:33 +0200)]
gitk: German translation again updated

This includes suggestions by Stephan Beyer.

Signed-off-by: Christian Stimming <stimming@tuhh.de>
Signed-off-by: Paul Mackerras <paulus@samba.org>
16 years agogitk: Update German translation
Christian Stimming [Thu, 1 May 2008 19:38:37 +0000 (21:38 +0200)]
gitk: Update German translation

Signed-off-by: Christian Stimming <stimming@tuhh.de>
Signed-off-by: Paul Mackerras <paulus@samba.org>
16 years agogitk: Makefile/install: force permissions when installing files and dirs
Gerrit Pape [Mon, 14 Apr 2008 08:27:09 +0000 (08:27 +0000)]
gitk: Makefile/install: force permissions when installing files and dirs

The msg-files msgs/*.msg used to be installed with mode 755 although
they're not executables.  With this commit, files are forced to be
installed with mode 644, directories and executables with mode 755.

Signed-off-by: Paul Mackerras <paulus@samba.org>
16 years agogitk: Initial Swedish translation.
Peter Karlsson [Fri, 14 Mar 2008 15:13:17 +0000 (16:13 +0100)]
gitk: Initial Swedish translation.

Signed-off-by: Paul Mackerras <paulus@samba.org>
16 years agogitk: Spanish translation of gitk
Santiago Gala [Tue, 25 Mar 2008 10:48:22 +0000 (11:48 +0100)]
gitk: Spanish translation of gitk

I copied the Italian translation and translated the strings
to Spanish starting from there.  This incorporates suggestions
from Wincent Colaiuta and Carlos Rica.

Signed-off-by: Santiago Gala <sgala@apache.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
16 years agogitk: Fix handling of tree file list with special chars in names
Paul Mackerras [Sun, 27 Apr 2008 23:40:50 +0000 (09:40 +1000)]
gitk: Fix handling of tree file list with special chars in names

Alex Riesen pointed out that displaying a commit in 'tree' mode fails
if some files have names with special characters such as '{' or '}' in
them, due to the fact that we treat the line returned from git ls-tree
as a Tcl list at one point.

This fixes it by doing what I originally intended but didn't quite
get right.  We split the line from git ls-tree at the first tab and
treat the part before the tab as a list (which is OK since it doesn't
have special characters in it) and the part after the tab as the
filename.

Signed-off-by: Paul Mackerras <paulus@samba.org>
16 years agogitk: Reorganize processing of arguments for git log
Paul Mackerras [Sat, 26 Apr 2008 06:00:00 +0000 (16:00 +1000)]
gitk: Reorganize processing of arguments for git log

This moves the scanning of the argument list for each view into a
new function, parseviewargs, which is called from start_rev_list.
This also makes the date mode and the merge mode be per-view rather
than global.  In merge mode, we work out the list of relevant files
in a new function called from start_rev_list, so it will be updated
on File->Reload.  Plus we now do that after running the argscmd, so
if we have one and it generates a -d or --merge option they will be
correctly handled now.

The other thing this does is to make errors detected in start_rev_list
not be fatal.  Now instead of doing exit 1 we just pop up and error
window and put "No commits selected" in the graph pane.

Signed-off-by: Paul Mackerras <paulus@samba.org>
16 years agogitk: Fix changing colors through Edit->Preferences
Gerrit Pape [Wed, 26 Mar 2008 18:45:26 +0000 (18:45 +0000)]
gitk: Fix changing colors through Edit->Preferences

With tcl/tk8.5 the lset command seems to behave differently.  When
changing the background color through Edit->Preferences, the changes
are applied, but new dialogs, such as View->New view... barf with

 Error: unknown color name "{#ffffff}"

Additionally when closing gitk, and starting it up again, a bad value
has been saved to ~/.gitk, preventing gitk from running properly; it
fails with

 Error in startup script: unknown color name "{#ffffff}"
 ...

This commit fixes the problem by changing the color dialogs to pass
the empty string {} as the list index to choosecolor.  This causes
the lset and lindex commands used by choosecolor to use and set the
whole variable (bgcolor, fgcolor or selectbgcolor) rather than
treating them as a 1-element list.  Tested with tcl/tk8.4 and 8.5.

Dmitry Potapov reported this problem through
 http://bugs.debian.org/472615

Signed-off-by: Gerrit Pape <pape@smarden.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
16 years agogitk: initial Italian translation
Michele Ballabio [Thu, 13 Mar 2008 16:46:30 +0000 (17:46 +0100)]
gitk: initial Italian translation

Signed-off-by: Michele Ballabio <barra_cuda@katamail.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
16 years agogitk: Default to using po2msg.sh if msgfmt doesn't grok --tcl, -l and -d
Paul Mackerras [Fri, 14 Mar 2008 09:24:31 +0000 (20:24 +1100)]
gitk: Default to using po2msg.sh if msgfmt doesn't grok --tcl, -l and -d

This is a similar change to that submitted by Junio C Hamano for
git-gui.  It tests whether the msgfmt command can be run successfully
with --tcl, -l and -d, and if not, falls back to using po/po2msg.sh.

Signed-off-by: Paul Mackerras <paulus@samba.org>
16 years agoMerge branch 'master' into dev
Paul Mackerras [Tue, 11 Mar 2008 11:21:39 +0000 (22:21 +1100)]
Merge branch 'master' into dev

16 years agogitk: Avoid Tcl error when switching views
Paul Mackerras [Tue, 11 Mar 2008 11:11:19 +0000 (22:11 +1100)]
gitk: Avoid Tcl error when switching views

Michele Ballabio <barra_cuda@katamail.com> pointed out that gitk
sometimes throws a Tcl error (can't read "yscreen") when switching
views, and proposed a patch.  This is a different way of fixing it
which is a bit neater.  Basically, in showview we only set yscreen if
the selected commit is on screen to start with, and then we only
scroll the canvas to bring it onscreen if yscreen is set and the
same commit exists in the new view.

Signed-off-by: Paul Mackerras <paulus@samba.org>
16 years ago[PATCH] gitk: Don't show local changes when we there is no work tree
David Aguilar [Mon, 10 Mar 2008 10:54:56 +0000 (03:54 -0700)]
[PATCH] gitk: Don't show local changes when we there is no work tree

Launching gitk on a bare repository or a .git directory
would previously show the work tree as having removed all
files.  We now inhibit showing local changes when gitk
is not launched from within a work tree.

Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
16 years ago[PATCH] gitk: Add horizontal scrollbar to the diff view
Pekka Kaitaniemi [Sat, 8 Mar 2008 12:27:23 +0000 (14:27 +0200)]
[PATCH] gitk: Add horizontal scrollbar to the diff view

Adding horizontal scroll bar makes the scrolling feature more
discoverable to the users.  The horizontal scrollbar is a bit narrower
than vertical ones so we don't make too big impact on available screen
real estate.  The text and scrollbar widget layout is done using grid
geometry manager.

An interesting side effect of Tk scrollbars is that the "elevator"
size changes depending on the visible content. So the horizontal
scrollbar "elevator" changes as the user scrolls the view up and down.

Signed-off-by: Pekka Kaitaniemi <kaitanie@cc.helsinki.fi>
Signed-off-by: Paul Mackerras <paulus@samba.org>
16 years ago[PATCH] gitk: make autoselect optional
Jeff King [Thu, 6 Mar 2008 11:49:25 +0000 (06:49 -0500)]
[PATCH] gitk: make autoselect optional

Whenever a commit is selected in the graph pane, its SHA1 is
automatically put into the selection buffer for cut and paste.
However, some users may find this behavior annoying since it can
overwrite something they actually wanted to keep in the buffer.

This makes the behavior optional under the name "Auto-select SHA1",
but continues to default to "on".

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Paul Mackerras <paulus@samba.org>
16 years ago[PATCH] gitk: Mark another string for translation
Michele Ballabio [Mon, 3 Mar 2008 20:12:47 +0000 (21:12 +0100)]
[PATCH] gitk: Mark another string for translation

Signed-off-by: Michele Ballabio <barra_cuda@katamail.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
16 years ago[PATCH] Add an --argscmd flag to get the list of refs to show
Yann Dirson [Thu, 21 Feb 2008 20:23:31 +0000 (21:23 +0100)]
[PATCH] Add an --argscmd flag to get the list of refs to show

This allows gitk to be used to display a different set of refs each
the display is refreshed.  This is useful when gitk is called from
other porcelain suites, for doing such things as displaying the set of
patches in a patch stack.

The user specifies a command as the argument to the --argscmd option.
The command is run initially and each time the display is refreshed,
and is expected to generate a list of commit IDs, one per line.  Those
commits are appended to the commits passed on the command-line when
constructing the git log command to be executed.

The command is considered to be an attribute of a view, and has its
own field in the saved view, and an edit field in the view editor.

Signed-off-by: Yann Dirson <ydirson@altern.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
16 years agogitk: Only restore window size from ~/.gitk, not position
Paul Mackerras [Mon, 10 Mar 2008 05:50:34 +0000 (16:50 +1100)]
gitk: Only restore window size from ~/.gitk, not position

This also limits the window size to the screen size.  That is better
than nothing, but it isn't perfect, since ideally we would take into
account window decorations, and things such as gnome panels or the
Mac OS X dock and menu bar, but I don't know how to do that.

On Cygwin this is as good as restoring the whole geometry (size and
position) at working around the Cygwin Tk bugs, according to Mark
Levedahl.

Tested-by: Mark Levedahl <mlevedahl@gmail.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
16 years agogitk: Fix problem with target row not being in scroll region
Paul Mackerras [Fri, 7 Mar 2008 11:51:55 +0000 (22:51 +1100)]
gitk: Fix problem with target row not being in scroll region

Since we limit the rate at which we do updates to the canvas scrolling
regions, it's possible to get into selectline for a row that is
outside the currently-set scrolling region.  When this happens,
selectline can't scroll to show the selected line, and as a
consequence, drawvisible chooses some other bogus row to be the
target row.

This fixes it by calling setcanvscroll from selectline in this case.
We also set selectedline (and currentid) before calling drawvisible
so that drawvisible makes the right choice of target row.

Signed-off-by: Paul Mackerras <paulus@samba.org>
16 years agogitk: Avoid a crash in selectline if commitinfo($id) isn't set
Paul Mackerras [Fri, 7 Mar 2008 10:19:18 +0000 (21:19 +1100)]
gitk: Avoid a crash in selectline if commitinfo($id) isn't set

Occasionally I see a crash in selectline with commitinfo($id) not
set.  This makes sure it is set by calling getcommit $id if it isn't.

Signed-off-by: Paul Mackerras <paulus@samba.org>
16 years agogitk: Fix some corner cases in computing vrowmod and displayorder
Paul Mackerras [Tue, 4 Mar 2008 10:32:38 +0000 (21:32 +1100)]
gitk: Fix some corner cases in computing vrowmod and displayorder

First, insertfakerow and removefakerow weren't updating vrowmod,
and hence displayorder was not getting updated when it needed to,
in the case where the fake row was being inserted into or removed
from the last arc.  The comparison of varctok vs vtokmod was moved
into modify_arc for these cases (and for the call in rewrite_commit)
to avoid duplicating the extra code needed.  Second, the logic in
update_arcrows didn't end up truncating displayorder and unsetting
cached_commitrow if the first modified row was in the last arc.
This fixes these problems.

Signed-off-by: Paul Mackerras <paulus@samba.org>
16 years agogitk: Correct a few strings and comments to say "git log"
Paul Mackerras [Tue, 4 Mar 2008 10:14:17 +0000 (21:14 +1100)]
gitk: Correct a few strings and comments to say "git log"

... instead of "git rev-list", since we now use git log for
generating the list of commits.

Signed-off-by: Paul Mackerras <paulus@samba.org>
16 years agogitk: Don't filter view arguments through git rev-parse
Paul Mackerras [Sun, 2 Mar 2008 23:19:35 +0000 (10:19 +1100)]
gitk: Don't filter view arguments through git rev-parse

Previously we passed the arguments indicating what commits the user
wants to view through git rev-parse to get a list of IDs (positive and
negative), then gave that to git log.  This had a couple of problems,
notably that --merge and --left-right didn't get handled properly.

Instead we now just pass the original arguments to git log.  When doing
an update, we append --not followed by the list of commits we have seen
that have no children, since we have got (or will get) their ancestors
from the first git log.  If the first git log isn't finished yet, we
might get some duplicates from the second git log, but that doesn't
cause any problem.

Also get rid of the unused vnextroot variable.

Signed-off-by: Paul Mackerras <paulus@samba.org>
16 years agogitk: Fix problems with target row stuff
Paul Mackerras [Sun, 2 Mar 2008 23:11:08 +0000 (10:11 +1100)]
gitk: Fix problems with target row stuff

Occasionally the target row stuff would scroll the display to some
uninteresting commit while reading.  There were two problems: one
was that drawvisible would set targetrow even if there was no target
previously and no row selected, and the other was that it was possible
for the target row to get pushed down past numcommits, if drawvisible
was called after rows were added but before layoutmore got run.

The first problem is fixed by just not setting targetrow/id unless
there is a selected row or they were set previously.

The second problem is fixed by updating numcommits immediately new
rows are added.  This leads to a simplification of layoutmore and
chewcommits but also means that some of the things that were done in
layoutmore now need to be done elsewhere, since layoutmore can no
longer use numcommits to know how much it has seen previously.
Hence the changes to getcommits, initlayout and setcanvscroll.

Signed-off-by: Paul Mackerras <paulus@samba.org>
16 years agogitk: Handle updating with path limiting better
Paul Mackerras [Sun, 24 Feb 2008 01:16:56 +0000 (12:16 +1100)]
gitk: Handle updating with path limiting better

When updating the graph, gitk uses a git log command with commit
limiting in order to get just the new commits.  When path limiting
is also in effect, git log rewrites the parents of the commits it
outputs in order to represent just the subgraph that modifies the
listed paths, but it doesn't rewrite the parents on the boundary
of the graph.  The result is that when updating, git log does not
give gitk the information about where the new commits join in to
the existing graph.

This solves the problem by explicitly rewriting boundary parents
when updating.  If we are updating and are doing path limiting,
then when gitk finds an unlisted commit (one where git log puts a
"-" in front of the commit ID to indicate that it isn't actually
part of the graph), then gitk will execute:

    git rev-list --first-parent --max-count=1 $id -- paths...

which returns the first ancestor that affects the listed paths.
(Currently gitk executes this synchronously; it could do it
asynchronously, which would be more complex but would avoid the
possibility of the UI freezing up if git rev-list takes a long time.)

Then, if the result is a commit that we know about, we rewrite the
parents of the children of the original commit to point to the new
commit.  That is mostly a matter of adjusting the parents and children
arrays and calling fix_reversal to fix up the graph.

Signed-off-by: Paul Mackerras <paulus@samba.org>