Skip to content

Commit a7dc726

Browse files
committed
Sync with 'master'
2 parents afdaf0e + ab427cd commit a7dc726

6 files changed

Lines changed: 203 additions & 30 deletions

File tree

git-gui/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ install: all
186186
$(QUIET)$(INSTALL_D0)'$(DESTDIR_SQ)$(gitexecdir_SQ)' $(INSTALL_D1)
187187
$(QUIET)$(INSTALL_X0)git-gui $(INSTALL_X1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
188188
$(QUIET)$(INSTALL_X0)git-gui--askpass $(INSTALL_X1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
189+
$(QUIET)$(INSTALL_X0)git-gui--askyesno $(INSTALL_X1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
189190
$(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
190191
ifdef GITGUI_WINDOWS_WRAPPER
191192
$(QUIET)$(INSTALL_R0)git-gui.tcl $(INSTALL_R1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
@@ -200,6 +201,7 @@ uninstall:
200201
$(QUIET)$(CLEAN_DST) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
201202
$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui $(REMOVE_F1)
202203
$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui--askpass $(REMOVE_F1)
204+
$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui--askyesno $(REMOVE_F1)
203205
$(QUIET)$(foreach p,$(GITGUI_BUILT_INS), $(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/$p $(REMOVE_F1) &&) true
204206
ifdef GITGUI_WINDOWS_WRAPPER
205207
$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui.tcl $(REMOVE_F1)

git-gui/git-gui--askyesno

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/bin/sh
2+
# Tcl ignores the next line -*- tcl -*- \
3+
exec wish "$0" -- "$@"
4+
5+
# This is an implementation of a simple yes no dialog
6+
# which is injected into the git commandline by git gui
7+
# in case a yesno question needs to be answered.
8+
#
9+
# The window title, which defaults to "Question?", can be
10+
# overridden via the optional `--title` command-line
11+
# option.
12+
13+
set NS {}
14+
set use_ttk [package vsatisfies [package provide Tk] 8.5]
15+
if {$use_ttk} {
16+
set NS ttk
17+
}
18+
19+
set title "Question?"
20+
if {$argc < 1} {
21+
puts stderr "Usage: $argv0 <question>"
22+
exit 1
23+
} else {
24+
if {$argc > 2 && [lindex $argv 0] == "--title"} {
25+
set title [lindex $argv 1]
26+
set argv [lreplace $argv 0 1]
27+
}
28+
set prompt [join $argv " "]
29+
}
30+
31+
${NS}::frame .t
32+
${NS}::label .t.m -text $prompt -justify center -width 40
33+
.t.m configure -wraplength 400
34+
pack .t.m -side top -fill x -padx 20 -pady 20 -expand 1
35+
pack .t -side top -fill x -ipadx 20 -ipady 20 -expand 1
36+
37+
${NS}::frame .b
38+
${NS}::frame .b.left -width 200
39+
${NS}::button .b.yes -text Yes -command {exit 0}
40+
${NS}::button .b.no -text No -command {exit 1}
41+
42+
pack .b.left -side left -expand 1 -fill x
43+
pack .b.yes -side left -expand 1
44+
pack .b.no -side right -expand 1 -ipadx 5
45+
pack .b -side bottom -fill x -ipadx 20 -ipady 15
46+
47+
bind . <Key-Return> {exit 0}
48+
bind . <Key-Escape> {exit 1}
49+
50+
if {$::tcl_platform(platform) eq {windows}} {
51+
set icopath [file dirname [file normalize $argv0]]
52+
if {[file tail $icopath] eq {git-core}} {
53+
set icopath [file dirname $icopath]
54+
}
55+
set icopath [file dirname $icopath]
56+
set icopath [file join $icopath share git git-for-windows.ico]
57+
if {[file exists $icopath]} {
58+
wm iconbitmap . -default $icopath
59+
}
60+
}
61+
62+
wm title . $title
63+
tk::PlaceWindow .

git-gui/git-gui.sh

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ if {[is_Windows]} {
103103
set _path_sep {:}
104104
}
105105

106-
set _search_path {}
107106
set _path_seen [dict create]
108107
foreach p [split $env(PATH) $_path_sep] {
109108
# Keep only absolute paths, getting rid of ., empty, etc.
@@ -112,12 +111,9 @@ foreach p [split $env(PATH) $_path_sep] {
112111
}
113112
# Keep only the first occurence of any duplicates.
114113
set norm_p [file normalize $p]
115-
if {[dict exists $_path_seen $norm_p]} {
116-
continue
117-
}
118114
dict set _path_seen $norm_p 1
119-
lappend _search_path $norm_p
120115
}
116+
set _search_path [dict keys $_path_seen]
121117
unset _path_seen
122118

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

586-
proc _lappend_nice {cmd_var} {
587-
global _nice
588-
upvar $cmd_var cmd
589-
590-
if {![info exists _nice]} {
591-
set _nice [_which nice]
592-
if {[catch {safe_exec [list $_nice git version]}]} {
593-
set _nice {}
594-
}
595-
}
596-
if {$_nice ne {}} {
597-
lappend cmd $_nice
598-
}
599-
}
600-
601582
proc git {args} {
602583
git_redir $args {}
603584
}
@@ -631,15 +612,14 @@ proc git_read {cmd {redir {}}} {
631612
return [safe_open_command $cmdp $redir]
632613
}
633614

634-
proc git_read_nice {cmd} {
635-
global _git
636-
set opt [list]
637-
638-
_lappend_nice opt
639-
640-
set cmdp [concat [list $_git] $cmd]
615+
set _nice [list [_which nice]]
616+
if {[catch {safe_exec [list {*}$_nice git version]}]} {
617+
set _nice {}
618+
}
641619

642-
return [safe_open_command [concat $opt $cmdp]]
620+
proc git_read_nice {cmd} {
621+
set cmdp [list {*}$::_nice $::_git {*}$cmd]
622+
return [safe_open_command $cmdp]
643623
}
644624

645625
proc git_write {cmd} {
@@ -1130,6 +1110,12 @@ set argv0dir [file dirname [file normalize $::argv0]]
11301110
if {![info exists env(SSH_ASKPASS)]} {
11311111
set env(SSH_ASKPASS) [file join $argv0dir git-gui--askpass]
11321112
}
1113+
if {![info exists env(GIT_ASKPASS)]} {
1114+
set env(GIT_ASKPASS) [file join $argv0dir git-gui--askpass]
1115+
}
1116+
if {![info exists env(GIT_ASK_YESNO)]} {
1117+
set env(GIT_ASK_YESNO) [file join $argv0dir git-gui--askyesno]
1118+
}
11331119
unset argv0dir
11341120

11351121
######################################################################

git-gui/lib/index.tcl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,14 +425,19 @@ proc revert_helper {txt paths} {
425425

426426
if {![lock_index begin-update]} return
427427

428+
# Workaround for Tcl < 9.0: chord namespaces are not obeyed and
429+
# operated in the global namespace. This clears an error that could
430+
# have been left over from a previous operation.
431+
set ::err {}
432+
428433
# Common "after" functionality that waits until multiple asynchronous
429434
# operations are complete (by waiting for them to activate their notes
430435
# on the chord).
431436
#
432437
# The asynchronous operations are each indicated below by a comment
433438
# before the code block that starts the async operation.
434439
set after_chord [SimpleChord::new {
435-
if {[string trim $err] != ""} {
440+
if {[info exists err] && [string trim $err] ne ""} {
436441
rescan_on_error $err
437442
} else {
438443
unlock_index

gitk-git/README.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
Gitk - The Git Repository Browser
2+
=================================
3+
4+
Gitk is a graphical Git repository browser. It displays the commit
5+
history of a Git repository as a graph, showing the relationships
6+
between commits, branches, and tags.
7+
8+
Usage
9+
=====
10+
11+
To view the history of the current repository:
12+
```bash
13+
gitk
14+
```
15+
16+
To view the history of specific files or directories:
17+
```bash
18+
gitk path/to/file
19+
gitk path/to/directory
20+
```
21+
22+
To view a specific branch or range of commits:
23+
```bash
24+
gitk branch-name
25+
gitk v1.0..v2.0
26+
```
27+
28+
For more usage examples and options, see the [gitk manual](https://git-scm.com/docs/gitk).
29+
30+
Building
31+
========
32+
33+
Gitk is a Tcl/Tk application. It requires Tcl/Tk to be installed on
34+
your system.
35+
36+
Running directly
37+
----------------
38+
39+
Gitk can be run from the source directory without installation:
40+
41+
```bash
42+
./gitk
43+
```
44+
45+
This allows for quick testing of changes.
46+
47+
Installation
48+
------------
49+
50+
To install system-wide, you can use either `make` or `meson`:
51+
52+
```bash
53+
# Install to default location ($HOME/bin)
54+
make install
55+
56+
# Install to system-wide location
57+
sudo make install prefix=/usr/local
58+
59+
# Install to custom location
60+
make install prefix=/opt/gitk
61+
62+
# Using Meson
63+
meson setup builddir
64+
meson compile -C builddir
65+
meson install -C builddir
66+
```
67+
68+
Both build systems will handle setting the correct Tcl/Tk interpreter
69+
path and installing translation files.
70+
71+
Contributing
72+
============
73+
74+
Contributions are welcome! The preferred method for submitting patches
75+
is via email to the Git mailing list, as this allows for more thorough
76+
review and broader community feedback. However, GitHub pull requests
77+
are also accepted.
78+
79+
All commits must be signed off (use `git commit --signoff`) and should
80+
have commit messages prefixed with `gitk:`.
81+
82+
Email Patches
83+
-------------
84+
85+
Send patches to git@vger.kernel.org and CC j6t@kdbg.org. See the Git
86+
project's [patch submission guidelines](https://git-scm.com/docs/SubmittingPatches)
87+
for detailed instructions on creating and sending patches.
88+
89+
License
90+
=======
91+
92+
Gitk is distributed under the GNU General Public License, either
93+
version 2, or (at your option) any later version.

gitk-git/gitk

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2301,6 +2301,11 @@ proc scrollval {D {koff 0}} {
23012301
return [expr int(-($D / $scroll_D0) * max(1, $kscroll-$koff))]
23022302
}
23032303
2304+
proc precisescrollval {D {koff 0}} {
2305+
global kscroll
2306+
return [expr (-($D / 10.0) * max(1, $kscroll-$koff))]
2307+
}
2308+
23042309
proc bind_mousewheel {} {
23052310
global canv cflist ctext
23062311
bindall <MouseWheel> {allcanvs yview scroll [scrollval %D] units}
@@ -2319,6 +2324,25 @@ proc bind_mousewheel {} {
23192324
bind $cflist <Alt-MouseWheel> {$cflist yview scroll [scrollval 5*%D 2] units}
23202325
bind $cflist <Alt-Shift-MouseWheel> break
23212326
bind $canv <Alt-Shift-MouseWheel> {$canv xview scroll [scrollval 5*%D] units}
2327+
2328+
bindall <TouchpadScroll> {
2329+
lassign [tk::PreciseScrollDeltas %D] deltaX deltaY
2330+
allcanvs yview scroll [precisescrollval $deltaY] units
2331+
}
2332+
bind $ctext <TouchpadScroll> {
2333+
lassign [tk::PreciseScrollDeltas %D] deltaX deltaY
2334+
$ctext yview scroll [precisescrollval $deltaY 2] units
2335+
$ctext xview scroll [precisescrollval $deltaX 2] units
2336+
}
2337+
bind $cflist <TouchpadScroll> {
2338+
lassign [tk::PreciseScrollDeltas %D] deltaX deltaY
2339+
$cflist yview scroll [precisescrollval $deltaY 2] units
2340+
}
2341+
bind $canv <TouchpadScroll> {
2342+
lassign [tk::PreciseScrollDeltas %D] deltaX deltaY
2343+
$canv xview scroll [precisescrollval $deltaX] units
2344+
allcanvs yview scroll [precisescrollval $deltaY] units
2345+
}
23222346
}
23232347
}
23242348
@@ -12596,7 +12620,7 @@ set foundbgcolor yellow
1259612620
set currentsearchhitbgcolor orange
1259712621
1259812622
# button for popping up context menus
12599-
if {[tk windowingsystem] eq "aqua"} {
12623+
if {[tk windowingsystem] eq "aqua" && [package vcompare $::tcl_version 8.7] < 0} {
1260012624
set ctxbut <Button-2>
1260112625
} else {
1260212626
set ctxbut <Button-3>

0 commit comments

Comments
 (0)