Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* 'master' of https://github.com/prati0100/git-gui:
  git-gui: create a new namespace for chord script evaluation
  git-gui: reduce Tcl version requirement from 8.6 to 8.5
  git-gui--askpass: coerce answers to UTF-8 on Windows
  git-gui: fix error popup when doing blame -> "Show History Context"
  git-gui: add missing close bracket
  git-gui: update German translation
  git-gui: extend translation glossary template with more terms
  git-gui: update pot template and German translation to current source code
  • Loading branch information
gitster committed Mar 19, 2020
2 parents 7fcb965 + a572802 commit 98cedd0
Show file tree
Hide file tree
Showing 10 changed files with 3,981 additions and 2,920 deletions.
5 changes: 5 additions & 0 deletions git-gui/git-gui--askpass
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ proc finish {} {
}
}

# On Windows, force the encoding to UTF-8: it is what `git.exe` expects
if {$::tcl_platform(platform) eq {windows}} {
set ::answer [encoding convertto utf-8 $::answer]
}

puts $::answer
set ::rc 0
}
Expand Down
14 changes: 8 additions & 6 deletions git-gui/git-gui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.}]
##
## Tcl/Tk sanity check

if {[catch {package require Tcl 8.6} err]
|| [catch {package require Tk 8.6} err]
if {[catch {package require Tcl 8.5} err]
|| [catch {package require Tk 8.5} err]
} {
catch {wm withdraw .}
tk_messageBox \
Expand Down Expand Up @@ -2205,11 +2205,13 @@ proc do_gitk {revs {is_submodule false}} {
set env(GIT_WORK_TREE) $_gitworktree
cd $pwd
set status_operation [$::main_status \
start \
[mc "Starting %s... please wait..." "gitk"]]
if {[info exists main_status]} {
set status_operation [$::main_status \
start \
[mc "Starting %s... please wait..." "gitk"]]
after 3500 [list $status_operation stop]
after 3500 [list $status_operation stop]
}
}
}
Expand Down
56 changes: 27 additions & 29 deletions git-gui/lib/chord.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
# # Turn off the UI while running a couple of async operations.
# lock_ui
#
# set chord [SimpleChord new {
# set chord [SimpleChord::new {
# unlock_ui
# # Note: $notice here is not referenced in the calling scope
# if {$notice} { info_popup $notice }
Expand All @@ -37,9 +37,9 @@
# # all operations have been initiated.
# set common_note [$chord add_note]
#
# # Pass notes as 'after' callbacks to other operations
# async_operation $args [$chord add_note]
# other_async_operation $args [$chord add_note]
# # Activate notes in 'after' callbacks to other operations
# set newnote [$chord add_note]
# async_operation $args [list $newnote activate]
#
# # Communicate with the chord body
# if {$condition} {
Expand All @@ -48,7 +48,7 @@
# }
#
# # Activate the common note, making the chord eligible to complete
# $common_note
# $common_note activate
#
# At this point, the chord will complete at some unknown point in the future.
# The common note might have been the first note activated, or the async
Expand All @@ -60,18 +60,23 @@
# Represents a procedure that conceptually has multiple entrypoints that must
# all be called before the procedure executes. Each entrypoint is called a
# "note". The chord is only "completed" when all the notes are "activated".
oo::class create SimpleChord {
variable notes body is_completed
class SimpleChord {
field notes
field body
field is_completed
field eval_ns

# Constructor:
# set chord [SimpleChord new {body}]
# set chord [SimpleChord::new {body}]
# Creates a new chord object with the specified body script. The
# body script is evaluated at most once, when a note is activated
# and the chord has no other non-activated notes.
constructor {body} {
constructor new {i_body} {
set notes [list]
my eval [list set body $body]
set body $i_body
set is_completed 0
set eval_ns "[namespace qualifiers $this]::eval"
return $this
}

# Method:
Expand All @@ -80,7 +85,7 @@ oo::class create SimpleChord {
# the chord body will be evaluated. This can be used to set variable
# values for the chord body to use.
method eval {script} {
namespace eval [self] $script
namespace eval $eval_ns $script
}

# Method:
Expand All @@ -92,7 +97,7 @@ oo::class create SimpleChord {
method add_note {} {
if {$is_completed} { error "Cannot add a note to a completed chord" }

set note [ChordNote new [self]]
set note [ChordNote::new $this]

lappend notes $note

Expand All @@ -108,8 +113,8 @@ oo::class create SimpleChord {

set is_completed 1

namespace eval [self] $body
namespace delete [self]
namespace eval $eval_ns $body
delete_this
}
}
}
Expand All @@ -119,15 +124,17 @@ oo::class create SimpleChord {
# final note of the chord is activated (this can be any note in the chord,
# with all other notes already previously activated in any order), the chord's
# body is evaluated.
oo::class create ChordNote {
variable chord is_activated
class ChordNote {
field chord
field is_activated

# Constructor:
# Instances of ChordNote are created internally by calling add_note on
# SimpleChord objects.
constructor {chord} {
my eval set chord $chord
constructor new {c} {
set chord $c
set is_activated 0
return $this
}

# Method:
Expand All @@ -138,20 +145,11 @@ oo::class create ChordNote {
}

# Method:
# $note
# $note activate
# Activates the note, if it has not already been activated, and
# completes the chord if there are no other notes awaiting
# activation. Subsequent calls will have no further effect.
#
# NB: In TclOO, if an object is invoked like a method without supplying
# any method name, then this internal method `unknown` is what
# actually runs (with no parameters). It is used in the ChordNote
# class for the purpose of allowing the note object to be called as
# a function (see example above). (The `unknown` method can also be
# used to support dynamic dispatch, but must take parameters to
# identify the "unknown" method to be invoked. In this form, this
# proc serves only to make instances behave directly like methods.)
method unknown {} {
method activate {} {
if {!$is_activated} {
set is_activated 1
$chord notify_note_activation
Expand Down
10 changes: 6 additions & 4 deletions git-gui/lib/index.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ proc revert_helper {txt paths} {
#
# The asynchronous operations are each indicated below by a comment
# before the code block that starts the async operation.
set after_chord [SimpleChord new {
set after_chord [SimpleChord::new {
if {[string trim $err] != ""} {
rescan_on_error $err
} else {
Expand Down Expand Up @@ -522,10 +522,11 @@ proc revert_helper {txt paths} {
]

if {$reply == 1} {
set note [$after_chord add_note]
checkout_index \
$txt \
$path_list \
[$after_chord add_note] \
[list $note activate] \
$capture_error
}
}
Expand Down Expand Up @@ -567,14 +568,15 @@ proc revert_helper {txt paths} {
if {$reply == 1} {
$after_chord eval { set should_reshow_diff 1 }

delete_files $untracked_list [$after_chord add_note]
set note [$after_chord add_note]
delete_files $untracked_list [list $note activate]
}
}

# Activate the common note. If no other notes were created, this
# completes the chord. If other notes were created, then this common
# note prevents a race condition where the chord might complete early.
$after_common_note
$after_common_note activate
}

# Delete all of the specified files, performing deletion in batches to allow the
Expand Down
2 changes: 1 addition & 1 deletion git-gui/lib/merge.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ Continue with resetting the current changes?"]
set status_bar_operation [$::main_status \
start \
[mc "Aborting"] \
[mc "files reset"]
[mc "files reset"]]
fileevent $fd readable [namespace code [list \
_reset_wait $fd $status_bar_operation]]
} else {
Expand Down
Loading

0 comments on commit 98cedd0

Please sign in to comment.