Skip to content

Commit 0677698

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 2b3ed3e + 6aba4d0 commit 0677698

File tree

4 files changed

+125
-35
lines changed

4 files changed

+125
-35
lines changed

git-gui/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ install: all
295295
$(QUIET)$(INSTALL_D0)'$(DESTDIR_SQ)$(gitexecdir_SQ)' $(INSTALL_D1)
296296
$(QUIET)$(INSTALL_X0)git-gui $(INSTALL_X1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
297297
$(QUIET)$(INSTALL_X0)git-gui--askpass $(INSTALL_X1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
298+
$(QUIET)$(INSTALL_X0)git-gui--askyesno $(INSTALL_X1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
298299
$(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
299300
ifdef GITGUI_WINDOWS_WRAPPER
300301
$(QUIET)$(INSTALL_R0)git-gui.tcl $(INSTALL_R1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
@@ -313,6 +314,7 @@ uninstall:
313314
$(QUIET)$(CLEAN_DST) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
314315
$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui $(REMOVE_F1)
315316
$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui--askpass $(REMOVE_F1)
317+
$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui--askyesno $(REMOVE_F1)
316318
$(QUIET)$(foreach p,$(GITGUI_BUILT_INS), $(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/$p $(REMOVE_F1) &&) true
317319
ifdef GITGUI_WINDOWS_WRAPPER
318320
$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui.tcl $(REMOVE_F1)

git-gui/git-gui--askyesno

Lines changed: 68 additions & 0 deletions
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

Lines changed: 11 additions & 1 deletion
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
@@ -1230,6 +1234,12 @@ set have_tk85 [expr {[package vcompare $tk_version "8.5"] >= 0}]
12301234
if {![info exists env(SSH_ASKPASS)]} {
12311235
set env(SSH_ASKPASS) [gitexec git-gui--askpass]
12321236
}
1237+
if {![info exists env(GIT_ASKPASS)]} {
1238+
set env(GIT_ASKPASS) [gitexec git-gui--askpass]
1239+
}
1240+
if {![info exists env(GIT_ASK_YESNO)]} {
1241+
set env(GIT_ASK_YESNO) [gitexec git-gui--askyesno]
1242+
}
12331243
12341244
######################################################################
12351245
##

gitk-git/gitk

Lines changed: 44 additions & 34 deletions
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"
@@ -7712,7 +7717,7 @@ proc gettreeline {gtf id} {
77127717
if {[string index $fname 0] eq "\""} {
77137718
set fname [lindex $fname 0]
77147719
}
7715-
set fname [encoding convertfrom $fname]
7720+
set fname [encoding convertfrom utf-8 $fname]
77167721
lappend treefilelist($id) $fname
77177722
}
77187723
if {![eof $gtf]} {
@@ -7974,7 +7979,7 @@ proc gettreediffline {gdtf ids} {
79747979
if {[string index $file 0] eq "\""} {
79757980
set file [lindex $file 0]
79767981
}
7977-
set file [encoding convertfrom $file]
7982+
set file [encoding convertfrom utf-8 $file]
79787983
if {$file ne [lindex $treediff end]} {
79797984
lappend treediff $file
79807985
lappend sublist $file
@@ -8119,7 +8124,7 @@ proc makediffhdr {fname ids} {
81198124
global ctext curdiffstart treediffs diffencoding
81208125
global ctext_file_names jump_to_here targetline diffline
81218126

8122-
set fname [encoding convertfrom $fname]
8127+
set fname [encoding convertfrom utf-8 $fname]
81238128
set diffencoding [get_path_encoding $fname]
81248129
set i [lsearch -exact $treediffs($ids) $fname]
81258130
if {$i >= 0} {
@@ -8181,7 +8186,7 @@ proc parseblobdiffline {ids line} {
81818186

81828187
if {![string compare -length 5 "diff " $line]} {
81838188
if {![regexp {^diff (--cc|--git) } $line m type]} {
8184-
set line [encoding convertfrom $line]
8189+
set line [encoding convertfrom utf-8 $line]
81858190
$ctext insert end "$line\n" hunksep
81868191
continue
81878192
}
@@ -8230,7 +8235,7 @@ proc parseblobdiffline {ids line} {
82308235
makediffhdr $fname $ids
82318236

82328237
} elseif {![string compare -length 16 "* Unmerged path " $line]} {
8233-
set fname [encoding convertfrom [string range $line 16 end]]
8238+
set fname [encoding convertfrom utf-8 [string range $line 16 end]]
82348239
$ctext insert end "\n"
82358240
set curdiffstart [$ctext index "end - 1c"]
82368241
lappend ctext_file_names $fname
@@ -8283,7 +8288,7 @@ proc parseblobdiffline {ids line} {
82838288
if {[string index $fname 0] eq "\""} {
82848289
set fname [lindex $fname 0]
82858290
}
8286-
set fname [encoding convertfrom $fname]
8291+
set fname [encoding convertfrom utf-8 $fname]
82878292
set i [lsearch -exact $treediffs($ids) $fname]
82888293
if {$i >= 0} {
82898294
setinlist difffilestart $i $curdiffstart
@@ -8302,6 +8307,7 @@ proc parseblobdiffline {ids line} {
83028307
set diffinhdr 0
83038308
return
83048309
}
8310+
set line [encoding convertfrom utf-8 $line]
83058311
$ctext insert end "$line\n" filesep
83068312

83078313
} else {
@@ -10060,7 +10066,7 @@ proc showrefs {} {
1006010066
text $top.list -background $bgcolor -foreground $fgcolor \
1006110067
-selectbackground $selectbgcolor -font mainfont \
1006210068
-xscrollcommand "$top.xsb set" -yscrollcommand "$top.ysb set" \
10063-
-width 30 -height 20 -cursor $maincursor \
10069+
-width 60 -height 20 -cursor $maincursor \
1006410070
-spacing1 1 -spacing3 1 -state disabled
1006510071
$top.list tag configure highlight -background $selectbgcolor
1006610072
if {![lsearch -exact $bglist $top.list]} {
@@ -12270,7 +12276,7 @@ proc cache_gitattr {attr pathlist} {
1227012276
foreach row [split $rlist "\n"] {
1227112277
if {[regexp "(.*): $attr: (.*)" $row m path value]} {
1227212278
if {[string index $path 0] eq "\""} {
12273-
set path [encoding convertfrom [lindex $path 0]]
12279+
set path [encoding convertfrom utf-8 [lindex $path 0]]
1227412280
}
1227512281
set path_attr_cache($attr,$path) $value
1227612282
}
@@ -12300,7 +12306,6 @@ if { [info exists ::env(GITK_MSGSDIR)] } {
1230012306
set gitk_prefix [file dirname [file dirname [file normalize $argv0]]]
1230112307
set gitk_libdir [file join $gitk_prefix share gitk lib]
1230212308
set gitk_msgsdir [file join $gitk_libdir msgs]
12303-
unset gitk_prefix
1230412309
}
1230512310

1230612311
## Internationalization (i18n) through msgcat and gettext. See
@@ -12599,6 +12604,7 @@ set nullid2 "0000000000000000000000000000000000000001"
1259912604
set nullfile "/dev/null"
1260012605

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

0 commit comments

Comments
 (0)