Skip to content

Commit 7e053dc

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 bed27f8 + cbe0d10 commit 7e053dc

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
@@ -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

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
@@ -2096,7 +2096,7 @@ proc makewindow {} {
20962096
global headctxmenu progresscanv progressitem progresscoords statusw
20972097
global fprogitem fprogcoord lastprogupdate progupdatepending
20982098
global rprogitem rprogcoord rownumsel numcommits
2099-
global have_tk85 use_ttk NS
2099+
global have_tk85 have_tk86 use_ttk NS
21002100
global git_version
21012101
global worddiff
21022102

@@ -2586,8 +2586,13 @@ proc makewindow {} {
25862586
bind . <Key-Down> "selnextline 1"
25872587
bind . <Shift-Key-Up> "dofind -1 0"
25882588
bind . <Shift-Key-Down> "dofind 1 0"
2589-
bindkey <Key-Right> "goforw"
2590-
bindkey <Key-Left> "goback"
2589+
if {$have_tk86} {
2590+
bindkey <<NextChar>> "goforw"
2591+
bindkey <<PrevChar>> "goback"
2592+
} else {
2593+
bindkey <Key-Right> "goforw"
2594+
bindkey <Key-Left> "goback"
2595+
}
25912596
bind . <Key-Prior> "selnextpage -1"
25922597
bind . <Key-Next> "selnextpage 1"
25932598
bind . <$M1B-Home> "allcanvs yview moveto 0.0"
@@ -7691,7 +7696,7 @@ proc gettreeline {gtf id} {
76917696
if {[string index $fname 0] eq "\""} {
76927697
set fname [lindex $fname 0]
76937698
}
7694-
set fname [encoding convertfrom $fname]
7699+
set fname [encoding convertfrom utf-8 $fname]
76957700
lappend treefilelist($id) $fname
76967701
}
76977702
if {![eof $gtf]} {
@@ -7953,7 +7958,7 @@ proc gettreediffline {gdtf ids} {
79537958
if {[string index $file 0] eq "\""} {
79547959
set file [lindex $file 0]
79557960
}
7956-
set file [encoding convertfrom $file]
7961+
set file [encoding convertfrom utf-8 $file]
79577962
if {$file ne [lindex $treediff end]} {
79587963
lappend treediff $file
79597964
lappend sublist $file
@@ -8098,7 +8103,7 @@ proc makediffhdr {fname ids} {
80988103
global ctext curdiffstart treediffs diffencoding
80998104
global ctext_file_names jump_to_here targetline diffline
81008105

8101-
set fname [encoding convertfrom $fname]
8106+
set fname [encoding convertfrom utf-8 $fname]
81028107
set diffencoding [get_path_encoding $fname]
81038108
set i [lsearch -exact $treediffs($ids) $fname]
81048109
if {$i >= 0} {
@@ -8160,7 +8165,7 @@ proc parseblobdiffline {ids line} {
81608165

81618166
if {![string compare -length 5 "diff " $line]} {
81628167
if {![regexp {^diff (--cc|--git) } $line m type]} {
8163-
set line [encoding convertfrom $line]
8168+
set line [encoding convertfrom utf-8 $line]
81648169
$ctext insert end "$line\n" hunksep
81658170
continue
81668171
}
@@ -8207,7 +8212,7 @@ proc parseblobdiffline {ids line} {
82078212
makediffhdr $fname $ids
82088213

82098214
} elseif {![string compare -length 16 "* Unmerged path " $line]} {
8210-
set fname [encoding convertfrom [string range $line 16 end]]
8215+
set fname [encoding convertfrom utf-8 [string range $line 16 end]]
82118216
$ctext insert end "\n"
82128217
set curdiffstart [$ctext index "end - 1c"]
82138218
lappend ctext_file_names $fname
@@ -8262,7 +8267,7 @@ proc parseblobdiffline {ids line} {
82628267
if {[string index $fname 0] eq "\""} {
82638268
set fname [lindex $fname 0]
82648269
}
8265-
set fname [encoding convertfrom $fname]
8270+
set fname [encoding convertfrom utf-8 $fname]
82668271
set i [lsearch -exact $treediffs($ids) $fname]
82678272
if {$i >= 0} {
82688273
setinlist difffilestart $i $curdiffstart
@@ -8281,6 +8286,7 @@ proc parseblobdiffline {ids line} {
82818286
set diffinhdr 0
82828287
return
82838288
}
8289+
set line [encoding convertfrom utf-8 $line]
82848290
$ctext insert end "$line\n" filesep
82858291

82868292
} else {
@@ -10039,7 +10045,7 @@ proc showrefs {} {
1003910045
text $top.list -background $bgcolor -foreground $fgcolor \
1004010046
-selectbackground $selectbgcolor -font mainfont \
1004110047
-xscrollcommand "$top.xsb set" -yscrollcommand "$top.ysb set" \
10042-
-width 30 -height 20 -cursor $maincursor \
10048+
-width 60 -height 20 -cursor $maincursor \
1004310049
-spacing1 1 -spacing3 1 -state disabled
1004410050
$top.list tag configure highlight -background $selectbgcolor
1004510051
if {![lsearch -exact $bglist $top.list]} {
@@ -12236,7 +12242,7 @@ proc cache_gitattr {attr pathlist} {
1223612242
foreach row [split $rlist "\n"] {
1223712243
if {[regexp "(.*): $attr: (.*)" $row m path value]} {
1223812244
if {[string index $path 0] eq "\""} {
12239-
set path [encoding convertfrom [lindex $path 0]]
12245+
set path [encoding convertfrom utf-8 [lindex $path 0]]
1224012246
}
1224112247
set path_attr_cache($attr,$path) $value
1224212248
}
@@ -12266,7 +12272,6 @@ if { [info exists ::env(GITK_MSGSDIR)] } {
1226612272
set gitk_prefix [file dirname [file dirname [file normalize $argv0]]]
1226712273
set gitk_libdir [file join $gitk_prefix share gitk lib]
1226812274
set gitk_msgsdir [file join $gitk_libdir msgs]
12269-
unset gitk_prefix
1227012275
}
1227112276

1227212277
## Internationalization (i18n) through msgcat and gettext. See
@@ -12564,6 +12569,7 @@ set nullid2 "0000000000000000000000000000000000000001"
1256412569
set nullfile "/dev/null"
1256512570

1256612571
set have_tk85 [expr {[package vcompare $tk_version "8.5"] >= 0}]
12572+
set have_tk86 [expr {[package vcompare $tk_version "8.6"] >= 0}]
1256712573
if {![info exists have_ttk]} {
1256812574
set have_ttk [llength [info commands ::ttk::style]]
1256912575
}
@@ -12630,28 +12636,32 @@ if {$hasworktree} {
1263012636
}
1263112637
setcoords
1263212638
makewindow
12633-
catch {
12634-
image create photo gitlogo -width 16 -height 16
12635-
12636-
image create photo gitlogominus -width 4 -height 2
12637-
gitlogominus put #C00000 -to 0 0 4 2
12638-
gitlogo copy gitlogominus -to 1 5
12639-
gitlogo copy gitlogominus -to 6 5
12640-
gitlogo copy gitlogominus -to 11 5
12641-
image delete gitlogominus
12642-
12643-
image create photo gitlogoplus -width 4 -height 4
12644-
gitlogoplus put #008000 -to 1 0 3 4
12645-
gitlogoplus put #008000 -to 0 1 4 3
12646-
gitlogo copy gitlogoplus -to 1 9
12647-
gitlogo copy gitlogoplus -to 6 9
12648-
gitlogo copy gitlogoplus -to 11 9
12649-
image delete gitlogoplus
12650-
12651-
image create photo gitlogo32 -width 32 -height 32
12652-
gitlogo32 copy gitlogo -zoom 2 2
12653-
12654-
wm iconphoto . -default gitlogo gitlogo32
12639+
if {$::tcl_platform(platform) eq {windows} && [file exists $gitk_prefix/etc/git.ico]} {
12640+
wm iconbitmap . -default $gitk_prefix/etc/git.ico
12641+
} else {
12642+
catch {
12643+
image create photo gitlogo -width 16 -height 16
12644+
12645+
image create photo gitlogominus -width 4 -height 2
12646+
gitlogominus put #C00000 -to 0 0 4 2
12647+
gitlogo copy gitlogominus -to 1 5
12648+
gitlogo copy gitlogominus -to 6 5
12649+
gitlogo copy gitlogominus -to 11 5
12650+
image delete gitlogominus
12651+
12652+
image create photo gitlogoplus -width 4 -height 4
12653+
gitlogoplus put #008000 -to 1 0 3 4
12654+
gitlogoplus put #008000 -to 0 1 4 3
12655+
gitlogo copy gitlogoplus -to 1 9
12656+
gitlogo copy gitlogoplus -to 6 9
12657+
gitlogo copy gitlogoplus -to 11 9
12658+
image delete gitlogoplus
12659+
12660+
image create photo gitlogo32 -width 32 -height 32
12661+
gitlogo32 copy gitlogo -zoom 2 2
12662+
12663+
wm iconphoto . -default gitlogo gitlogo32
12664+
}
1265512665
}
1265612666
# wait for the window to become visible
1265712667
tkwait visibility .

0 commit comments

Comments
 (0)