1
0
mirror of https://github.com/git/git.git synced 2024-10-20 12:18:36 +02:00
Commit Graph

376 Commits

Author SHA1 Message Date
Alexander Gavrilov
0ce76ded1b git-gui: Add a Tools menu for arbitrary commands.
Due to the emphasis on scriptability in the git
design, it is impossible to provide 100% complete
GUI. Currently unaccounted areas include git-svn
and other source control system interfaces, TopGit,
all custom scripts.

This problem can be mitigated by providing basic
customization capabilities in Git Gui. This commit
adds a new Tools menu, which can be configured
to contain items invoking arbitrary shell commands.

The interface is powerful enough to allow calling
both batch text programs like git-svn, and GUI editors.
To support the latter use, the commands have access
to the name of the currently selected file through
the environment.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-11-16 13:33:09 -08:00
Alexander Gavrilov
7cf4566f48 git-gui: Fix the after callback execution in rescan.
The rescan function receives a callback command
as its parameter, which is supposed to be executed
after the scan finishes. It is generally used to
update status. However, rescan may initiate a
loading of a diff, which always calls ui_ready after
completion. If the after handler is called before
that, ui_ready will override the new status.

This commit ensures that the after callback is
properly threaded through the diff machinery.

Since it uncovered the fact that force_first_diff
actually didn't work due to an undeclared global
variable, and the desired effects appeared only
because of the race condition between the diff
system and the rescan callback, I also reimplement
this function to make it behave as originally
intended.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-11-16 13:33:09 -08:00
Alexander Gavrilov
153ad78b50 git-gui: Implement system-wide configuration handling.
With the old implementation any system-wide options appear
to be set locally in the current repository. This commit
adds explicit handling of system options, essentially
interpreting them as customized default_config.

The difficulty in interpreting system options stems from
the fact that simple 'git config' lists all values, while
'git config --global' only values set in ~/.gitconfig,
excluding both local and system options.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-11-16 13:33:09 -08:00
Giuseppe Bilotta
d1f2b362b7 git-gui: try to provide a window icon under X
When running under X, we try to set up a window icon by providing a
hand-crafted 16x16 Tk photo image equivalent to the .ico. Wrap in a
catch because the earlier Tcl/Tk 8.4 releases didn't provide the 'wm
iconphoto' command.

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-11-16 13:31:41 -08:00
Alexander Gavrilov
e29c0d10a2 git-gui: Add the Show SSH Key item to the clone dialog.
The user might need to see the key before cloning a repository.
This patch makes the relevant menu item available in the Select
Repository/Clone dialog.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-11-11 09:29:36 -08:00
Alexander Gavrilov
8c76212529 git-gui: Add a simple implementation of SSH_ASKPASS.
OpenSSH allows specifying an external program to use
for direct user interaction. While most Linux systems
already have such programs, some environments, for
instance, msysgit, lack it. This patch adds a simple
fallback Tcl implementation of the tool.

In msysgit it is also necessary to set a fake value of
the DISPLAY variable, because otherwise ssh won't even
try to use SSH_ASKPASS handlers.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Acked-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-11-01 16:01:34 -07:00
Alexander Gavrilov
98a6846bb8 git-gui: Add a dialog that shows the OpenSSH public key.
Generating a new SSH key or finding an existing one may
be a difficult task for non-technical users, especially
on Windows.

This commit adds a new dialog that shows the public key,
or allows the user to generate a new one if none were found.
Since this is a convenience/informational feature for new
users, and the dialog is mostly read-only, it is located
in the Help menu.

The command line used to invoke ssh-keygen is designed to
force it to use SSH_ASKPASS if available, or accept empty
passphrases, but _never_ wait for user response on the tty.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Acked-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-11-01 16:01:23 -07:00
Alexander Gavrilov
f10d5b064a git-gui: Add a search command to the blame viewer.
One of the largest deficiencies in the blame viewer at
the moment is the impossibility to search for a text
string. This commit fixes it by adding a Firefox-like
search panel to the viewer.

The panel can be shown by pressing F7 or clicking a
menu entry, and is hidden by pressing Esc. Find Next
is available through the F3 key.

Implementation is based on the gitk code, but heavily
refactored. It now also supports case-insensitive
searches, and uses the text box background color to
signal success or failure of the search.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-10-10 09:33:21 -07:00
Petr Baudis
bb4812bc0a git-gui: gui.autoexplore makes explorer to pop up automatically after picking
Especially for Windows users used to work with the Windows Explorer,
it is very useful when after picking a repository (either opening
a local one or initializing/cloning a new one) in the "intro" window,
the explorer view of the working copy pops up along the standard
Git GUI window, so that the users can, well, actually work with
the repository.

Signed-off-by: Petr Baudis <petr.baudis@novartis.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-09-30 12:59:18 -07:00
Petr Baudis
afd5424085 git-gui: Add Explore Working Copy to the Repository menu
Especially when cloning is finished, the Git GUI window pops up,
but there is not really much one can do within it - there needs to be
a way to easily start exploring and working with the new working copy
using the standard system interface: explorer.exe on Windows, open on
MacOS/X and xdg-open as a fallback (all modern Linux desktops).

This might be also a post-clone option instead (possibly opening the window
automagically) but I believe that this might be useful also in other
situations, e.g. you don't have to keep the working copy window around
if you work in multiple repositories.

This operation will not make sense on bare repositories.

Signed-off-by: Petr Baudis <petr.baudis@novartis.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-09-30 12:59:18 -07:00
Petr Baudis
2db21e709a git-gui: Use git web--browser for web browsing
This patch removes git-gui specific webbrowser guessing and instead
relies on git web--browser to do the right thing, removing unnecessary
code duplication. New function start_browser encapsulates the browser
execution, for usage from other parts of code. This will also make
git-gui show the documentation menu item even in cases it might not
be able to start up a browser, these cases should be however only
very rare.

Signed-off-by: Petr Baudis <petr.baudis@novartis.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-09-30 12:59:18 -07:00
Petr Baudis
ba6485e05d git-gui: Add support for adding remotes
When a remote is being added, it can also be automatically either fetched
or initialized and pushed; this patch adds capability for initializing
of local and ssh repositories. This also of course leaves a lot of space
for further customization features, like individually turning the
initialization phase on/off or tuning attributes of the remote
repository; I consider that out of scope of this patch, however.

Signed-off-by: Petr Baudis <petr.baudis@novartis.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-09-30 12:59:18 -07:00
Petr Baudis
8329bd0725 git-gui: Squash populate_{push,fetch}_menu to populate_remotes_menu
The meat of the routines is now separated to add_fetch_entry() and
add_push_entry(). This refactoring will allow easy implementation of adding
individual remotes later.

Signed-off-by: Petr Baudis <petr.baudis@novartis.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-09-30 12:59:18 -07:00
Petr Baudis
3c1c2a00b2 git-gui: Clarify the Remote -> Delete... action
Currently, it was not really clear what all does this perform. We rename
"Delete..." to "Delete Branch..." (since this does not delete the remote
as a whole) and relabel the window from "Delete Remote Branch" to "Delete
Branch Remotely" (since the action also involves pushing the delete out).

Signed-off-by: Petr Baudis <petr.baudis@novartis.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-09-30 12:59:18 -07:00
Alexander Gavrilov
0aea2842d9 git-gui: Make Ctrl-T safe to use for conflicting files.
A previous patch added a check for conflict markers, which
is done when the file is about to be staged due to a click
on the icon. However, pressing Ctrl-T still immediately
stages the file without confirmation. This patch fixes it.

The check requires a loaded diff, so staging multiple files
at once won't work if they are unmerged.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-09-30 11:47:33 -07:00
Shawn O. Pearce
ed70e4d7db git-gui: Show/hide "Sign Off" based on nocommitmsg option
If citool --nocommit is invoked we hide the Sign Off features, as
the commit message area is not editable.  But we really want the
selection tied to the message area's editing ability.

Suggested-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-09-26 07:44:40 -07:00
Alexander Gavrilov
3e34838caf git-gui: Reenable staging unmerged files by clicking the icon.
This restores functionality of the file icon for unmerged files.
Safety is enforced by loading the diff and checking for lines
that look like conflict markers. If such lines are found, or
the conflict involves deletion and/or symlinks, a confirmation
dialog is presented. Otherwise, the icon immediately stages the
working copy version of the file.

Includes a revert of 2fe5b2ee42897a3acc78e5ddaace3775eb2713ca
(Restore ability to Stage Working Copy for conflicts)

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Tested-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-09-24 12:51:43 -07:00
Alexander Gavrilov
3fe0162362 git-gui: Allow forcing display encoding for diffs using a submenu.
Add a submenu to allow dynamically changing the encoding to use
for diffs. Encoding settings are remembered while git-gui runs.
The rules are:

1) Encoding set for a specific file overrides gitattributes.
2) Last explicitly set value of the encoding overrides gui.encoding

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Tested-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-09-24 12:48:32 -07:00
Alexander Gavrilov
72e6b00202 git-gui: Cleanup handling of the default encoding.
- Make diffs and blame default to the system (locale)
  encoding instead of hard-coding UTF-8.
- Add a gui.encoding option to allow overriding it.
- gitattributes still have the final word.

The rationale for this is Windows support:

1) Windows people are accustomed to using legacy encodings
   for text files. For many of them defaulting to utf-8
   will be counter-intuitive.
2) Windows doesn't support utf-8 locales, and switching
   the system encoding is a real pain. Thus the option.

This patch also adds proper encoding conversion to Apply Hunk/Line.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Tested-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-09-24 12:48:32 -07:00
Shawn O. Pearce
1ffca60f0b git-gui: Use gitattribute "encoding" for file content display
Most folks using git-gui on internationalized files have complained
that it doesn't recognize UTF-8 correctly.  In the past we have just
ignored the problem and showed the file contents as binary/US-ASCII,
which is wrong no matter how you look at it.

This really should be a per-file attribute, managed by .gitattributes,
so we now pull the "encoding" attribute data for the given path from
the .gitattributes (if available) and use that, falling back to UTF-8
if the attributes are unavailable, git-check-attr is broken, or an
encoding for this path not specified.

We apply the encoding anytime we show file content, which currently
is limited to only the diff viewer and the blame viewer.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-09-24 12:48:31 -07:00
Joshua Williams
2cd1fd1f6d git-gui: Add support for calling out to the prepare-commit-msg hook
Signed-off-by: Joshua Williams <joshua.williams@qlogic.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-09-24 12:43:00 -07:00
Shawn O. Pearce
1e02b32e72 git-gui: Hide commit related UI during citool --nocommit
If the user started git-gui as "git citool --nocommit" then they
don't need the new commit / amend commit radio buttons, or the sign
off button in the UI.  Rather than use up space with options the
user cannot activate they are simply not installed into the UI.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-09-24 09:53:35 -07:00
Alexander Gavrilov
1e65c6225d git-gui: Add more integration options to citool.
- Make citool return nonzero exit code if it did not commit.
- Add a mode where it does not actually commit and simply
  exits with zero code. Commit message is either disabled,
  or simply dumped to GITGUI_EDITMSG before exiting.
- Add an option to immediately start it in amend mode.

Rationale:

1) Use 'git citool --nocommit' instead of mergetool in scripts.
2) Use 'git citool --amend' to edit commits while rebasing.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-09-24 09:53:01 -07:00
Alexander Gavrilov
2fe5b2ee42 git-gui: Restore ability to Stage Working Copy for conflicts.
Tools like rerere leave files marked as conflicts in the index,
while actually resolving them in the working copy. Also, some
people like to use an external editor to resolve conflicts.

This patch restores functionality previously removed in
commit 617ceee653 by adding a new context menu item.
It still ensures that the user does not stage conflicting files
accidentally by clicking on the icon instead of the name.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Tested-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Shawn O. Pearce <sop@google.com>
2008-09-12 08:09:09 -07:00
Alexander Gavrilov
a9786bb42f git-gui: Fix Blame Parent & Context for working copy lines.
Make Blame Parent Commit and Show History Context work
properly for lines blamed on the working copy.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Shawn O. Pearce <sop@google.com>
2008-09-12 08:09:09 -07:00
Alexander Gavrilov
8056cc4f29 git-gui: Make F5 reselect a diff, if an untracked file is selected.
If an untracked file is selected, F5 and other manual rescan synonyms
would try to select a tracked file instead. Also, clicking on an icon
in the unstaged changes list skips over untracked files, unless the
file clicked is untracked itself.

The objective is to make it easier to ignore untracked files showing
up in the Unstaged Changes list, and ensure that no modifications
to tracked objects are left unstaged.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-09-04 21:28:55 -07:00
Alexander Gavrilov
29853b9010 git-gui: Reimplement and enhance auto-selection of diffs.
Generalize the next_diff system, and implement auto-reselection
for merge tool resolution and reshow_diff. Also add auto-selection
of diffs after rescan, if no diff is already selected.

New auto-select rules:

- Rescan auto-selects the first conflicting file, or if none
  a modified tracked file, if nothing was selected previously.
- Resolving a conflict auto-selects the nearest conflicting
  file, or nothing if everything is resolved.
- Staging the last remaining hunk auto-selects the nearest
  modified staged file.
- Staging a file through its icon auto-selects the nearest file.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-09-04 21:28:55 -07:00
Alexander Gavrilov
ff515d81fa git-gui: Support conflict states _U & UT.
Support _U (local deleted, remote modified) and
UT (file type changed in conflict) modes.

Note that 'file type changed' does not refer to
changes in the executable bit, instead it denotes
replacing a file with a link, or vice versa.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-09-04 21:28:55 -07:00
Alexander Gavrilov
617ceee653 git-gui: Don't allow staging files with conflicts.
Prevent staging files with conflict markers by clicking
on the icon in the 'Unstaged Changes' list. Instead, pretend
that the user clicked the name, and show the diff.

Originally it made some sense to allow staging conflicting
files, because git-gui did not provide any tools to resolve
them from within the GUI. But now that we have added mergetool
capabilities, it is more likely to cause accidental and
non-undoable errors.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-09-04 21:28:55 -07:00
Alexander Gavrilov
7e30682ce0 git-gui: Support calling merge tools.
Adds an item to the diff context menu in conflict mode,
which invokes a merge tool for the selected file. Tool
command-line handling code was ported from git-mergetool.

Automatic default tool selection and custom merge tools
are not supported. If merge.tool is not set, git-gui
defaults to meld.

This implementation uses a checkout-index hack in order
to retrieve all stages with autocrlf and filters properly
applied. It requires temporarily moving the original
conflict file out of the way.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-09-04 21:28:54 -07:00
Alexander Gavrilov
042c232535 git-gui: Support resolving conflicts via the diff context menu.
If the file has merge conflicts, show a special version of the
diff context menu, which includes conflict resolution commands
instead of Stage Hunk/Line. This patch only supports resolving
by discarding all sides except one.

Discarding is the only way to resolve conflicts involving symlinks
and/or deletion, excluding manual editing.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-09-04 21:28:54 -07:00
Shawn O. Pearce
961a628fdd Merge branch 'maint'
* maint:
  git-gui: Fix string escaping in po2msg.sh
  git gui: show diffs with a minimum of 1 context line

Conflicts:
	lib/option.tcl
2008-09-01 15:39:56 -07:00
Clemens Buchacher
55ba8a3474 git gui: show diffs with a minimum of 1 context line
Staging hunks without context does not work, because line number
information would have to be recomputed for individual hunks.

Since it is already possible to stage individual lines using
'Stage Line for Commit', zero context diffs are not really
necessary for git gui.

Signed-off-by: Clemens Buchacher <drizzd@aon.at>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-09-01 12:45:46 -07:00
Alexander Gavrilov
f7078b4091 git-gui: Allow specifying an initial line for git gui blame.
Add a command-line option to make git gui blame automatically
scroll to a specific line in the file. Useful for integration
with other tools.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-08-24 22:00:01 -07:00
Alexander Gavrilov
a9c80b83d4 git-gui: Support starting gitk from Gui Blame
Add a context menu command to load commits
that are within a certain time range from the
selected commit into gitk.

It can be useful for understanding of the code,
especially if the repository is imported from
a VCS that does not support atomic commits.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-08-24 22:00:01 -07:00
Gustaf Hendeby
e681cb7d6a git-gui: Teach git gui about file type changes
Signed-off-by: Gustaf Hendeby <hendeby@isy.liu.se>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-08-24 21:36:17 -07:00
Johannes Sixt
9534c9fb31 git-gui: Adapt discovery of oguilib to execdir 'libexec/git-core'
The new execdir is two levels below the root directory, while
the old execdir 'bin' was only one level below.  This commit
adapts the discovery of oguilib that uses relative paths
accordingly. We determine whether we have the extra level in the same
way in which the Makefile defines sharedir, i.e. whether the last
directory part is 'git-core'.

Inspired-by: Steffen Prohaska <prohaska@zib.de>
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-08-04 17:38:17 -07:00
Shawn O. Pearce
79317e5df1 git-gui: Fix gitk search in $PATH to work on Windows
Back in 15430be5a1 ("Look for gitk in $PATH, not $LIBEXEC/git-core")
git-gui learned to use [_which gitk] to locate where gitk's script
is as Git 1.6 will install gitk to $prefix/bin (in $PATH) and all
of the other tools are in $gitexecdir.

This failed on Windows because _which adds the ".exe" suffix as it
searches for the program on $PATH, under the assumption that we can
only execute something from Tcl if it is a proper Windows executable.

When scanning for gitk on Windows we need to omit the ".exe" suffix.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-07-29 22:41:23 -07:00
Alexander Gavrilov
7e09b1531f git-gui: Fix the Remote menu separator.
It was positioned incorrectly (offset by one position)
if the menu had a tear-off handle.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-07-27 08:08:09 -07:00
Abhijit Menon-Sen
15430be5a1 git-gui: Look for gitk in $PATH, not $LIBEXEC/git-core
Signed-off-by: Abhijit Menon-Sen <ams@toroid.org>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-07-25 14:58:31 -07:00
Alexander Gavrilov
e6131d30c2 Kill the blame back-end on window close.
Currently 'git-gui blame' does not kill its back-end
process, hoping that it will die anyway when the pipe
is closed. However, in some cases the process works
for a long time without producing any output. This
behavior results in a runaway CPU hog.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-07-16 22:09:28 -04:00
Alexander Gavrilov
57cae87b77 Add options to control the search for copies in blame.
On huge repositories, -C -C can be way too slow to be
unconditionally enabled, and it can also be useful to control
its precision.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-07-16 22:09:28 -04:00
Alexander Gavrilov
fbc0e7ac14 Fix pre-commit hooks under MinGW/MSYS
Apply the work-around for checking the executable
permission of hook files not only on Cygwin, but on
Windows in general.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-07-16 21:17:27 -04:00
Soeren Finster
af894943cb git-gui: Exit shortcut in MacOSX repaired
Now, as in all OSX apps, there is only one quit menu entry.
It's automatically in the wish menu and calls ::tk::mac::Quit when used.

Signed-off-by: Soeren Finster <sf@9by6.de>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-07-08 00:51:04 -04:00
Johannes Sixt
5821988f97 git-gui: Implement "Stage/Unstage Line"
This adds a context menu entry below "Stage/Unstage Hunk" that stages or
unstages just the line under the mouse pointer.

This is by itself useful, for example, if there are unrelated changes in
the same hunk and the hunk cannot be split by reducing the context.

The feature can also be used to split a hunk by staging a number of
additions (or unstaging a number of removals) until there are enough
context lines that the hunk gets split.

The implementation reads the complete hunk that the line lives in, and
constructs a new hunk by picking existing context lines, removing unneeded
change lines and transforming other change lines to context lines. The
resulting hunk is fed through 'git apply' just like in the "Stage/Unstage
Hunk" case.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-07-02 01:06:38 -04:00
Abhijit Menon-Sen
f531e463f0 git-gui: Don't select the wrong file if the last listed file is staged.
Johannes Sixt noticed that if the last file in the list was staged, my
earlier patch would display the diff for the penultimate file, but show
the file _before_ that as being selected.

This was due to my misunderstanding the lno argument to show_diff.

This patch fixes the problem: lno is not decremented in the special case
to handle the last item in the list (though we still need to use $lno-1
to find the right path for the next diff).

Signed-off-by: Abhijit Menon-Sen <ams@toroid.org>
Tested-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-06-25 16:55:10 -04:00
Richard Quirk
cead78edef git-gui: Fix accidental staged state toggle when clicking top pixel row
If a text widget is asked the index at x,y with y == 0 or y == 1 it will
always return 1.0 as the nearest index, regardless of the x position.

This means that clicking the top 2 pixels of the Unstaged/Staged Changes
lists caused the state of the file there to be toggled. This patch
checks that the pixel clicked is greater than 1, so there is less chance
of accidentally staging or unstaging changes.

Signed-off-by: Richard Quirk <richard.quirk@gmail.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-06-20 23:19:52 -04:00
Abhijit Menon-Sen
8a965b8ee2 git-gui: Move on to the next filename after staging/unstaging a change
Suppose the "Unstaged Changes" pane contains a list of files, and one of
them is selected (i.e., that diff is currently being displayed). If one
clicks on the icon to stage the change, git-gui clears the diff and one
has to click on another filename to see the next diff in the list.

This patch changes that behaviour. If one clicks on the icon to stage
(or unstage) the file whose diff is being displayed, git-gui will move
on to the next filename in the list and display that diff instead of a
blank diff pane. If the selected file was at the end of the list, the
diff pane will display the previous diff instead; if the selected file
was the only one listed, the diff pane will become blank.

If no diff is currently being displayed, this patch changes nothing.

Signed-off-by: Abhijit Menon-Sen <ams@toroid.org>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-06-13 17:58:00 -04:00
Shawn O. Pearce
7f83aa2d3d git-gui: Handle workdir detection when CYGWIN=nowinsymlinks
If the user has put nowinsymlinks into their CYGWIN environment
variable any symlinks created by a Cygwin process (e.g. ln -s)
will not have the ".lnk" suffix.  In this case workdir is still
a workdir, but our detection of looking for "info.lnk" fails
as the symlink is actually a normal file called "info".

Instead we just always use Cygwin's test executable to see if
info/exclude is a file.  If it is, we assume from there on it
can be read by git-ls-files --others and is thus safe to use
on the command line.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-05-22 08:34:00 -04:00
Shawn O. Pearce
16dd62ac4d git-gui: Add a --trace command line option
Often new Git users want to know what commands git-gui uses to make
changes, so they can learn the command line interface by mimicking
what git-gui does in response to GUI actions.  Showing the direct
commands being executed is easy enough to implement but this is of
little value to end-users because git-gui frequently directly calls
plumbing, not porcelain.

Since the code is already written and tested, its fairly harmless
to include.  It may not help a new end-user, but it can help with
debugging git-gui or reverse-engineering its logic to further make
changes to it or implement another GUI for Git.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-05-20 15:44:46 -04:00