mirror of
https://github.com/git/git.git
synced 2024-10-31 06:17:56 +01:00
git-gui: Implement automatic rescan after Tool execution.
The Tools menu is generally intended for commands that affect the working directory or repository state. Thus, the user would usually want to initiate rescan after execution of a tool. This commit implements it. In case somebody would want to avoid rescanning after certain tools, it also adds an option that controls it, although it is not made available through the Add dialog. Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
This commit is contained in:
parent
67df911cee
commit
b8dfb16d36
1 changed files with 42 additions and 2 deletions
|
@ -102,13 +102,15 @@ proc tools_exec {fullname} {
|
||||||
|
|
||||||
set cmdline $repo_config(guitool.$fullname.cmd)
|
set cmdline $repo_config(guitool.$fullname.cmd)
|
||||||
if {[is_config_true "guitool.$fullname.noconsole"]} {
|
if {[is_config_true "guitool.$fullname.noconsole"]} {
|
||||||
exec sh -c $cmdline &
|
tools_run_silent [list sh -c $cmdline] \
|
||||||
|
[list tools_complete $fullname {}]
|
||||||
} else {
|
} else {
|
||||||
regsub {/} $fullname { / } title
|
regsub {/} $fullname { / } title
|
||||||
set w [console::new \
|
set w [console::new \
|
||||||
[mc "Tool: %s" $title] \
|
[mc "Tool: %s" $title] \
|
||||||
[mc "Running: %s" $cmdline]]
|
[mc "Running: %s" $cmdline]]
|
||||||
console::exec $w [list sh -c $cmdline]
|
console::exec $w [list sh -c $cmdline] \
|
||||||
|
[list tools_complete $fullname $w]
|
||||||
}
|
}
|
||||||
|
|
||||||
unset env(GIT_GUITOOL)
|
unset env(GIT_GUITOOL)
|
||||||
|
@ -117,3 +119,41 @@ proc tools_exec {fullname} {
|
||||||
catch { unset env(ARGS) }
|
catch { unset env(ARGS) }
|
||||||
catch { unset env(REVISION) }
|
catch { unset env(REVISION) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
proc tools_run_silent {cmd after} {
|
||||||
|
lappend cmd 2>@1
|
||||||
|
set fd [_open_stdout_stderr $cmd]
|
||||||
|
|
||||||
|
fconfigure $fd -blocking 0 -translation binary
|
||||||
|
fileevent $fd readable [list tools_consume_input $fd $after]
|
||||||
|
}
|
||||||
|
|
||||||
|
proc tools_consume_input {fd after} {
|
||||||
|
read $fd
|
||||||
|
if {[eof $fd]} {
|
||||||
|
fconfigure $fd -blocking 1
|
||||||
|
if {[catch {close $fd}]} {
|
||||||
|
uplevel #0 $after 0
|
||||||
|
} else {
|
||||||
|
uplevel #0 $after 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
proc tools_complete {fullname w {ok 1}} {
|
||||||
|
if {$w ne {}} {
|
||||||
|
console::done $w $ok
|
||||||
|
}
|
||||||
|
|
||||||
|
if {$ok} {
|
||||||
|
set msg [mc "Tool completed succesfully: %s" $fullname]
|
||||||
|
} else {
|
||||||
|
set msg [mc "Tool failed: %s" $fullname]
|
||||||
|
}
|
||||||
|
|
||||||
|
if {[is_config_true "guitool.$fullname.norescan"]} {
|
||||||
|
ui_status $msg
|
||||||
|
} else {
|
||||||
|
rescan [list ui_status $msg]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue