Skip to content

Commit bb20d7c

Browse files
committed
Merge branch 'gitk-and-git-gui-patches'
These are Git for Windows' Git GUI and gitk patches. We will have to decide at some point what to do about them, but that's a little lower priority (as Git GUI seems to be unmaintained for the time being, and the gitk maintainer keeps a very low profile on the Git mailing list, too). Signed-off-by: Johannes Schindelin <[email protected]>
2 parents b38c072 + 531aab7 commit bb20d7c

File tree

4 files changed

+125
-35
lines changed

4 files changed

+125
-35
lines changed

git-gui/Makefile

+2
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ install: all
293293
$(QUIET)$(INSTALL_D0)'$(DESTDIR_SQ)$(gitexecdir_SQ)' $(INSTALL_D1)
294294
$(QUIET)$(INSTALL_X0)git-gui $(INSTALL_X1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
295295
$(QUIET)$(INSTALL_X0)git-gui--askpass $(INSTALL_X1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
296+
$(QUIET)$(INSTALL_X0)git-gui--askyesno $(INSTALL_X1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
296297
$(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
297298
ifdef GITGUI_WINDOWS_WRAPPER
298299
$(QUIET)$(INSTALL_R0)git-gui.tcl $(INSTALL_R1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
@@ -311,6 +312,7 @@ uninstall:
311312
$(QUIET)$(CLEAN_DST) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
312313
$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui $(REMOVE_F1)
313314
$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui--askpass $(REMOVE_F1)
315+
$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui--askyesno $(REMOVE_F1)
314316
$(QUIET)$(foreach p,$(GITGUI_BUILT_INS), $(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/$p $(REMOVE_F1) &&) true
315317
ifdef GITGUI_WINDOWS_WRAPPER
316318
$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui.tcl $(REMOVE_F1)

git-gui/git-gui--askyesno

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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+
set NS {}
10+
set use_ttk [package vsatisfies [package provide Tk] 8.5]
11+
if {$use_ttk} {
12+
set NS ttk
13+
}
14+
15+
set title "Question?"
16+
if {$argc < 1} {
17+
puts stderr "Usage: $argv0 <question>"
18+
exit 1
19+
} else {
20+
if {$argc > 2 && [lindex $argv 0] == "--title"} {
21+
set title [lindex $argv 1]
22+
set argv [lreplace $argv 0 1]
23+
}
24+
set prompt [join $argv " "]
25+
}
26+
27+
${NS}::frame .t
28+
${NS}::label .t.m -text $prompt -justify center -width 400px
29+
.t.m configure -wraplength 400px
30+
pack .t.m -side top -fill x -padx 20 -pady 20 -expand 1
31+
pack .t -side top -fill x -ipadx 20 -ipady 20 -expand 1
32+
33+
${NS}::frame .b
34+
${NS}::frame .b.left -width 200
35+
${NS}::button .b.yes -text Yes -command yes
36+
${NS}::button .b.no -text No -command no
37+
38+
39+
pack .b.left -side left -expand 1 -fill x
40+
pack .b.yes -side left -expand 1
41+
pack .b.no -side right -expand 1 -ipadx 5
42+
pack .b -side bottom -fill x -ipadx 20 -ipady 15
43+
44+
bind . <Key-Return> {exit 0}
45+
bind . <Key-Escape> {exit 1}
46+
47+
proc no {} {
48+
exit 1
49+
}
50+
51+
proc yes {} {
52+
exit 0
53+
}
54+
55+
if {$::tcl_platform(platform) eq {windows}} {
56+
set icopath [file dirname [file normalize $argv0]]
57+
if {[file tail $icopath] eq {git-core}} {
58+
set icopath [file dirname $icopath]
59+
}
60+
set icopath [file dirname $icopath]
61+
set icopath [file join $icopath share git git-for-windows.ico]
62+
if {[file exists $icopath]} {
63+
wm iconbitmap . -default $icopath
64+
}
65+
}
66+
67+
wm title . $title
68+
tk::PlaceWindow .

git-gui/git-gui.sh

+11-1
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,11 @@ proc git_write {args} {
623623
}
624624
625625
proc githook_read {hook_name args} {
626-
set pchook [gitdir hooks $hook_name]
626+
if {[package vcompare $::_git_version 2.5.0] >= 0} {
627+
set pchook [git rev-parse --git-path "hooks/$hook_name"]
628+
} else {
629+
set pchook [gitdir hooks $hook_name]
630+
}
627631
lappend args 2>@1
628632
629633
# On Windows [file executable] might lie so we need to ask
@@ -1233,6 +1237,12 @@ set have_tk85 [expr {[package vcompare $tk_version "8.5"] >= 0}]
12331237
if {![info exists env(SSH_ASKPASS)]} {
12341238
set env(SSH_ASKPASS) [gitexec git-gui--askpass]
12351239
}
1240+
if {![info exists env(GIT_ASKPASS)]} {
1241+
set env(GIT_ASKPASS) [gitexec git-gui--askpass]
1242+
}
1243+
if {![info exists env(GIT_ASK_YESNO)]} {
1244+
set env(GIT_ASK_YESNO) [gitexec git-gui--askyesno]
1245+
}
12361246
12371247
######################################################################
12381248
##

gitk-git/gitk

+44-34
Original file line numberDiff line numberDiff line change
@@ -2099,7 +2099,7 @@ proc makewindow {} {
20992099
global headctxmenu progresscanv progressitem progresscoords statusw
21002100
global fprogitem fprogcoord lastprogupdate progupdatepending
21012101
global rprogitem rprogcoord rownumsel numcommits
2102-
global have_tk85 use_ttk NS
2102+
global have_tk85 have_tk86 use_ttk NS
21032103
global git_version
21042104
global worddiff
21052105

@@ -2597,8 +2597,13 @@ proc makewindow {} {
25972597
bind . <Key-Down> "selnextline 1"
25982598
bind . <Shift-Key-Up> "dofind -1 0"
25992599
bind . <Shift-Key-Down> "dofind 1 0"
2600-
bindkey <Key-Right> "goforw"
2601-
bindkey <Key-Left> "goback"
2600+
if {$have_tk86} {
2601+
bindkey <<NextChar>> "goforw"
2602+
bindkey <<PrevChar>> "goback"
2603+
} else {
2604+
bindkey <Key-Right> "goforw"
2605+
bindkey <Key-Left> "goback"
2606+
}
26022607
bind . <Key-Prior> "selnextpage -1"
26032608
bind . <Key-Next> "selnextpage 1"
26042609
bind . <$M1B-Home> "allcanvs yview moveto 0.0"
@@ -7709,7 +7714,7 @@ proc gettreeline {gtf id} {
77097714
if {[string index $fname 0] eq "\""} {
77107715
set fname [lindex $fname 0]
77117716
}
7712-
set fname [encoding convertfrom $fname]
7717+
set fname [encoding convertfrom utf-8 $fname]
77137718
lappend treefilelist($id) $fname
77147719
}
77157720
if {![eof $gtf]} {
@@ -7971,7 +7976,7 @@ proc gettreediffline {gdtf ids} {
79717976
if {[string index $file 0] eq "\""} {
79727977
set file [lindex $file 0]
79737978
}
7974-
set file [encoding convertfrom $file]
7979+
set file [encoding convertfrom utf-8 $file]
79757980
if {$file ne [lindex $treediff end]} {
79767981
lappend treediff $file
79777982
lappend sublist $file
@@ -8116,7 +8121,7 @@ proc makediffhdr {fname ids} {
81168121
global ctext curdiffstart treediffs diffencoding
81178122
global ctext_file_names jump_to_here targetline diffline
81188123

8119-
set fname [encoding convertfrom $fname]
8124+
set fname [encoding convertfrom utf-8 $fname]
81208125
set diffencoding [get_path_encoding $fname]
81218126
set i [lsearch -exact $treediffs($ids) $fname]
81228127
if {$i >= 0} {
@@ -8178,7 +8183,7 @@ proc parseblobdiffline {ids line} {
81788183

81798184
if {![string compare -length 5 "diff " $line]} {
81808185
if {![regexp {^diff (--cc|--git) } $line m type]} {
8181-
set line [encoding convertfrom $line]
8186+
set line [encoding convertfrom utf-8 $line]
81828187
$ctext insert end "$line\n" hunksep
81838188
continue
81848189
}
@@ -8227,7 +8232,7 @@ proc parseblobdiffline {ids line} {
82278232
makediffhdr $fname $ids
82288233

82298234
} elseif {![string compare -length 16 "* Unmerged path " $line]} {
8230-
set fname [encoding convertfrom [string range $line 16 end]]
8235+
set fname [encoding convertfrom utf-8 [string range $line 16 end]]
82318236
$ctext insert end "\n"
82328237
set curdiffstart [$ctext index "end - 1c"]
82338238
lappend ctext_file_names $fname
@@ -8280,7 +8285,7 @@ proc parseblobdiffline {ids line} {
82808285
if {[string index $fname 0] eq "\""} {
82818286
set fname [lindex $fname 0]
82828287
}
8283-
set fname [encoding convertfrom $fname]
8288+
set fname [encoding convertfrom utf-8 $fname]
82848289
set i [lsearch -exact $treediffs($ids) $fname]
82858290
if {$i >= 0} {
82868291
setinlist difffilestart $i $curdiffstart
@@ -8299,6 +8304,7 @@ proc parseblobdiffline {ids line} {
82998304
set diffinhdr 0
83008305
return
83018306
}
8307+
set line [encoding convertfrom utf-8 $line]
83028308
$ctext insert end "$line\n" filesep
83038309

83048310
} else {
@@ -10057,7 +10063,7 @@ proc showrefs {} {
1005710063
text $top.list -background $bgcolor -foreground $fgcolor \
1005810064
-selectbackground $selectbgcolor -font mainfont \
1005910065
-xscrollcommand "$top.xsb set" -yscrollcommand "$top.ysb set" \
10060-
-width 30 -height 20 -cursor $maincursor \
10066+
-width 60 -height 20 -cursor $maincursor \
1006110067
-spacing1 1 -spacing3 1 -state disabled
1006210068
$top.list tag configure highlight -background $selectbgcolor
1006310069
if {![lsearch -exact $bglist $top.list]} {
@@ -12267,7 +12273,7 @@ proc cache_gitattr {attr pathlist} {
1226712273
foreach row [split $rlist "\n"] {
1226812274
if {[regexp "(.*): $attr: (.*)" $row m path value]} {
1226912275
if {[string index $path 0] eq "\""} {
12270-
set path [encoding convertfrom [lindex $path 0]]
12276+
set path [encoding convertfrom utf-8 [lindex $path 0]]
1227112277
}
1227212278
set path_attr_cache($attr,$path) $value
1227312279
}
@@ -12297,7 +12303,6 @@ if { [info exists ::env(GITK_MSGSDIR)] } {
1229712303
set gitk_prefix [file dirname [file dirname [file normalize $argv0]]]
1229812304
set gitk_libdir [file join $gitk_prefix share gitk lib]
1229912305
set gitk_msgsdir [file join $gitk_libdir msgs]
12300-
unset gitk_prefix
1230112306
}
1230212307

1230312308
## Internationalization (i18n) through msgcat and gettext. See
@@ -12596,6 +12601,7 @@ set nullid2 "0000000000000000000000000000000000000001"
1259612601
set nullfile "/dev/null"
1259712602

1259812603
set have_tk85 [expr {[package vcompare $tk_version "8.5"] >= 0}]
12604+
set have_tk86 [expr {[package vcompare $tk_version "8.6"] >= 0}]
1259912605
if {![info exists have_ttk]} {
1260012606
set have_ttk [llength [info commands ::ttk::style]]
1260112607
}
@@ -12660,28 +12666,32 @@ if {[expr {[exec git rev-parse --is-inside-work-tree] == "true"}]} {
1266012666
set worktree [gitworktree]
1266112667
setcoords
1266212668
makewindow
12663-
catch {
12664-
image create photo gitlogo -width 16 -height 16
12665-
12666-
image create photo gitlogominus -width 4 -height 2
12667-
gitlogominus put #C00000 -to 0 0 4 2
12668-
gitlogo copy gitlogominus -to 1 5
12669-
gitlogo copy gitlogominus -to 6 5
12670-
gitlogo copy gitlogominus -to 11 5
12671-
image delete gitlogominus
12672-
12673-
image create photo gitlogoplus -width 4 -height 4
12674-
gitlogoplus put #008000 -to 1 0 3 4
12675-
gitlogoplus put #008000 -to 0 1 4 3
12676-
gitlogo copy gitlogoplus -to 1 9
12677-
gitlogo copy gitlogoplus -to 6 9
12678-
gitlogo copy gitlogoplus -to 11 9
12679-
image delete gitlogoplus
12680-
12681-
image create photo gitlogo32 -width 32 -height 32
12682-
gitlogo32 copy gitlogo -zoom 2 2
12683-
12684-
wm iconphoto . -default gitlogo gitlogo32
12669+
if {$::tcl_platform(platform) eq {windows} && [file exists $gitk_prefix/etc/git.ico]} {
12670+
wm iconbitmap . -default $gitk_prefix/etc/git.ico
12671+
} else {
12672+
catch {
12673+
image create photo gitlogo -width 16 -height 16
12674+
12675+
image create photo gitlogominus -width 4 -height 2
12676+
gitlogominus put #C00000 -to 0 0 4 2
12677+
gitlogo copy gitlogominus -to 1 5
12678+
gitlogo copy gitlogominus -to 6 5
12679+
gitlogo copy gitlogominus -to 11 5
12680+
image delete gitlogominus
12681+
12682+
image create photo gitlogoplus -width 4 -height 4
12683+
gitlogoplus put #008000 -to 1 0 3 4
12684+
gitlogoplus put #008000 -to 0 1 4 3
12685+
gitlogo copy gitlogoplus -to 1 9
12686+
gitlogo copy gitlogoplus -to 6 9
12687+
gitlogo copy gitlogoplus -to 11 9
12688+
image delete gitlogoplus
12689+
12690+
image create photo gitlogo32 -width 32 -height 32
12691+
gitlogo32 copy gitlogo -zoom 2 2
12692+
12693+
wm iconphoto . -default gitlogo gitlogo32
12694+
}
1268512695
}
1268612696
# wait for the window to become visible
1268712697
tkwait visibility .

0 commit comments

Comments
 (0)