Skip to content

Commit 73c6b35

Browse files
committed
Merge branch 'master' of git://repo.or.cz/git-gui
* 'master' of git://repo.or.cz/git-gui: (28 commits) git-gui 0.16 git-gui: handle shell script text filters when loading for blame. git-gui: Set both 16x16 and 32x32 icons on X to pacify Xming. git-gui: added config gui.gcwarning to disable the gc hint message git-gui: set whitespace warnings appropriate to this project git-gui: don't warn for detached head when rebasing git-gui: make config gui.warndetachedcommit a boolean git-gui: add config value gui.diffopts for passing additional diff options git-gui: sort the numeric ansi codes git-gui: support underline style when parsing diff output git-gui: fix spelling error in sshkey.tcl git-gui: include the file path in guitools confirmation dialog git-gui: span widgets over the full file output area in the blame view git-gui: use a tristate to control the case mode in the searchbar git-gui: set suitable extended window manager hints. git-gui: fix display of path in browser title git-gui: enable the smart case sensitive search only if gui.search.smartcase is true git-gui: catch invalid or complete regular expressions and treat as no match. git-gui: theme the search and line-number entry fields on blame screen git-gui: include the number of untracked files to stage when asking the user ...
2 parents 57526fd + 942e6ba commit 73c6b35

17 files changed

+339
-49
lines changed

git-gui/.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
* whitespace=indent-with-non-tab,trailing-space,space-before-tab,tabwidth=4
12
* encoding=US-ASCII
23
git-gui.sh encoding=UTF-8
34
/po/*.po encoding=UTF-8

git-gui/GIT-VERSION-GEN

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

33
GVF=GIT-VERSION-FILE
4-
DEF_VER=0.13.GITGUI
4+
DEF_VER=0.16.GITGUI
55

66
LF='
77
'

git-gui/git-gui.sh

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,9 @@ proc is_config_true {name} {
299299
global repo_config
300300
if {[catch {set v $repo_config($name)}]} {
301301
return 0
302-
} elseif {$v eq {true} || $v eq {1} || $v eq {yes}} {
302+
}
303+
set v [string tolower $v]
304+
if {$v eq {} || $v eq {true} || $v eq {1} || $v eq {yes} || $v eq {on}} {
303305
return 1
304306
} else {
305307
return 0
@@ -310,7 +312,9 @@ proc is_config_false {name} {
310312
global repo_config
311313
if {[catch {set v $repo_config($name)}]} {
312314
return 0
313-
} elseif {$v eq {false} || $v eq {0} || $v eq {no}} {
315+
}
316+
set v [string tolower $v]
317+
if {$v eq {false} || $v eq {0} || $v eq {no} || $v eq {off}} {
314318
return 1
315319
} else {
316320
return 0
@@ -460,6 +464,35 @@ proc _which {what args} {
460464
return {}
461465
}
462466
467+
# Test a file for a hashbang to identify executable scripts on Windows.
468+
proc is_shellscript {filename} {
469+
if {![file exists $filename]} {return 0}
470+
set f [open $filename r]
471+
fconfigure $f -encoding binary
472+
set magic [read $f 2]
473+
close $f
474+
return [expr {$magic eq "#!"}]
475+
}
476+
477+
# Run a command connected via pipes on stdout.
478+
# This is for use with textconv filters and uses sh -c "..." to allow it to
479+
# contain a command with arguments. On windows we must check for shell
480+
# scripts specifically otherwise just call the filter command.
481+
proc open_cmd_pipe {cmd path} {
482+
global env
483+
if {![file executable [shellpath]]} {
484+
set exe [auto_execok [lindex $cmd 0]]
485+
if {[is_shellscript [lindex $exe 0]]} {
486+
set run [linsert [auto_execok sh] end -c "$cmd \"\$0\"" $path]
487+
} else {
488+
set run [concat $exe [lrange $cmd 1 end] $path]
489+
}
490+
} else {
491+
set run [list [shellpath] -c "$cmd \"\$0\"" $path]
492+
}
493+
return [open |$run r]
494+
}
495+
463496
proc _lappend_nice {cmd_var} {
464497
global _nice
465498
upvar $cmd_var cmd
@@ -725,7 +758,10 @@ if {[is_Windows]} {
725758
gitlogo put gray26 -to 5 15 11 16
726759
gitlogo redither
727760
728-
wm iconphoto . -default gitlogo
761+
image create photo gitlogo32 -width 32 -height 32
762+
gitlogo32 copy gitlogo -zoom 2 2
763+
764+
wm iconphoto . -default gitlogo gitlogo32
729765
}
730766
}
731767
@@ -846,6 +882,7 @@ set default_config(gui.fastcopyblame) false
846882
set default_config(gui.copyblamethreshold) 40
847883
set default_config(gui.blamehistoryctx) 7
848884
set default_config(gui.diffcontext) 5
885+
set default_config(gui.diffopts) {}
849886
set default_config(gui.commitmsgwidth) 75
850887
set default_config(gui.newbranchtemplate) {}
851888
set default_config(gui.spellingdictionary) {}
@@ -859,6 +896,7 @@ set font_descs {
859896
{fontui font_ui {mc "Main Font"}}
860897
{fontdiff font_diff {mc "Diff/Console Font"}}
861898
}
899+
set default_config(gui.stageuntracked) ask
862900
863901
######################################################################
864902
##
@@ -1060,6 +1098,10 @@ git-version proc _parse_config {arr_name args} {
10601098
} else {
10611099
set arr($name) $value
10621100
}
1101+
} elseif {[regexp {^([^\n]+)$} $line line name]} {
1102+
# no value given, but interpreting them as
1103+
# boolean will be handled as true
1104+
set arr($name) {}
10631105
}
10641106
}
10651107
}
@@ -1075,6 +1117,10 @@ git-version proc _parse_config {arr_name args} {
10751117
} else {
10761118
set arr($name) $value
10771119
}
1120+
} elseif {[regexp {^([^=]+)$} $line line name]} {
1121+
# no value given, but interpreting them as
1122+
# boolean will be handled as true
1123+
set arr($name) {}
10781124
}
10791125
}
10801126
close $fd_rc
@@ -2474,6 +2520,7 @@ proc toggle_or_diff {w x y} {
24742520
[concat $after [list ui_ready]]
24752521
}
24762522
} else {
2523+
set selected_paths($path) 1
24772524
show_diff $path $w $lno
24782525
}
24792526
}
@@ -3362,6 +3409,7 @@ foreach {n c} {0 black 1 red4 2 green4 3 yellow4 4 blue4 5 magenta4 6 cyan4 7 gr
33623409
$ui_diff tag configure clri3$n -background $c
33633410
}
33643411
$ui_diff tag configure clr1 -font font_diffbold
3412+
$ui_diff tag configure clr4 -underline 1
33653413
33663414
$ui_diff tag conf d_info -foreground blue -font font_diffbold
33673415
@@ -3878,7 +3926,7 @@ after 1 {
38783926
$ui_comm configure -state disabled -background gray
38793927
}
38803928
}
3881-
if {[is_enabled multicommit]} {
3929+
if {[is_enabled multicommit] && ![is_config_false gui.gcwarning]} {
38823930
after 1000 hint_gc
38833931
}
38843932
if {[is_enabled retcode]} {

git-gui/lib/blame.tcl

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,8 @@ constructor new {i_commit i_path i_jump} {
219219
eval grid $w_columns $w.file_pane.out.sby -sticky nsew
220220
grid conf \
221221
$w.file_pane.out.sbx \
222-
-column [expr {[llength $w_columns] - 1}] \
222+
-column 0 \
223+
-columnspan [expr {[llength $w_columns] + 1}] \
223224
-sticky we
224225
grid columnconfigure \
225226
$w.file_pane.out \
@@ -229,12 +230,14 @@ constructor new {i_commit i_path i_jump} {
229230

230231
set finder [::searchbar::new \
231232
$w.file_pane.out.ff $w_file \
232-
-column [expr {[llength $w_columns] - 1}] \
233+
-column 0 \
234+
-columnspan [expr {[llength $w_columns] + 1}] \
233235
]
234236

235237
set gotoline [::linebar::new \
236238
$w.file_pane.out.lf $w_file \
237-
-column [expr {[llength $w_columns] - 1}] \
239+
-column 0 \
240+
-columnspan [expr {[llength $w_columns] + 1}] \
238241
]
239242

240243
set w_cviewer $w.file_pane.cm.t
@@ -473,14 +476,7 @@ method _load {jump} {
473476
}
474477
if {$commit eq {}} {
475478
if {$do_textconv ne 0} {
476-
# Run textconv with sh -c "..." to allow it to
477-
# contain command + arguments. On windows, just
478-
# call the filter command.
479-
if {![file executable [shellpath]]} {
480-
set fd [open |[linsert $textconv end $path] r]
481-
} else {
482-
set fd [open |[list [shellpath] -c "$textconv \"\$0\"" $path] r]
483-
}
479+
set fd [open_cmd_pipe $textconv $path]
484480
} else {
485481
set fd [open $path r]
486482
}
@@ -572,7 +568,11 @@ method _read_file {fd jump} {
572568
foreach i $w_columns {$i conf -state disabled}
573569

574570
if {[eof $fd]} {
575-
close $fd
571+
fconfigure $fd -blocking 1; # enable error reporting on close
572+
if {[catch {close $fd} err]} {
573+
tk_messageBox -icon error -title [mc Error] \
574+
-message $err
575+
}
576576

577577
# If we don't force Tk to update the widgets *right now*
578578
# none of our jump commands will cause a change in the UI.
@@ -1062,7 +1062,7 @@ method _gitkcommit {} {
10621062
set radius [get_config gui.blamehistoryctx]
10631063
set cmdline [list --select-commit=$cmit]
10641064

1065-
if {$radius > 0} {
1065+
if {$radius > 0} {
10661066
set author_time {}
10671067
set committer_time {}
10681068

@@ -1170,7 +1170,7 @@ method _read_diff_load_commit {fd cparent new_path tline} {
11701170
}
11711171

11721172
if {[eof $fd]} {
1173-
close $fd;
1173+
close $fd
11741174
set current_fd {}
11751175

11761176
_load_new_commit $this \
@@ -1201,6 +1201,7 @@ method _open_tooltip {cur_w} {
12011201
_hide_tooltip $this
12021202

12031203
set tooltip_wm [toplevel $cur_w.tooltip -borderwidth 1]
1204+
catch {wm attributes $tooltip_wm -type tooltip}
12041205
wm overrideredirect $tooltip_wm 1
12051206
wm transient $tooltip_wm [winfo toplevel $cur_w]
12061207
set tooltip_t $tooltip_wm.label

git-gui/lib/browser.tcl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,14 @@ constructor new {commit {path {}}} {
2626
wm withdraw $top
2727
wm title $top [append "[appname] ([reponame]): " [mc "File Browser"]]
2828

29+
if {$path ne {}} {
30+
if {[string index $path end] ne {/}} {
31+
append path /
32+
}
33+
}
34+
2935
set browser_commit $commit
30-
set browser_path $browser_commit:$path
36+
set browser_path "$browser_commit:[escape_path $path]"
3137

3238
${NS}::label $w.path \
3339
-textvariable @browser_path \

git-gui/lib/choose_rev.tcl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,7 @@ method _open_tooltip {} {
497497

498498
if {$tooltip_wm eq {}} {
499499
set tooltip_wm [toplevel $w_list.tooltip -borderwidth 1]
500+
catch {wm attributes $tooltip_wm -type tooltip}
500501
wm overrideredirect $tooltip_wm 1
501502
wm transient $tooltip_wm [winfo toplevel $w_list]
502503
set tooltip_t $tooltip_wm.label

git-gui/lib/class.tcl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ proc make_dialog {t w args} {
138138
upvar $t top $w pfx this this
139139
global use_ttk
140140
uplevel [linsert $args 0 make_toplevel $t $w]
141+
catch {wm attributes $top -type dialog}
141142
pave_toplevel $pfx
142143
}
143144

git-gui/lib/commit.tcl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,9 @@ proc commit_commitmsg {curHEAD msg_p} {
263263
global is_detached repo_config
264264
global pch_error
265265

266-
if {$is_detached && $repo_config(gui.warndetachedcommit)} {
266+
if {$is_detached
267+
&& ![file exists [gitdir rebase-merge head-name]]
268+
&& [is_config_true gui.warndetachedcommit]} {
267269
set msg [mc "You are about to commit on a detached head.\
268270
This is a potentially dangerous thing to do because if you switch\
269271
to another branch you will loose your changes and it can be difficult\

git-gui/lib/diff.tcl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ proc start_show_diff {cont_info {add_opts {}}} {
309309

310310
lappend cmd -p
311311
lappend cmd --color
312+
set cmd [concat $cmd $repo_config(gui.diffopts)]
312313
if {$repo_config(gui.diffcontext) >= 1} {
313314
lappend cmd "-U$repo_config(gui.diffcontext)"
314315
}
@@ -502,9 +503,9 @@ proc read_diff {fd conflict_size cont_info} {
502503

503504
foreach {posbegin colbegin posend colend} $markup {
504505
set prefix clr
505-
foreach style [split $colbegin ";"] {
506+
foreach style [lsort -integer [split $colbegin ";"]] {
506507
if {$style eq "7"} {append prefix i; continue}
507-
if {$style < 30 || $style > 47} {continue}
508+
if {$style != 4 && ($style < 30 || $style > 47)} {continue}
508509
set a "$mark linestart + $posbegin chars"
509510
set b "$mark linestart + $posend chars"
510511
catch {$ui_diff tag add $prefix$style $a $b}

git-gui/lib/index.tcl

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -356,21 +356,33 @@ proc do_add_all {} {
356356
global file_states
357357

358358
set paths [list]
359-
set unknown_paths [list]
359+
set untracked_paths [list]
360360
foreach path [array names file_states] {
361361
switch -glob -- [lindex $file_states($path) 0] {
362362
U? {continue}
363363
?M -
364364
?T -
365365
?D {lappend paths $path}
366-
?O {lappend unknown_paths $path}
366+
?O {lappend untracked_paths $path}
367367
}
368368
}
369-
if {[llength $unknown_paths]} {
370-
set reply [ask_popup [mc "There are unknown files do you also want
371-
to stage those?"]]
369+
if {[llength $untracked_paths]} {
370+
set reply 0
371+
switch -- [get_config gui.stageuntracked] {
372+
no {
373+
set reply 0
374+
}
375+
yes {
376+
set reply 1
377+
}
378+
ask -
379+
default {
380+
set reply [ask_popup [mc "Stage %d untracked files?" \
381+
[llength $untracked_paths]]]
382+
}
383+
}
372384
if {$reply} {
373-
set paths [concat $paths $unknown_paths]
385+
set paths [concat $paths $untracked_paths]
374386
}
375387
}
376388
add_helper {Adding all changed files} $paths

0 commit comments

Comments
 (0)