Skip to content

Commit 9269df9

Browse files
committed
Merge branch 'maint' of git://repo.or.cz/git-gui into maint
* 'maint' of git://repo.or.cz/git-gui: git-gui: Disable native platform text selection in "lists" git-gui: Paper bag fix "Commit->Revert" format arguments git-gui: Provide 'uninstall' Makefile target to undo an installation git-gui: Font chooser to handle a large number of font families git-gui: Make backporting changes from i18n version easier git-gui: Don't delete send on Windows as it doesn't exist git-gui: Trim trailing slashes from untracked submodule names git-gui: Assume untracked directories are Git submodules git-gui: handle "deleted symlink" diff marker git-gui: show unstaged symlinks in diff viewer git-gui: Avoid use of libdir in Makefile git-gui: Disable Tk send in all git-gui sessions git-gui: lib/index.tcl: handle files with % in the filename properly git-gui: Properly set the state of "Stage/Unstage Hunk" action git-gui: Fix detaching current branch during checkout git-gui: Correct starting of git-remote to handle -w option
2 parents be510cf + 3849bfb commit 9269df9

File tree

8 files changed

+293
-45
lines changed

8 files changed

+293
-45
lines changed

git-gui/Makefile

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ ifndef INSTALL
3131
INSTALL = install
3232
endif
3333

34+
RM_F ?= rm -f
35+
RMDIR ?= rmdir
36+
3437
INSTALL_D0 = $(INSTALL) -d -m755 # space is required here
3538
INSTALL_D1 =
3639
INSTALL_R0 = $(INSTALL) -m644 # space is required here
@@ -42,6 +45,12 @@ INSTALL_L1 = && ln # space is required here
4245
INSTALL_L2 =
4346
INSTALL_L3 =
4447

48+
REMOVE_D0 = $(RMDIR) # space is required here
49+
REMOVE_D1 = || true
50+
REMOVE_F0 = $(RM_F) # space is required here
51+
REMOVE_F1 =
52+
CLEAN_DST = true
53+
4554
ifndef V
4655
QUIET = @
4756
QUIET_GEN = $(QUIET)echo ' ' GEN $@ &&
@@ -60,6 +69,12 @@ ifndef V
6069
INSTALL_L1 = && src=
6170
INSTALL_L2 = && dst=
6271
INSTALL_L3 = && echo ' ' 'LINK ' `basename "$$dst"` '->' `basename "$$src"` && rm -f "$$dst" && ln "$$src" "$$dst"
72+
73+
CLEAN_DST = echo ' ' UNINSTALL
74+
REMOVE_D0 = dir=
75+
REMOVE_D1 = && echo ' ' REMOVE $$dir && test -d "$$dir" && $(RMDIR) "$$dir" || true
76+
REMOVE_F0 = dst=
77+
REMOVE_F1 = && echo ' ' REMOVE `basename "$$dst"` && $(RM_F) "$$dst"
6378
endif
6479

6580
TCL_PATH ?= tclsh
@@ -76,8 +91,8 @@ SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
7691
TCL_PATH_SQ = $(subst ','\'',$(TCL_PATH))
7792
TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
7893

79-
libdir ?= $(sharedir)/git-gui/lib
80-
libdir_SQ = $(subst ','\'',$(libdir))
94+
gg_libdir ?= $(sharedir)/git-gui/lib
95+
libdir_SQ = $(subst ','\'',$(gg_libdir))
8196

8297
exedir = $(dir $(gitexecdir))share/git-gui/lib
8398
exedir_SQ = $(subst ','\'',$(exedir))
@@ -126,7 +141,7 @@ TRACK_VARS = \
126141
$(subst ','\'',TCL_PATH='$(TCL_PATH_SQ)') \
127142
$(subst ','\'',TCLTK_PATH='$(TCLTK_PATH_SQ)') \
128143
$(subst ','\'',gitexecdir='$(gitexecdir_SQ)') \
129-
$(subst ','\'',libdir='$(libdir_SQ)') \
144+
$(subst ','\'',gg_libdir='$(libdir_SQ)') \
130145
#end TRACK_VARS
131146

132147
GIT-GUI-VARS: .FORCE-GIT-GUI-VARS
@@ -146,6 +161,17 @@ install: all
146161
$(QUIET)$(INSTALL_R0)lib/tclIndex $(INSTALL_R1) '$(DESTDIR_SQ)$(libdir_SQ)'
147162
$(QUIET)$(foreach p,$(ALL_LIBFILES), $(INSTALL_R0)$p $(INSTALL_R1) '$(DESTDIR_SQ)$(libdir_SQ)' &&) true
148163

164+
uninstall:
165+
$(QUIET)$(CLEAN_DST) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
166+
$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui $(REMOVE_F1)
167+
$(QUIET)$(foreach p,$(GITGUI_BUILT_INS), $(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/$p $(REMOVE_F1) &&) true
168+
$(QUIET)$(CLEAN_DST) '$(DESTDIR_SQ)$(libdir_SQ)'
169+
$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(libdir_SQ)'/tclIndex $(REMOVE_F1)
170+
$(QUIET)$(foreach p,$(ALL_LIBFILES), $(REMOVE_F0)'$(DESTDIR_SQ)$(libdir_SQ)'/$(notdir $p) $(REMOVE_F1) &&) true
171+
$(QUIET)$(REMOVE_D0)'$(DESTDIR_SQ)$(gitexecdir_SQ)' $(REMOVE_D1)
172+
$(QUIET)$(REMOVE_D0)'$(DESTDIR_SQ)$(libdir_SQ)' $(REMOVE_D1)
173+
$(QUIET)$(REMOVE_D0)`dirname '$(DESTDIR_SQ)$(libdir_SQ)'` $(REMOVE_D1)
174+
149175
dist-version:
150176
@mkdir -p $(TARDIR)
151177
@echo $(GITGUI_VERSION) > $(TARDIR)/version
@@ -154,6 +180,6 @@ clean::
154180
rm -f $(ALL_PROGRAMS) lib/tclIndex
155181
rm -f GIT-VERSION-FILE GIT-GUI-VARS
156182

157-
.PHONY: all install dist-version clean
183+
.PHONY: all install uninstall dist-version clean
158184
.PHONY: .FORCE-GIT-VERSION-FILE
159185
.PHONY: .FORCE-GIT-GUI-VARS

git-gui/git-gui.sh

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ if {[catch {package require Tcl 8.4} err]
4242
exit 1
4343
}
4444

45+
catch {rename send {}} ; # What an evil concept...
46+
4547
######################################################################
4648
##
4749
## enable verbose loading?
@@ -60,6 +62,18 @@ if {![catch {set _verbose $env(GITGUI_VERBOSE)}]} {
6062
}
6163
}
6264

65+
######################################################################
66+
##
67+
## Fake internationalization to ease backporting of changes.
68+
69+
proc mc {fmt args} {
70+
set cmk [string first @@ $fmt]
71+
if {$cmk > 0} {
72+
set fmt [string range $fmt 0 [expr {$cmk - 1}]]
73+
}
74+
return [eval [list format $fmt] $args]
75+
}
76+
6377
######################################################################
6478
##
6579
## read only globals
@@ -261,7 +275,7 @@ proc _git_cmd {name} {
261275
set s [gets $f]
262276
close $f
263277

264-
switch -glob -- $s {
278+
switch -glob -- [lindex $s 0] {
265279
#!*sh { set i sh }
266280
#!*perl { set i perl }
267281
#!*python { set i python }
@@ -275,7 +289,7 @@ proc _git_cmd {name} {
275289
if {$interp eq {}} {
276290
error "git-$name requires $i (not in PATH)"
277291
}
278-
set v [list $interp $p]
292+
set v [concat [list $interp] [lrange $s 1 end] [list $p]]
279293
} else {
280294
# Assume it is builtin to git somehow and we
281295
# aren't actually able to see a file for it.
@@ -467,6 +481,16 @@ proc tk_optionMenu {w varName args} {
467481
return $m
468482
}
469483

484+
proc rmsel_tag {text} {
485+
$text tag conf sel \
486+
-background [$text cget -background] \
487+
-foreground [$text cget -foreground] \
488+
-borderwidth 0
489+
$text tag conf in_sel -background lightgray
490+
bind $text <Motion> break
491+
return $text
492+
}
493+
470494
######################################################################
471495
##
472496
## find git
@@ -1008,7 +1032,11 @@ proc read_ls_others {fd after} {
10081032
set pck [split $buf_rlo "\0"]
10091033
set buf_rlo [lindex $pck end]
10101034
foreach p [lrange $pck 0 end-1] {
1011-
merge_state [encoding convertfrom $p] ?O
1035+
set p [encoding convertfrom $p]
1036+
if {[string index $p end] eq {/}} {
1037+
set p [string range $p 0 end-1]
1038+
}
1039+
merge_state $p ?O
10121040
}
10131041
rescan_done $fd buf_rlo $after
10141042
}
@@ -2133,8 +2161,8 @@ pack $ui_workdir -side left -fill both -expand 1
21332161
.vpane.files add .vpane.files.workdir -sticky nsew
21342162

21352163
foreach i [list $ui_index $ui_workdir] {
2136-
$i tag conf in_diff -background lightgray
2137-
$i tag conf in_sel -background lightgray
2164+
rmsel_tag $i
2165+
$i tag conf in_diff -background [$i tag cget in_sel -background]
21382166
}
21392167
unset i
21402168

@@ -2441,20 +2469,17 @@ proc popup_diff_menu {ctxm x y X Y} {
24412469
set ::cursorX $x
24422470
set ::cursorY $y
24432471
if {$::ui_index eq $::current_diff_side} {
2444-
set s normal
24452472
set l "Unstage Hunk From Commit"
24462473
} else {
2447-
if {$current_diff_path eq {}
2448-
|| ![info exists file_states($current_diff_path)]
2449-
|| {_O} eq [lindex $file_states($current_diff_path) 0]} {
2450-
set s disabled
2451-
} else {
2452-
set s normal
2453-
}
24542474
set l "Stage Hunk For Commit"
24552475
}
2456-
if {$::is_3way_diff} {
2476+
if {$::is_3way_diff
2477+
|| $current_diff_path eq {}
2478+
|| ![info exists file_states($current_diff_path)]
2479+
|| {_O} eq [lindex $file_states($current_diff_path) 0]} {
24572480
set s disabled
2481+
} else {
2482+
set s normal
24582483
}
24592484
$ctxm entryconf $::ui_diff_applyhunk -state $s -label $l
24602485
tk_popup $ctxm $X $Y

git-gui/lib/browser.tcl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ constructor new {commit {path {}}} {
4747
-width 70 \
4848
-xscrollcommand [list $w.list.sbx set] \
4949
-yscrollcommand [list $w.list.sby set]
50-
$w_list tag conf in_sel \
51-
-background [$w_list cget -foreground] \
52-
-foreground [$w_list cget -background]
50+
rmsel_tag $w_list
5351
scrollbar $w.list.sbx -orient h -command [list $w_list xview]
5452
scrollbar $w.list.sby -orient v -command [list $w_list yview]
5553
pack $w.list.sbx -side bottom -fill x

git-gui/lib/checkout_op.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ method _after_readtree {} {
396396
set is_detached 0
397397
}
398398
} else {
399-
if {$new_hash ne $HEAD} {
399+
if {!$is_detached || $new_hash ne $HEAD} {
400400
append log " to $new_expr"
401401
if {[catch {
402402
_detach_HEAD $log $new_hash

git-gui/lib/choose_font.tcl

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
# git-gui font chooser
2+
# Copyright (C) 2007 Shawn Pearce
3+
4+
class choose_font {
5+
6+
field w
7+
field w_family ; # UI widget of all known family names
8+
field w_example ; # Example to showcase the chosen font
9+
10+
field f_family ; # Currently chosen family name
11+
field f_size ; # Currently chosen point size
12+
13+
field v_family ; # Name of global variable for family
14+
field v_size ; # Name of global variable for size
15+
16+
variable all_families [list] ; # All fonts known to Tk
17+
18+
constructor pick {path title a_family a_size} {
19+
variable all_families
20+
21+
set v_family $a_family
22+
set v_size $a_size
23+
24+
upvar #0 $v_family pv_family
25+
upvar #0 $v_size pv_size
26+
27+
set f_family $pv_family
28+
set f_size $pv_size
29+
30+
make_toplevel top w
31+
wm title $top "[appname] ([reponame]): $title"
32+
wm geometry $top "+[winfo rootx $path]+[winfo rooty $path]"
33+
34+
label $w.header -text $title -font font_uibold
35+
pack $w.header -side top -fill x
36+
37+
frame $w.buttons
38+
button $w.buttons.select \
39+
-text [mc Select] \
40+
-default active \
41+
-command [cb _select]
42+
button $w.buttons.cancel \
43+
-text [mc Cancel] \
44+
-command [list destroy $w]
45+
pack $w.buttons.select -side right
46+
pack $w.buttons.cancel -side right -padx 5
47+
pack $w.buttons -side bottom -fill x -pady 10 -padx 10
48+
49+
frame $w.inner
50+
51+
frame $w.inner.family
52+
label $w.inner.family.l \
53+
-text [mc "Font Family"] \
54+
-anchor w
55+
set w_family $w.inner.family.v
56+
text $w_family \
57+
-background white \
58+
-borderwidth 1 \
59+
-relief sunken \
60+
-cursor $::cursor_ptr \
61+
-wrap none \
62+
-width 30 \
63+
-height 10 \
64+
-yscrollcommand [list $w.inner.family.sby set]
65+
rmsel_tag $w_family
66+
scrollbar $w.inner.family.sby -command [list $w_family yview]
67+
pack $w.inner.family.l -side top -fill x
68+
pack $w.inner.family.sby -side right -fill y
69+
pack $w_family -fill both -expand 1
70+
71+
frame $w.inner.size
72+
label $w.inner.size.l \
73+
-text [mc "Font Size"] \
74+
-anchor w
75+
spinbox $w.inner.size.v \
76+
-textvariable @f_size \
77+
-from 2 -to 80 -increment 1 \
78+
-width 3
79+
bind $w.inner.size.v <FocusIn> {%W selection range 0 end}
80+
pack $w.inner.size.l -fill x -side top
81+
pack $w.inner.size.v -fill x -padx 2
82+
83+
grid configure $w.inner.family $w.inner.size -sticky nsew
84+
grid rowconfigure $w.inner 0 -weight 1
85+
grid columnconfigure $w.inner 0 -weight 1
86+
pack $w.inner -fill both -expand 1 -padx 5 -pady 5
87+
88+
frame $w.example
89+
label $w.example.l \
90+
-text [mc "Font Example"] \
91+
-anchor w
92+
set w_example $w.example.t
93+
text $w_example \
94+
-background white \
95+
-borderwidth 1 \
96+
-relief sunken \
97+
-height 3 \
98+
-width 40
99+
rmsel_tag $w_example
100+
$w_example tag conf example -justify center
101+
$w_example insert end [mc "This is example text.\nIf you like this text, it can be your font."] example
102+
$w_example conf -state disabled
103+
pack $w.example.l -fill x
104+
pack $w_example -fill x
105+
pack $w.example -fill x -padx 5
106+
107+
if {$all_families eq {}} {
108+
set all_families [lsort [font families]]
109+
}
110+
111+
$w_family tag conf pick
112+
$w_family tag bind pick <Button-1> [cb _pick_family %x %y]\;break
113+
foreach f $all_families {
114+
set sel [list pick]
115+
if {$f eq $f_family} {
116+
lappend sel in_sel
117+
}
118+
$w_family insert end "$f\n" $sel
119+
}
120+
$w_family conf -state disabled
121+
_update $this
122+
123+
trace add variable @f_size write [cb _update]
124+
bind $w <Key-Escape> [list destroy $w]
125+
bind $w <Key-Return> [cb _select]\;break
126+
bind $w <Visibility> "
127+
grab $w
128+
focus $w
129+
"
130+
tkwait window $w
131+
}
132+
133+
method _select {} {
134+
upvar #0 $v_family pv_family
135+
upvar #0 $v_size pv_size
136+
137+
set pv_family $f_family
138+
set pv_size $f_size
139+
140+
destroy $w
141+
}
142+
143+
method _pick_family {x y} {
144+
variable all_families
145+
146+
set i [lindex [split [$w_family index @$x,$y] .] 0]
147+
set n [lindex $all_families [expr {$i - 1}]]
148+
if {$n ne {}} {
149+
$w_family tag remove in_sel 0.0 end
150+
$w_family tag add in_sel $i.0 [expr {$i + 1}].0
151+
set f_family $n
152+
_update $this
153+
}
154+
}
155+
156+
method _update {args} {
157+
variable all_families
158+
159+
set i [lsearch -exact $all_families $f_family]
160+
if {$i < 0} return
161+
162+
$w_example tag conf example -font [list $f_family $f_size]
163+
$w_family see [expr {$i + 1}].0
164+
}
165+
166+
}

0 commit comments

Comments
 (0)