Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions git-gui/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ install: all
$(QUIET)$(INSTALL_D0)'$(DESTDIR_SQ)$(gitexecdir_SQ)' $(INSTALL_D1)
$(QUIET)$(INSTALL_X0)git-gui $(INSTALL_X1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
$(QUIET)$(INSTALL_X0)git-gui--askpass $(INSTALL_X1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
$(QUIET)$(INSTALL_X0)git-gui--askyesno $(INSTALL_X1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
$(QUIET)$(foreach p,$(GITGUI_BUILT_INS), $(INSTALL_L0)'$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' $(INSTALL_L1)'$(DESTDIR_SQ)$(gitexecdir_SQ)/git-gui' $(INSTALL_L2)'$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' $(INSTALL_L3) &&) true
ifdef GITGUI_WINDOWS_WRAPPER
$(QUIET)$(INSTALL_R0)git-gui.tcl $(INSTALL_R1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
Expand All @@ -200,6 +201,7 @@ uninstall:
$(QUIET)$(CLEAN_DST) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui $(REMOVE_F1)
$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui--askpass $(REMOVE_F1)
$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui--askyesno $(REMOVE_F1)
$(QUIET)$(foreach p,$(GITGUI_BUILT_INS), $(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/$p $(REMOVE_F1) &&) true
ifdef GITGUI_WINDOWS_WRAPPER
$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui.tcl $(REMOVE_F1)
Expand Down
63 changes: 63 additions & 0 deletions git-gui/git-gui--askyesno
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/sh
# Tcl ignores the next line -*- tcl -*- \
exec wish "$0" -- "$@"

# This is an implementation of a simple yes no dialog
# which is injected into the git commandline by git gui
# in case a yesno question needs to be answered.
#
# The window title, which defaults to "Question?", can be
# overridden via the optional `--title` command-line
# option.

set NS {}
set use_ttk [package vsatisfies [package provide Tk] 8.5]
if {$use_ttk} {
set NS ttk
}

set title "Question?"
if {$argc < 1} {
puts stderr "Usage: $argv0 <question>"
exit 1
} else {
if {$argc > 2 && [lindex $argv 0] == "--title"} {
set title [lindex $argv 1]
set argv [lreplace $argv 0 1]
}
set prompt [join $argv " "]
}

${NS}::frame .t
${NS}::label .t.m -text $prompt -justify center -width 40
.t.m configure -wraplength 400
pack .t.m -side top -fill x -padx 20 -pady 20 -expand 1
pack .t -side top -fill x -ipadx 20 -ipady 20 -expand 1

${NS}::frame .b
${NS}::frame .b.left -width 200
${NS}::button .b.yes -text Yes -command {exit 0}
${NS}::button .b.no -text No -command {exit 1}

pack .b.left -side left -expand 1 -fill x
pack .b.yes -side left -expand 1
pack .b.no -side right -expand 1 -ipadx 5
pack .b -side bottom -fill x -ipadx 20 -ipady 15

bind . <Key-Return> {exit 0}
bind . <Key-Escape> {exit 1}

if {$::tcl_platform(platform) eq {windows}} {
set icopath [file dirname [file normalize $argv0]]
if {[file tail $icopath] eq {git-core}} {
set icopath [file dirname $icopath]
}
set icopath [file dirname $icopath]
set icopath [file join $icopath share git git-for-windows.ico]
if {[file exists $icopath]} {
wm iconbitmap . -default $icopath
}
}

wm title . $title
tk::PlaceWindow .
42 changes: 14 additions & 28 deletions git-gui/git-gui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ if {[is_Windows]} {
set _path_sep {:}
}

set _search_path {}
set _path_seen [dict create]
foreach p [split $env(PATH) $_path_sep] {
# Keep only absolute paths, getting rid of ., empty, etc.
Expand All @@ -112,12 +111,9 @@ foreach p [split $env(PATH) $_path_sep] {
}
# Keep only the first occurence of any duplicates.
set norm_p [file normalize $p]
if {[dict exists $_path_seen $norm_p]} {
continue
}
dict set _path_seen $norm_p 1
lappend _search_path $norm_p
}
set _search_path [dict keys $_path_seen]
unset _path_seen

set env(PATH) [join $_search_path $_path_sep]
Expand Down Expand Up @@ -583,21 +579,6 @@ proc open_cmd_pipe {cmd path} {
return [open |$run r]
}

proc _lappend_nice {cmd_var} {
global _nice
upvar $cmd_var cmd

if {![info exists _nice]} {
set _nice [_which nice]
if {[catch {safe_exec [list $_nice git version]}]} {
set _nice {}
}
}
if {$_nice ne {}} {
lappend cmd $_nice
}
}

proc git {args} {
git_redir $args {}
}
Expand Down Expand Up @@ -631,15 +612,14 @@ proc git_read {cmd {redir {}}} {
return [safe_open_command $cmdp $redir]
}

proc git_read_nice {cmd} {
global _git
set opt [list]

_lappend_nice opt

set cmdp [concat [list $_git] $cmd]
set _nice [list [_which nice]]
if {[catch {safe_exec [list {*}$_nice git version]}]} {
set _nice {}
}

return [safe_open_command [concat $opt $cmdp]]
proc git_read_nice {cmd} {
set cmdp [list {*}$::_nice $::_git {*}$cmd]
return [safe_open_command $cmdp]
}

proc git_write {cmd} {
Expand Down Expand Up @@ -1130,6 +1110,12 @@ set argv0dir [file dirname [file normalize $::argv0]]
if {![info exists env(SSH_ASKPASS)]} {
set env(SSH_ASKPASS) [file join $argv0dir git-gui--askpass]
}
if {![info exists env(GIT_ASKPASS)]} {
set env(GIT_ASKPASS) [file join $argv0dir git-gui--askpass]
}
if {![info exists env(GIT_ASK_YESNO)]} {
set env(GIT_ASK_YESNO) [file join $argv0dir git-gui--askyesno]
}
unset argv0dir

######################################################################
Expand Down
7 changes: 6 additions & 1 deletion git-gui/lib/index.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -425,14 +425,19 @@ proc revert_helper {txt paths} {

if {![lock_index begin-update]} return

# Workaround for Tcl < 9.0: chord namespaces are not obeyed and
# operated in the global namespace. This clears an error that could
# have been left over from a previous operation.
set ::err {}

# Common "after" functionality that waits until multiple asynchronous
# operations are complete (by waiting for them to activate their notes
# on the chord).
#
# The asynchronous operations are each indicated below by a comment
# before the code block that starts the async operation.
set after_chord [SimpleChord::new {
if {[string trim $err] != ""} {
if {[info exists err] && [string trim $err] ne ""} {
rescan_on_error $err
} else {
unlock_index
Expand Down
93 changes: 93 additions & 0 deletions gitk-git/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
Gitk - The Git Repository Browser
=================================

Gitk is a graphical Git repository browser. It displays the commit
history of a Git repository as a graph, showing the relationships
between commits, branches, and tags.

Usage
=====

To view the history of the current repository:
```bash
gitk
```

To view the history of specific files or directories:
```bash
gitk path/to/file
gitk path/to/directory
```

To view a specific branch or range of commits:
```bash
gitk branch-name
gitk v1.0..v2.0
```

For more usage examples and options, see the [gitk manual](https://git-scm.com/docs/gitk).

Building
========

Gitk is a Tcl/Tk application. It requires Tcl/Tk to be installed on
your system.

Running directly
----------------

Gitk can be run from the source directory without installation:

```bash
./gitk
```

This allows for quick testing of changes.

Installation
------------

To install system-wide, you can use either `make` or `meson`:

```bash
# Install to default location ($HOME/bin)
make install

# Install to system-wide location
sudo make install prefix=/usr/local

# Install to custom location
make install prefix=/opt/gitk

# Using Meson
meson setup builddir
meson compile -C builddir
meson install -C builddir
```

Both build systems will handle setting the correct Tcl/Tk interpreter
path and installing translation files.

Contributing
============

Contributions are welcome! The preferred method for submitting patches
is via email to the Git mailing list, as this allows for more thorough
review and broader community feedback. However, GitHub pull requests
are also accepted.

All commits must be signed off (use `git commit --signoff`) and should
have commit messages prefixed with `gitk:`.

Email Patches
-------------

Send patches to git@vger.kernel.org and CC j6t@kdbg.org. See the Git
project's [patch submission guidelines](https://git-scm.com/docs/SubmittingPatches)
for detailed instructions on creating and sending patches.

License
=======

Gitk is distributed under the GNU General Public License, either
version 2, or (at your option) any later version.
26 changes: 25 additions & 1 deletion gitk-git/gitk
Original file line number Diff line number Diff line change
Expand Up @@ -2301,6 +2301,11 @@ proc scrollval {D {koff 0}} {
return [expr int(-($D / $scroll_D0) * max(1, $kscroll-$koff))]
}

proc precisescrollval {D {koff 0}} {
global kscroll
return [expr (-($D / 10.0) * max(1, $kscroll-$koff))]
}

proc bind_mousewheel {} {
global canv cflist ctext
bindall <MouseWheel> {allcanvs yview scroll [scrollval %D] units}
Expand All @@ -2319,6 +2324,25 @@ proc bind_mousewheel {} {
bind $cflist <Alt-MouseWheel> {$cflist yview scroll [scrollval 5*%D 2] units}
bind $cflist <Alt-Shift-MouseWheel> break
bind $canv <Alt-Shift-MouseWheel> {$canv xview scroll [scrollval 5*%D] units}

bindall <TouchpadScroll> {
lassign [tk::PreciseScrollDeltas %D] deltaX deltaY
allcanvs yview scroll [precisescrollval $deltaY] units
}
bind $ctext <TouchpadScroll> {
lassign [tk::PreciseScrollDeltas %D] deltaX deltaY
$ctext yview scroll [precisescrollval $deltaY 2] units
$ctext xview scroll [precisescrollval $deltaX 2] units
}
bind $cflist <TouchpadScroll> {
lassign [tk::PreciseScrollDeltas %D] deltaX deltaY
$cflist yview scroll [precisescrollval $deltaY 2] units
}
bind $canv <TouchpadScroll> {
lassign [tk::PreciseScrollDeltas %D] deltaX deltaY
$canv xview scroll [precisescrollval $deltaX] units
allcanvs yview scroll [precisescrollval $deltaY] units
}
}
}

Expand Down Expand Up @@ -12596,7 +12620,7 @@ set foundbgcolor yellow
set currentsearchhitbgcolor orange

# button for popping up context menus
if {[tk windowingsystem] eq "aqua"} {
if {[tk windowingsystem] eq "aqua" && [package vcompare $::tcl_version 8.7] < 0} {
set ctxbut <Button-2>
} else {
set ctxbut <Button-3>
Expand Down