Skip to content

Commit 98cedd0

Browse files
committed
* '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
2 parents 7fcb965 + a572802 commit 98cedd0

File tree

10 files changed

+3981
-2920
lines changed

10 files changed

+3981
-2920
lines changed

git-gui/git-gui--askpass

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ proc finish {} {
5656
}
5757
}
5858

59+
# On Windows, force the encoding to UTF-8: it is what `git.exe` expects
60+
if {$::tcl_platform(platform) eq {windows}} {
61+
set ::answer [encoding convertto utf-8 $::answer]
62+
}
63+
5964
puts $::answer
6065
set ::rc 0
6166
}

git-gui/git-gui.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.}]
3030
##
3131
## Tcl/Tk sanity check
3232

33-
if {[catch {package require Tcl 8.6} err]
34-
|| [catch {package require Tk 8.6} err]
33+
if {[catch {package require Tcl 8.5} err]
34+
|| [catch {package require Tk 8.5} err]
3535
} {
3636
catch {wm withdraw .}
3737
tk_messageBox \
@@ -2205,11 +2205,13 @@ proc do_gitk {revs {is_submodule false}} {
22052205
set env(GIT_WORK_TREE) $_gitworktree
22062206
cd $pwd
22072207
2208-
set status_operation [$::main_status \
2209-
start \
2210-
[mc "Starting %s... please wait..." "gitk"]]
2208+
if {[info exists main_status]} {
2209+
set status_operation [$::main_status \
2210+
start \
2211+
[mc "Starting %s... please wait..." "gitk"]]
22112212
2212-
after 3500 [list $status_operation stop]
2213+
after 3500 [list $status_operation stop]
2214+
}
22132215
}
22142216
}
22152217

git-gui/lib/chord.tcl

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
# # Turn off the UI while running a couple of async operations.
2828
# lock_ui
2929
#
30-
# set chord [SimpleChord new {
30+
# set chord [SimpleChord::new {
3131
# unlock_ui
3232
# # Note: $notice here is not referenced in the calling scope
3333
# if {$notice} { info_popup $notice }
@@ -37,9 +37,9 @@
3737
# # all operations have been initiated.
3838
# set common_note [$chord add_note]
3939
#
40-
# # Pass notes as 'after' callbacks to other operations
41-
# async_operation $args [$chord add_note]
42-
# other_async_operation $args [$chord add_note]
40+
# # Activate notes in 'after' callbacks to other operations
41+
# set newnote [$chord add_note]
42+
# async_operation $args [list $newnote activate]
4343
#
4444
# # Communicate with the chord body
4545
# if {$condition} {
@@ -48,7 +48,7 @@
4848
# }
4949
#
5050
# # Activate the common note, making the chord eligible to complete
51-
# $common_note
51+
# $common_note activate
5252
#
5353
# At this point, the chord will complete at some unknown point in the future.
5454
# The common note might have been the first note activated, or the async
@@ -60,18 +60,23 @@
6060
# Represents a procedure that conceptually has multiple entrypoints that must
6161
# all be called before the procedure executes. Each entrypoint is called a
6262
# "note". The chord is only "completed" when all the notes are "activated".
63-
oo::class create SimpleChord {
64-
variable notes body is_completed
63+
class SimpleChord {
64+
field notes
65+
field body
66+
field is_completed
67+
field eval_ns
6568

6669
# Constructor:
67-
# set chord [SimpleChord new {body}]
70+
# set chord [SimpleChord::new {body}]
6871
# Creates a new chord object with the specified body script. The
6972
# body script is evaluated at most once, when a note is activated
7073
# and the chord has no other non-activated notes.
71-
constructor {body} {
74+
constructor new {i_body} {
7275
set notes [list]
73-
my eval [list set body $body]
76+
set body $i_body
7477
set is_completed 0
78+
set eval_ns "[namespace qualifiers $this]::eval"
79+
return $this
7580
}
7681

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

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

95-
set note [ChordNote new [self]]
100+
set note [ChordNote::new $this]
96101

97102
lappend notes $note
98103

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

109114
set is_completed 1
110115

111-
namespace eval [self] $body
112-
namespace delete [self]
116+
namespace eval $eval_ns $body
117+
delete_this
113118
}
114119
}
115120
}
@@ -119,15 +124,17 @@ oo::class create SimpleChord {
119124
# final note of the chord is activated (this can be any note in the chord,
120125
# with all other notes already previously activated in any order), the chord's
121126
# body is evaluated.
122-
oo::class create ChordNote {
123-
variable chord is_activated
127+
class ChordNote {
128+
field chord
129+
field is_activated
124130

125131
# Constructor:
126132
# Instances of ChordNote are created internally by calling add_note on
127133
# SimpleChord objects.
128-
constructor {chord} {
129-
my eval set chord $chord
134+
constructor new {c} {
135+
set chord $c
130136
set is_activated 0
137+
return $this
131138
}
132139

133140
# Method:
@@ -138,20 +145,11 @@ oo::class create ChordNote {
138145
}
139146

140147
# Method:
141-
# $note
148+
# $note activate
142149
# Activates the note, if it has not already been activated, and
143150
# completes the chord if there are no other notes awaiting
144151
# activation. Subsequent calls will have no further effect.
145-
#
146-
# NB: In TclOO, if an object is invoked like a method without supplying
147-
# any method name, then this internal method `unknown` is what
148-
# actually runs (with no parameters). It is used in the ChordNote
149-
# class for the purpose of allowing the note object to be called as
150-
# a function (see example above). (The `unknown` method can also be
151-
# used to support dynamic dispatch, but must take parameters to
152-
# identify the "unknown" method to be invoked. In this form, this
153-
# proc serves only to make instances behave directly like methods.)
154-
method unknown {} {
152+
method activate {} {
155153
if {!$is_activated} {
156154
set is_activated 1
157155
$chord notify_note_activation

git-gui/lib/index.tcl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ proc revert_helper {txt paths} {
436436
#
437437
# The asynchronous operations are each indicated below by a comment
438438
# before the code block that starts the async operation.
439-
set after_chord [SimpleChord new {
439+
set after_chord [SimpleChord::new {
440440
if {[string trim $err] != ""} {
441441
rescan_on_error $err
442442
} else {
@@ -522,10 +522,11 @@ proc revert_helper {txt paths} {
522522
]
523523

524524
if {$reply == 1} {
525+
set note [$after_chord add_note]
525526
checkout_index \
526527
$txt \
527528
$path_list \
528-
[$after_chord add_note] \
529+
[list $note activate] \
529530
$capture_error
530531
}
531532
}
@@ -567,14 +568,15 @@ proc revert_helper {txt paths} {
567568
if {$reply == 1} {
568569
$after_chord eval { set should_reshow_diff 1 }
569570

570-
delete_files $untracked_list [$after_chord add_note]
571+
set note [$after_chord add_note]
572+
delete_files $untracked_list [list $note activate]
571573
}
572574
}
573575

574576
# Activate the common note. If no other notes were created, this
575577
# completes the chord. If other notes were created, then this common
576578
# note prevents a race condition where the chord might complete early.
577-
$after_common_note
579+
$after_common_note activate
578580
}
579581

580582
# Delete all of the specified files, performing deletion in batches to allow the

git-gui/lib/merge.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ Continue with resetting the current changes?"]
244244
set status_bar_operation [$::main_status \
245245
start \
246246
[mc "Aborting"] \
247-
[mc "files reset"]
247+
[mc "files reset"]]
248248
fileevent $fd readable [namespace code [list \
249249
_reset_wait $fd $status_bar_operation]]
250250
} else {

0 commit comments

Comments
 (0)