Skip to content

Commit 836fcb9

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 f8d4e9f + c405ea6 commit 836fcb9

File tree

4 files changed

+120
-34
lines changed

4 files changed

+120
-34
lines changed

git-gui/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ install: all
280280
$(QUIET)$(INSTALL_D0)'$(DESTDIR_SQ)$(gitexecdir_SQ)' $(INSTALL_D1)
281281
$(QUIET)$(INSTALL_X0)git-gui $(INSTALL_X1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
282282
$(QUIET)$(INSTALL_X0)git-gui--askpass $(INSTALL_X1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
283+
$(QUIET)$(INSTALL_X0)git-gui--askyesno $(INSTALL_X1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
283284
$(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
284285
ifdef GITGUI_WINDOWS_WRAPPER
285286
$(QUIET)$(INSTALL_R0)git-gui.tcl $(INSTALL_R1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
@@ -298,6 +299,7 @@ uninstall:
298299
$(QUIET)$(CLEAN_DST) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
299300
$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui $(REMOVE_F1)
300301
$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui--askpass $(REMOVE_F1)
302+
$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui--askyesno $(REMOVE_F1)
301303
$(QUIET)$(foreach p,$(GITGUI_BUILT_INS), $(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/$p $(REMOVE_F1) &&) true
302304
ifdef GITGUI_WINDOWS_WRAPPER
303305
$(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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,6 +1248,12 @@ set have_tk85 [expr {[package vcompare $tk_version "8.5"] >= 0}]
12481248
if {![info exists env(SSH_ASKPASS)]} {
12491249
set env(SSH_ASKPASS) [gitexec git-gui--askpass]
12501250
}
1251+
if {![info exists env(GIT_ASKPASS)]} {
1252+
set env(GIT_ASKPASS) [gitexec git-gui--askpass]
1253+
}
1254+
if {![info exists env(GIT_ASK_YESNO)]} {
1255+
set env(GIT_ASK_YESNO) [gitexec git-gui--askyesno]
1256+
}
12511257

12521258
######################################################################
12531259
##

gitk-git/gitk

Lines changed: 44 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2238,7 +2238,7 @@ proc makewindow {} {
22382238
global headctxmenu progresscanv progressitem progresscoords statusw
22392239
global fprogitem fprogcoord lastprogupdate progupdatepending
22402240
global rprogitem rprogcoord rownumsel numcommits
2241-
global have_tk85 use_ttk NS
2241+
global have_tk85 have_tk86 use_ttk NS
22422242
global git_version
22432243
global worddiff
22442244
@@ -2736,8 +2736,13 @@ proc makewindow {} {
27362736
bind . <Key-Down> "selnextline 1"
27372737
bind . <Shift-Key-Up> "dofind -1 0"
27382738
bind . <Shift-Key-Down> "dofind 1 0"
2739-
bindkey <Key-Right> "goforw"
2740-
bindkey <Key-Left> "goback"
2739+
if {$have_tk86} {
2740+
bindkey <<NextChar>> "goforw"
2741+
bindkey <<PrevChar>> "goback"
2742+
} else {
2743+
bindkey <Key-Right> "goforw"
2744+
bindkey <Key-Left> "goback"
2745+
}
27412746
bind . <Key-Prior> "selnextpage -1"
27422747
bind . <Key-Next> "selnextpage 1"
27432748
bind . <$M1B-Home> "allcanvs yview moveto 0.0"
@@ -7855,7 +7860,7 @@ proc gettreeline {gtf id} {
78557860
if {[string index $fname 0] eq "\""} {
78567861
set fname [lindex $fname 0]
78577862
}
7858-
set fname [encoding convertfrom $fname]
7863+
set fname [encoding convertfrom utf-8 $fname]
78597864
lappend treefilelist($id) $fname
78607865
}
78617866
if {![eof $gtf]} {
@@ -8117,7 +8122,7 @@ proc gettreediffline {gdtf ids} {
81178122
if {[string index $file 0] eq "\""} {
81188123
set file [lindex $file 0]
81198124
}
8120-
set file [encoding convertfrom $file]
8125+
set file [encoding convertfrom utf-8 $file]
81218126
if {$file ne [lindex $treediff end]} {
81228127
lappend treediff $file
81238128
lappend sublist $file
@@ -8262,7 +8267,7 @@ proc makediffhdr {fname ids} {
82628267
global ctext curdiffstart treediffs diffencoding
82638268
global ctext_file_names jump_to_here targetline diffline
82648269
8265-
set fname [encoding convertfrom $fname]
8270+
set fname [encoding convertfrom utf-8 $fname]
82668271
set diffencoding [get_path_encoding $fname]
82678272
set i [lsearch -exact $treediffs($ids) $fname]
82688273
if {$i >= 0} {
@@ -8324,7 +8329,7 @@ proc parseblobdiffline {ids line} {
83248329
83258330
if {![string compare -length 5 "diff " $line]} {
83268331
if {![regexp {^diff (--cc|--git) } $line m type]} {
8327-
set line [encoding convertfrom $line]
8332+
set line [encoding convertfrom utf-8 $line]
83288333
$ctext insert end "$line\n" hunksep
83298334
continue
83308335
}
@@ -8373,7 +8378,7 @@ proc parseblobdiffline {ids line} {
83738378
makediffhdr $fname $ids
83748379
83758380
} elseif {![string compare -length 16 "* Unmerged path " $line]} {
8376-
set fname [encoding convertfrom [string range $line 16 end]]
8381+
set fname [encoding convertfrom utf-8 [string range $line 16 end]]
83778382
$ctext insert end "\n"
83788383
set curdiffstart [$ctext index "end - 1c"]
83798384
lappend ctext_file_names $fname
@@ -8426,7 +8431,7 @@ proc parseblobdiffline {ids line} {
84268431
if {[string index $fname 0] eq "\""} {
84278432
set fname [lindex $fname 0]
84288433
}
8429-
set fname [encoding convertfrom $fname]
8434+
set fname [encoding convertfrom utf-8 $fname]
84308435
set i [lsearch -exact $treediffs($ids) $fname]
84318436
if {$i >= 0} {
84328437
setinlist difffilestart $i $curdiffstart
@@ -8445,6 +8450,7 @@ proc parseblobdiffline {ids line} {
84458450
set diffinhdr 0
84468451
return
84478452
}
8453+
set line [encoding convertfrom utf-8 $line]
84488454
$ctext insert end "$line\n" filesep
84498455
84508456
} else {
@@ -10203,7 +10209,7 @@ proc showrefs {} {
1020310209
text $top.list -background $bgcolor -foreground $fgcolor \
1020410210
-selectbackground $selectbgcolor -font mainfont \
1020510211
-xscrollcommand "$top.xsb set" -yscrollcommand "$top.ysb set" \
10206-
-width 30 -height 20 -cursor $maincursor \
10212+
-width 60 -height 20 -cursor $maincursor \
1020710213
-spacing1 1 -spacing3 1 -state disabled
1020810214
$top.list tag configure highlight -background $selectbgcolor
1020910215
if {![lsearch -exact $bglist $top.list]} {
@@ -12440,7 +12446,7 @@ proc cache_gitattr {attr pathlist} {
1244012446
foreach row [split $rlist "\n"] {
1244112447
if {[regexp "(.*): $attr: (.*)" $row m path value]} {
1244212448
if {[string index $path 0] eq "\""} {
12443-
set path [encoding convertfrom [lindex $path 0]]
12449+
set path [encoding convertfrom utf-8 [lindex $path 0]]
1244412450
}
1244512451
set path_attr_cache($attr,$path) $value
1244612452
}
@@ -12470,7 +12476,6 @@ if { [info exists ::env(GITK_MSGSDIR)] } {
1247012476
set gitk_prefix [file dirname [file dirname [file normalize $argv0]]]
1247112477
set gitk_libdir [file join $gitk_prefix share gitk lib]
1247212478
set gitk_msgsdir [file join $gitk_libdir msgs]
12473-
unset gitk_prefix
1247412479
}
1247512480
1247612481
## Internationalization (i18n) through msgcat and gettext. See
@@ -12772,6 +12777,7 @@ set nullid2 "0000000000000000000000000000000000000001"
1277212777
set nullfile "/dev/null"
1277312778
1277412779
set have_tk85 [expr {[package vcompare $tk_version "8.5"] >= 0}]
12780+
set have_tk86 [expr {[package vcompare $tk_version "8.6"] >= 0}]
1277512781
if {![info exists have_ttk]} {
1277612782
set have_ttk [llength [info commands ::ttk::style]]
1277712783
}
@@ -12836,28 +12842,32 @@ if {[expr {[exec git rev-parse --is-inside-work-tree] == "true"}]} {
1283612842
set worktree [gitworktree]
1283712843
setcoords
1283812844
makewindow
12839-
catch {
12840-
image create photo gitlogo -width 16 -height 16
12841-
12842-
image create photo gitlogominus -width 4 -height 2
12843-
gitlogominus put #C00000 -to 0 0 4 2
12844-
gitlogo copy gitlogominus -to 1 5
12845-
gitlogo copy gitlogominus -to 6 5
12846-
gitlogo copy gitlogominus -to 11 5
12847-
image delete gitlogominus
12848-
12849-
image create photo gitlogoplus -width 4 -height 4
12850-
gitlogoplus put #008000 -to 1 0 3 4
12851-
gitlogoplus put #008000 -to 0 1 4 3
12852-
gitlogo copy gitlogoplus -to 1 9
12853-
gitlogo copy gitlogoplus -to 6 9
12854-
gitlogo copy gitlogoplus -to 11 9
12855-
image delete gitlogoplus
12856-
12857-
image create photo gitlogo32 -width 32 -height 32
12858-
gitlogo32 copy gitlogo -zoom 2 2
12859-
12860-
wm iconphoto . -default gitlogo gitlogo32
12845+
if {$::tcl_platform(platform) eq {windows} && [file exists $gitk_prefix/etc/git.ico]} {
12846+
wm iconbitmap . -default $gitk_prefix/etc/git.ico
12847+
} else {
12848+
catch {
12849+
image create photo gitlogo -width 16 -height 16
12850+
12851+
image create photo gitlogominus -width 4 -height 2
12852+
gitlogominus put #C00000 -to 0 0 4 2
12853+
gitlogo copy gitlogominus -to 1 5
12854+
gitlogo copy gitlogominus -to 6 5
12855+
gitlogo copy gitlogominus -to 11 5
12856+
image delete gitlogominus
12857+
12858+
image create photo gitlogoplus -width 4 -height 4
12859+
gitlogoplus put #008000 -to 1 0 3 4
12860+
gitlogoplus put #008000 -to 0 1 4 3
12861+
gitlogo copy gitlogoplus -to 1 9
12862+
gitlogo copy gitlogoplus -to 6 9
12863+
gitlogo copy gitlogoplus -to 11 9
12864+
image delete gitlogoplus
12865+
12866+
image create photo gitlogo32 -width 32 -height 32
12867+
gitlogo32 copy gitlogo -zoom 2 2
12868+
12869+
wm iconphoto . -default gitlogo gitlogo32
12870+
}
1286112871
}
1286212872
# wait for the window to become visible
1286312873
if {![winfo viewable .]} {tkwait visibility .}

0 commit comments

Comments
 (0)