Skip to content

Commit ab427cd

Browse files
committed
Merge branch 'master' of https://github.com/j6t/git-gui
* 'master' of https://github.com/j6t/git-gui: git-gui: sync Makefiles with git.git git-gui: fix error handling of Revert Changes command git-gui--askyesno (mingw): use Git for Windows' icon, if available git-gui--askyesno: allow overriding the window title git gui: set GIT_ASKPASS=git-gui--askpass if not set yet git-gui: provide question helper for retry fallback on Windows git-gui: simplify using nice(1) git-gui: simplify PATH de-duplication
2 parents f2457a6 + 7ef77ec commit ab427cd

File tree

4 files changed

+85
-29
lines changed

4 files changed

+85
-29
lines changed

git-gui/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ install: all
186186
$(QUIET)$(INSTALL_D0)'$(DESTDIR_SQ)$(gitexecdir_SQ)' $(INSTALL_D1)
187187
$(QUIET)$(INSTALL_X0)git-gui $(INSTALL_X1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
188188
$(QUIET)$(INSTALL_X0)git-gui--askpass $(INSTALL_X1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
189+
$(QUIET)$(INSTALL_X0)git-gui--askyesno $(INSTALL_X1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
189190
$(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
190191
ifdef GITGUI_WINDOWS_WRAPPER
191192
$(QUIET)$(INSTALL_R0)git-gui.tcl $(INSTALL_R1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
@@ -200,6 +201,7 @@ uninstall:
200201
$(QUIET)$(CLEAN_DST) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
201202
$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui $(REMOVE_F1)
202203
$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui--askpass $(REMOVE_F1)
204+
$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui--askyesno $(REMOVE_F1)
203205
$(QUIET)$(foreach p,$(GITGUI_BUILT_INS), $(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/$p $(REMOVE_F1) &&) true
204206
ifdef GITGUI_WINDOWS_WRAPPER
205207
$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui.tcl $(REMOVE_F1)

git-gui/git-gui--askyesno

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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+
# The window title, which defaults to "Question?", can be
10+
# overridden via the optional `--title` command-line
11+
# option.
12+
13+
set NS {}
14+
set use_ttk [package vsatisfies [package provide Tk] 8.5]
15+
if {$use_ttk} {
16+
set NS ttk
17+
}
18+
19+
set title "Question?"
20+
if {$argc < 1} {
21+
puts stderr "Usage: $argv0 <question>"
22+
exit 1
23+
} else {
24+
if {$argc > 2 && [lindex $argv 0] == "--title"} {
25+
set title [lindex $argv 1]
26+
set argv [lreplace $argv 0 1]
27+
}
28+
set prompt [join $argv " "]
29+
}
30+
31+
${NS}::frame .t
32+
${NS}::label .t.m -text $prompt -justify center -width 40
33+
.t.m configure -wraplength 400
34+
pack .t.m -side top -fill x -padx 20 -pady 20 -expand 1
35+
pack .t -side top -fill x -ipadx 20 -ipady 20 -expand 1
36+
37+
${NS}::frame .b
38+
${NS}::frame .b.left -width 200
39+
${NS}::button .b.yes -text Yes -command {exit 0}
40+
${NS}::button .b.no -text No -command {exit 1}
41+
42+
pack .b.left -side left -expand 1 -fill x
43+
pack .b.yes -side left -expand 1
44+
pack .b.no -side right -expand 1 -ipadx 5
45+
pack .b -side bottom -fill x -ipadx 20 -ipady 15
46+
47+
bind . <Key-Return> {exit 0}
48+
bind . <Key-Escape> {exit 1}
49+
50+
if {$::tcl_platform(platform) eq {windows}} {
51+
set icopath [file dirname [file normalize $argv0]]
52+
if {[file tail $icopath] eq {git-core}} {
53+
set icopath [file dirname $icopath]
54+
}
55+
set icopath [file dirname $icopath]
56+
set icopath [file join $icopath share git git-for-windows.ico]
57+
if {[file exists $icopath]} {
58+
wm iconbitmap . -default $icopath
59+
}
60+
}
61+
62+
wm title . $title
63+
tk::PlaceWindow .

git-gui/git-gui.sh

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ if {[is_Windows]} {
103103
set _path_sep {:}
104104
}
105105

106-
set _search_path {}
107106
set _path_seen [dict create]
108107
foreach p [split $env(PATH) $_path_sep] {
109108
# Keep only absolute paths, getting rid of ., empty, etc.
@@ -112,12 +111,9 @@ foreach p [split $env(PATH) $_path_sep] {
112111
}
113112
# Keep only the first occurence of any duplicates.
114113
set norm_p [file normalize $p]
115-
if {[dict exists $_path_seen $norm_p]} {
116-
continue
117-
}
118114
dict set _path_seen $norm_p 1
119-
lappend _search_path $norm_p
120115
}
116+
set _search_path [dict keys $_path_seen]
121117
unset _path_seen
122118

123119
set env(PATH) [join $_search_path $_path_sep]
@@ -583,21 +579,6 @@ proc open_cmd_pipe {cmd path} {
583579
return [open |$run r]
584580
}
585581

586-
proc _lappend_nice {cmd_var} {
587-
global _nice
588-
upvar $cmd_var cmd
589-
590-
if {![info exists _nice]} {
591-
set _nice [_which nice]
592-
if {[catch {safe_exec [list $_nice git version]}]} {
593-
set _nice {}
594-
}
595-
}
596-
if {$_nice ne {}} {
597-
lappend cmd $_nice
598-
}
599-
}
600-
601582
proc git {args} {
602583
git_redir $args {}
603584
}
@@ -631,15 +612,14 @@ proc git_read {cmd {redir {}}} {
631612
return [safe_open_command $cmdp $redir]
632613
}
633614

634-
proc git_read_nice {cmd} {
635-
global _git
636-
set opt [list]
637-
638-
_lappend_nice opt
639-
640-
set cmdp [concat [list $_git] $cmd]
615+
set _nice [list [_which nice]]
616+
if {[catch {safe_exec [list {*}$_nice git version]}]} {
617+
set _nice {}
618+
}
641619

642-
return [safe_open_command [concat $opt $cmdp]]
620+
proc git_read_nice {cmd} {
621+
set cmdp [list {*}$::_nice $::_git {*}$cmd]
622+
return [safe_open_command $cmdp]
643623
}
644624

645625
proc git_write {cmd} {
@@ -1130,6 +1110,12 @@ set argv0dir [file dirname [file normalize $::argv0]]
11301110
if {![info exists env(SSH_ASKPASS)]} {
11311111
set env(SSH_ASKPASS) [file join $argv0dir git-gui--askpass]
11321112
}
1113+
if {![info exists env(GIT_ASKPASS)]} {
1114+
set env(GIT_ASKPASS) [file join $argv0dir git-gui--askpass]
1115+
}
1116+
if {![info exists env(GIT_ASK_YESNO)]} {
1117+
set env(GIT_ASK_YESNO) [file join $argv0dir git-gui--askyesno]
1118+
}
11331119
unset argv0dir
11341120

11351121
######################################################################

git-gui/lib/index.tcl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,14 +425,19 @@ proc revert_helper {txt paths} {
425425

426426
if {![lock_index begin-update]} return
427427

428+
# Workaround for Tcl < 9.0: chord namespaces are not obeyed and
429+
# operated in the global namespace. This clears an error that could
430+
# have been left over from a previous operation.
431+
set ::err {}
432+
428433
# Common "after" functionality that waits until multiple asynchronous
429434
# operations are complete (by waiting for them to activate their notes
430435
# on the chord).
431436
#
432437
# The asynchronous operations are each indicated below by a comment
433438
# before the code block that starts the async operation.
434439
set after_chord [SimpleChord::new {
435-
if {[string trim $err] != ""} {
440+
if {[info exists err] && [string trim $err] ne ""} {
436441
rescan_on_error $err
437442
} else {
438443
unlock_index

0 commit comments

Comments
 (0)