Skip to content

Commit a8816e7

Browse files
committed
Merge git://repo.or.cz/git-gui
* git://repo.or.cz/git-gui: git-gui: Fixes for Mac OS X TkAqua git-gui: Update Russian translation git-gui: run post-checkout hook after clone git-gui: Ensure consistent usage of mergetool.keepBackup git-gui: fix use of undeclared variable diff_empty_count git-gui (Win): make starting via "Git GUI Here" on .git/ possible git-gui (Win): make "Explore Working Copy" more robust git-gui: run post-checkout hook on checkout git-gui: When calling post-commit hook wrong variable was cleared. git-gui: use `git --html-path` to get the location of installed HTML docs git-gui: fix deleting from the context menu with empty selection git-gui: minor spelling fix and string factorisation. git-gui: various French translation fixes git-gui: Fix merge conflict display error when filename contains spaces git-gui: don't hide the Browse button when resizing the repo chooser Append ampersand to "Target" of lnk files created by do_cygwin_shortcut git-gui: Support more git version notations. git-gui: Avoid an infinite rescan loop in handle_empty_diff. git-gui: Fix post-commit status with subject in non-locale encoding
2 parents 1087aba + a91be3f commit a8816e7

22 files changed

+1254
-657
lines changed

git-gui/Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,11 @@ endif
105105

106106
ifeq ($(uname_S),Darwin)
107107
TKFRAMEWORK = /Library/Frameworks/Tk.framework/Resources/Wish.app
108-
ifeq ($(shell expr "$(uname_R)" : '9\.'),2)
109-
TKFRAMEWORK = /System/Library/Frameworks/Tk.framework/Resources/Wish\ Shell.app
108+
ifeq ($(shell echo "$(uname_R)" | awk -F. '{if ($$1 >= 9) print "y"}')_$(shell test -d $(TKFRAMEWORK) || echo n),y_n)
109+
TKFRAMEWORK = /System/Library/Frameworks/Tk.framework/Resources/Wish.app
110+
ifeq ($(shell test -d $(TKFRAMEWORK) || echo n),n)
111+
TKFRAMEWORK = /System/Library/Frameworks/Tk.framework/Resources/Wish\ Shell.app
112+
endif
110113
endif
111114
TKEXECUTABLE = $(shell basename "$(TKFRAMEWORK)" .app)
112115
endif

git-gui/git-gui.sh

Lines changed: 52 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ unset oguimsg
122122
set _appname {Git Gui}
123123
set _gitdir {}
124124
set _gitexec {}
125+
set _githtmldir {}
125126
set _reponame {}
126127
set _iscygwin {}
127128
set _search_path {}
@@ -168,6 +169,28 @@ proc gitexec {args} {
168169
return [eval [list file join $_gitexec] $args]
169170
}
170171

172+
proc githtmldir {args} {
173+
global _githtmldir
174+
if {$_githtmldir eq {}} {
175+
if {[catch {set _githtmldir [git --html-path]}]} {
176+
# Git not installed or option not yet supported
177+
return {}
178+
}
179+
if {[is_Cygwin]} {
180+
set _githtmldir [exec cygpath \
181+
--windows \
182+
--absolute \
183+
$_githtmldir]
184+
} else {
185+
set _githtmldir [file normalize $_githtmldir]
186+
}
187+
}
188+
if {$args eq {}} {
189+
return $_githtmldir
190+
}
191+
return [eval [list file join $_githtmldir] $args]
192+
}
193+
171194
proc reponame {} {
172195
return $::_reponame
173196
}
@@ -640,10 +663,13 @@ font create font_diffbold
640663
font create font_diffitalic
641664
642665
foreach class {Button Checkbutton Entry Label
643-
Labelframe Listbox Menu Message
666+
Labelframe Listbox Message
644667
Radiobutton Spinbox Text} {
645668
option add *$class.font font_ui
646669
}
670+
if {![is_MacOSX]} {
671+
option add *Menu.font font_ui
672+
}
647673
unset class
648674
649675
if {[is_Windows] || [is_MacOSX]} {
@@ -699,7 +725,7 @@ proc apply_config {} {
699725
700726
set default_config(branch.autosetupmerge) true
701727
set default_config(merge.tool) {}
702-
set default_config(merge.keepbackup) true
728+
set default_config(mergetool.keepbackup) true
703729
set default_config(merge.diffstat) true
704730
set default_config(merge.summary) false
705731
set default_config(merge.verbosity) 2
@@ -769,9 +795,9 @@ if {![regsub {^git version } $_git_version {} _git_version]} {
769795
set _real_git_version $_git_version
770796
regsub -- {[\-\.]dirty$} $_git_version {} _git_version
771797
regsub {\.[0-9]+\.g[0-9a-f]+$} $_git_version {} _git_version
772-
regsub {\.rc[0-9]+$} $_git_version {} _git_version
798+
regsub {\.[a-zA-Z]+\.?[0-9]+$} $_git_version {} _git_version
773799
regsub {\.GIT$} $_git_version {} _git_version
774-
regsub {\.[a-zA-Z]+\.[0-9]+$} $_git_version {} _git_version
800+
regsub {\.[a-zA-Z]+\.?[0-9]+$} $_git_version {} _git_version
775801
776802
if {![regexp {^[1-9]+(\.[0-9]+)+$} $_git_version]} {
777803
catch {wm withdraw .}
@@ -1108,6 +1134,7 @@ set current_diff_path {}
11081134
set is_3way_diff 0
11091135
set is_conflict_diff 0
11101136
set selected_commit_type new
1137+
set diff_empty_count 0
11111138
11121139
set nullid "0000000000000000000000000000000000000000"
11131140
set nullid2 "0000000000000000000000000000000000000001"
@@ -1924,7 +1951,7 @@ proc do_explore {} {
19241951
# freedesktop.org-conforming system is our best shot
19251952
set explorer "xdg-open"
19261953
}
1927-
eval exec $explorer [file dirname [gitdir]] &
1954+
eval exec $explorer [list [file nativename [file dirname [gitdir]]]] &
19281955
}
19291956
19301957
set is_quitting 0
@@ -2277,6 +2304,12 @@ set ui_comm {}
22772304
# -- Menu Bar
22782305
#
22792306
menu .mbar -tearoff 0
2307+
if {[is_MacOSX]} {
2308+
# -- Apple Menu (Mac OS X only)
2309+
#
2310+
.mbar add cascade -label Apple -menu .mbar.apple
2311+
menu .mbar.apple
2312+
}
22802313
.mbar add cascade -label [mc Repository] -menu .mbar.repository
22812314
.mbar add cascade -label [mc Edit] -menu .mbar.edit
22822315
if {[is_enabled branch]} {
@@ -2292,7 +2325,6 @@ if {[is_enabled transport]} {
22922325
if {[is_enabled multicommit] || [is_enabled singlecommit]} {
22932326
.mbar add cascade -label [mc Tools] -menu .mbar.tools
22942327
}
2295-
. configure -menu .mbar
22962328
22972329
# -- Repository Menu
22982330
#
@@ -2545,19 +2577,7 @@ if {[is_enabled transport]} {
25452577
}
25462578
25472579
if {[is_MacOSX]} {
2548-
# -- Apple Menu (Mac OS X only)
2549-
#
2550-
.mbar add cascade -label Apple -menu .mbar.apple
2551-
menu .mbar.apple
2552-
2553-
.mbar.apple add command -label [mc "About %s" [appname]] \
2554-
-command do_about
2555-
.mbar.apple add separator
2556-
.mbar.apple add command \
2557-
-label [mc "Preferences..."] \
2558-
-command do_options \
2559-
-accelerator $M1T-,
2560-
bind . <$M1B-,> do_options
2580+
proc ::tk::mac::ShowPreferences {} {do_options}
25612581
} else {
25622582
# -- Edit Menu
25632583
#
@@ -2585,17 +2605,23 @@ if {[is_enabled multicommit] || [is_enabled singlecommit]} {
25852605
.mbar add cascade -label [mc Help] -menu .mbar.help
25862606
menu .mbar.help
25872607
2588-
if {![is_MacOSX]} {
2608+
if {[is_MacOSX]} {
2609+
.mbar.apple add command -label [mc "About %s" [appname]] \
2610+
-command do_about
2611+
.mbar.apple add separator
2612+
} else {
25892613
.mbar.help add command -label [mc "About %s" [appname]] \
25902614
-command do_about
25912615
}
2616+
. configure -menu .mbar
25922617
2618+
set doc_path [githtmldir]
2619+
if {$doc_path ne {}} {
2620+
set doc_path [file join $doc_path index.html]
25932621
2594-
set doc_path [file dirname [gitexec]]
2595-
set doc_path [file join $doc_path Documentation index.html]
2596-
2597-
if {[is_Cygwin]} {
2598-
set doc_path [exec cygpath --mixed $doc_path]
2622+
if {[is_Cygwin]} {
2623+
set doc_path [exec cygpath --mixed $doc_path]
2624+
}
25992625
}
26002626
26012627
if {[file isfile $doc_path]} {
@@ -2944,7 +2970,7 @@ $ctxm add command \
29442970
-command {tk_textPaste $ui_comm}
29452971
$ctxm add command \
29462972
-label [mc Delete] \
2947-
-command {$ui_comm delete sel.first sel.last}
2973+
-command {catch {$ui_comm delete sel.first sel.last}}
29482974
$ctxm add separator
29492975
$ctxm add command \
29502976
-label [mc "Select All"] \

git-gui/lib/branch_delete.tcl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ constructor dialog {} {
5151
$w.check \
5252
[mc "Delete Only If Merged Into"] \
5353
]
54-
$w_check none [mc "Always (Do not perform merge test.)"]
54+
$w_check none [mc "Always (Do not perform merge checks)"]
5555
pack $w.check -anchor nw -fill x -pady 5 -padx 5
5656

5757
foreach h [load_all_heads] {
@@ -112,7 +112,7 @@ method _delete {} {
112112
}
113113
if {$to_delete eq {}} return
114114
if {$check_cmt eq {}} {
115-
set msg [mc "Recovering deleted branches is difficult. \n\n Delete the selected branches?"]
115+
set msg [mc "Recovering deleted branches is difficult.\n\nDelete the selected branches?"]
116116
if {[tk_messageBox \
117117
-icon warning \
118118
-type yesno \

git-gui/lib/checkout_op.tcl

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ field w_cons {}; # embedded console window object
99
field new_expr ; # expression the user saw/thinks this is
1010
field new_hash ; # commit SHA-1 we are switching to
1111
field new_ref ; # ref we are updating/creating
12+
field old_hash ; # commit SHA-1 that was checked out when we started
1213

1314
field parent_w .; # window that started us
1415
field merge_type none; # type of merge to apply to existing branch
@@ -280,11 +281,11 @@ method _start_checkout {} {
280281

281282
# -- Our in memory state should match the repository.
282283
#
283-
repository_state curType curHEAD curMERGE_HEAD
284+
repository_state curType old_hash curMERGE_HEAD
284285
if {[string match amend* $commit_type]
285286
&& $curType eq {normal}
286-
&& $curHEAD eq $HEAD} {
287-
} elseif {$commit_type ne $curType || $HEAD ne $curHEAD} {
287+
&& $old_hash eq $HEAD} {
288+
} elseif {$commit_type ne $curType || $HEAD ne $old_hash} {
288289
info_popup [mc "Last scanned state does not match repository state.
289290
290291
Another Git program has modified this repository since the last scan. A rescan must be performed before the current branch can be changed.
@@ -297,7 +298,7 @@ The rescan will be automatically started now.
297298
return
298299
}
299300

300-
if {$curHEAD eq $new_hash} {
301+
if {$old_hash eq $new_hash} {
301302
_after_readtree $this
302303
} elseif {[is_config_true gui.trustmtime]} {
303304
_readtree $this
@@ -453,13 +454,47 @@ method _after_readtree {} {
453454
If you wanted to be on a branch, create one now starting from 'This Detached Checkout'."]
454455
}
455456

457+
# -- Run the post-checkout hook.
458+
#
459+
set fd_ph [githook_read post-checkout $old_hash $new_hash 1]
460+
if {$fd_ph ne {}} {
461+
global pch_error
462+
set pch_error {}
463+
fconfigure $fd_ph -blocking 0 -translation binary -eofchar {}
464+
fileevent $fd_ph readable [cb _postcheckout_wait $fd_ph]
465+
} else {
466+
_update_repo_state $this
467+
}
468+
}
469+
470+
method _postcheckout_wait {fd_ph} {
471+
global pch_error
472+
473+
append pch_error [read $fd_ph]
474+
fconfigure $fd_ph -blocking 1
475+
if {[eof $fd_ph]} {
476+
if {[catch {close $fd_ph}]} {
477+
hook_failed_popup post-checkout $pch_error 0
478+
}
479+
unset pch_error
480+
_update_repo_state $this
481+
return
482+
}
483+
fconfigure $fd_ph -blocking 0
484+
}
485+
486+
method _update_repo_state {} {
456487
# -- Update our repository state. If we were previously in
457488
# amend mode we need to toss the current buffer and do a
458489
# full rescan to update our file lists. If we weren't in
459490
# amend mode our file lists are accurate and we can avoid
460491
# the rescan.
461492
#
493+
global selected_commit_type commit_type HEAD MERGE_HEAD PARENT
494+
global ui_comm
495+
462496
unlock_index
497+
set name [_name $this]
463498
set selected_commit_type new
464499
if {[string match amend* $commit_type]} {
465500
$ui_comm delete 0.0 end

git-gui/lib/choose_repository.tcl

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,8 @@ method _do_new {} {
398398
grid $w_body.where.l $w_body.where.t $w_body.where.b -sticky ew
399399
pack $w_body.where -fill x
400400

401+
grid columnconfigure $w_body.where 1 -weight 1
402+
401403
trace add variable @local_path write [cb _write_local_path]
402404
bind $w_body.h <Destroy> [list trace remove variable @local_path write [cb _write_local_path]]
403405
update
@@ -964,7 +966,34 @@ method _readtree_wait {fd} {
964966
return
965967
}
966968

967-
set done 1
969+
# -- Run the post-checkout hook.
970+
#
971+
set fd_ph [githook_read post-checkout [string repeat 0 40] \
972+
[git rev-parse HEAD] 1]
973+
if {$fd_ph ne {}} {
974+
global pch_error
975+
set pch_error {}
976+
fconfigure $fd_ph -blocking 0 -translation binary -eofchar {}
977+
fileevent $fd_ph readable [cb _postcheckout_wait $fd_ph]
978+
} else {
979+
set done 1
980+
}
981+
}
982+
983+
method _postcheckout_wait {fd_ph} {
984+
global pch_error
985+
986+
append pch_error [read $fd_ph]
987+
fconfigure $fd_ph -blocking 1
988+
if {[eof $fd_ph]} {
989+
if {[catch {close $fd_ph}]} {
990+
hook_failed_popup post-checkout $pch_error 0
991+
}
992+
unset pch_error
993+
set done 1
994+
return
995+
}
996+
fconfigure $fd_ph -blocking 0
968997
}
969998

970999
######################################################################
@@ -998,6 +1027,8 @@ method _do_open {} {
9981027
grid $w_body.where.l $w_body.where.t $w_body.where.b -sticky ew
9991028
pack $w_body.where -fill x
10001029

1030+
grid columnconfigure $w_body.where 1 -weight 1
1031+
10011032
trace add variable @local_path write [cb _write_local_path]
10021033
bind $w_body.h <Destroy> [list trace remove variable @local_path write [cb _write_local_path]]
10031034
update

0 commit comments

Comments
 (0)