Skip to content

Commit

Permalink
Merge git://repo.or.cz/git-gui
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
gitster committed May 2, 2009
2 parents 1087aba + a91be3f commit a8816e7
Show file tree
Hide file tree
Showing 22 changed files with 1,254 additions and 657 deletions.
7 changes: 5 additions & 2 deletions git-gui/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,11 @@ endif

ifeq ($(uname_S),Darwin)
TKFRAMEWORK = /Library/Frameworks/Tk.framework/Resources/Wish.app
ifeq ($(shell expr "$(uname_R)" : '9\.'),2)
TKFRAMEWORK = /System/Library/Frameworks/Tk.framework/Resources/Wish\ Shell.app
ifeq ($(shell echo "$(uname_R)" | awk -F. '{if ($$1 >= 9) print "y"}')_$(shell test -d $(TKFRAMEWORK) || echo n),y_n)
TKFRAMEWORK = /System/Library/Frameworks/Tk.framework/Resources/Wish.app
ifeq ($(shell test -d $(TKFRAMEWORK) || echo n),n)
TKFRAMEWORK = /System/Library/Frameworks/Tk.framework/Resources/Wish\ Shell.app
endif
endif
TKEXECUTABLE = $(shell basename "$(TKFRAMEWORK)" .app)
endif
Expand Down
78 changes: 52 additions & 26 deletions git-gui/git-gui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ unset oguimsg
set _appname {Git Gui}
set _gitdir {}
set _gitexec {}
set _githtmldir {}
set _reponame {}
set _iscygwin {}
set _search_path {}
Expand Down Expand Up @@ -168,6 +169,28 @@ proc gitexec {args} {
return [eval [list file join $_gitexec] $args]
}

proc githtmldir {args} {
global _githtmldir
if {$_githtmldir eq {}} {
if {[catch {set _githtmldir [git --html-path]}]} {
# Git not installed or option not yet supported
return {}
}
if {[is_Cygwin]} {
set _githtmldir [exec cygpath \
--windows \
--absolute \
$_githtmldir]
} else {
set _githtmldir [file normalize $_githtmldir]
}
}
if {$args eq {}} {
return $_githtmldir
}
return [eval [list file join $_githtmldir] $args]
}

proc reponame {} {
return $::_reponame
}
Expand Down Expand Up @@ -640,10 +663,13 @@ font create font_diffbold
font create font_diffitalic
foreach class {Button Checkbutton Entry Label
Labelframe Listbox Menu Message
Labelframe Listbox Message
Radiobutton Spinbox Text} {
option add *$class.font font_ui
}
if {![is_MacOSX]} {
option add *Menu.font font_ui
}
unset class
if {[is_Windows] || [is_MacOSX]} {
Expand Down Expand Up @@ -699,7 +725,7 @@ proc apply_config {} {
set default_config(branch.autosetupmerge) true
set default_config(merge.tool) {}
set default_config(merge.keepbackup) true
set default_config(mergetool.keepbackup) true
set default_config(merge.diffstat) true
set default_config(merge.summary) false
set default_config(merge.verbosity) 2
Expand Down Expand Up @@ -769,9 +795,9 @@ if {![regsub {^git version } $_git_version {} _git_version]} {
set _real_git_version $_git_version
regsub -- {[\-\.]dirty$} $_git_version {} _git_version
regsub {\.[0-9]+\.g[0-9a-f]+$} $_git_version {} _git_version
regsub {\.rc[0-9]+$} $_git_version {} _git_version
regsub {\.[a-zA-Z]+\.?[0-9]+$} $_git_version {} _git_version
regsub {\.GIT$} $_git_version {} _git_version
regsub {\.[a-zA-Z]+\.[0-9]+$} $_git_version {} _git_version
regsub {\.[a-zA-Z]+\.?[0-9]+$} $_git_version {} _git_version
if {![regexp {^[1-9]+(\.[0-9]+)+$} $_git_version]} {
catch {wm withdraw .}
Expand Down Expand Up @@ -1108,6 +1134,7 @@ set current_diff_path {}
set is_3way_diff 0
set is_conflict_diff 0
set selected_commit_type new
set diff_empty_count 0
set nullid "0000000000000000000000000000000000000000"
set nullid2 "0000000000000000000000000000000000000001"
Expand Down Expand Up @@ -1924,7 +1951,7 @@ proc do_explore {} {
# freedesktop.org-conforming system is our best shot
set explorer "xdg-open"
}
eval exec $explorer [file dirname [gitdir]] &
eval exec $explorer [list [file nativename [file dirname [gitdir]]]] &
}
set is_quitting 0
Expand Down Expand Up @@ -2277,6 +2304,12 @@ set ui_comm {}
# -- Menu Bar
#
menu .mbar -tearoff 0
if {[is_MacOSX]} {
# -- Apple Menu (Mac OS X only)
#
.mbar add cascade -label Apple -menu .mbar.apple
menu .mbar.apple
}
.mbar add cascade -label [mc Repository] -menu .mbar.repository
.mbar add cascade -label [mc Edit] -menu .mbar.edit
if {[is_enabled branch]} {
Expand All @@ -2292,7 +2325,6 @@ if {[is_enabled transport]} {
if {[is_enabled multicommit] || [is_enabled singlecommit]} {
.mbar add cascade -label [mc Tools] -menu .mbar.tools
}
. configure -menu .mbar
# -- Repository Menu
#
Expand Down Expand Up @@ -2545,19 +2577,7 @@ if {[is_enabled transport]} {
}
if {[is_MacOSX]} {
# -- Apple Menu (Mac OS X only)
#
.mbar add cascade -label Apple -menu .mbar.apple
menu .mbar.apple
.mbar.apple add command -label [mc "About %s" [appname]] \
-command do_about
.mbar.apple add separator
.mbar.apple add command \
-label [mc "Preferences..."] \
-command do_options \
-accelerator $M1T-,
bind . <$M1B-,> do_options
proc ::tk::mac::ShowPreferences {} {do_options}
} else {
# -- Edit Menu
#
Expand Down Expand Up @@ -2585,17 +2605,23 @@ if {[is_enabled multicommit] || [is_enabled singlecommit]} {
.mbar add cascade -label [mc Help] -menu .mbar.help
menu .mbar.help
if {![is_MacOSX]} {
if {[is_MacOSX]} {
.mbar.apple add command -label [mc "About %s" [appname]] \
-command do_about
.mbar.apple add separator
} else {
.mbar.help add command -label [mc "About %s" [appname]] \
-command do_about
}
. configure -menu .mbar
set doc_path [githtmldir]
if {$doc_path ne {}} {
set doc_path [file join $doc_path index.html]
set doc_path [file dirname [gitexec]]
set doc_path [file join $doc_path Documentation index.html]
if {[is_Cygwin]} {
set doc_path [exec cygpath --mixed $doc_path]
if {[is_Cygwin]} {
set doc_path [exec cygpath --mixed $doc_path]
}
}
if {[file isfile $doc_path]} {
Expand Down Expand Up @@ -2944,7 +2970,7 @@ $ctxm add command \
-command {tk_textPaste $ui_comm}
$ctxm add command \
-label [mc Delete] \
-command {$ui_comm delete sel.first sel.last}
-command {catch {$ui_comm delete sel.first sel.last}}
$ctxm add separator
$ctxm add command \
-label [mc "Select All"] \
Expand Down
4 changes: 2 additions & 2 deletions git-gui/lib/branch_delete.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ constructor dialog {} {
$w.check \
[mc "Delete Only If Merged Into"] \
]
$w_check none [mc "Always (Do not perform merge test.)"]
$w_check none [mc "Always (Do not perform merge checks)"]
pack $w.check -anchor nw -fill x -pady 5 -padx 5

foreach h [load_all_heads] {
Expand Down Expand Up @@ -112,7 +112,7 @@ method _delete {} {
}
if {$to_delete eq {}} return
if {$check_cmt eq {}} {
set msg [mc "Recovering deleted branches is difficult. \n\n Delete the selected branches?"]
set msg [mc "Recovering deleted branches is difficult.\n\nDelete the selected branches?"]
if {[tk_messageBox \
-icon warning \
-type yesno \
Expand Down
43 changes: 39 additions & 4 deletions git-gui/lib/checkout_op.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ field w_cons {}; # embedded console window object
field new_expr ; # expression the user saw/thinks this is
field new_hash ; # commit SHA-1 we are switching to
field new_ref ; # ref we are updating/creating
field old_hash ; # commit SHA-1 that was checked out when we started

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

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

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

# -- Run the post-checkout hook.
#
set fd_ph [githook_read post-checkout $old_hash $new_hash 1]
if {$fd_ph ne {}} {
global pch_error
set pch_error {}
fconfigure $fd_ph -blocking 0 -translation binary -eofchar {}
fileevent $fd_ph readable [cb _postcheckout_wait $fd_ph]
} else {
_update_repo_state $this
}
}

method _postcheckout_wait {fd_ph} {
global pch_error

append pch_error [read $fd_ph]
fconfigure $fd_ph -blocking 1
if {[eof $fd_ph]} {
if {[catch {close $fd_ph}]} {
hook_failed_popup post-checkout $pch_error 0
}
unset pch_error
_update_repo_state $this
return
}
fconfigure $fd_ph -blocking 0
}

method _update_repo_state {} {
# -- Update our repository state. If we were previously in
# amend mode we need to toss the current buffer and do a
# full rescan to update our file lists. If we weren't in
# amend mode our file lists are accurate and we can avoid
# the rescan.
#
global selected_commit_type commit_type HEAD MERGE_HEAD PARENT
global ui_comm

unlock_index
set name [_name $this]
set selected_commit_type new
if {[string match amend* $commit_type]} {
$ui_comm delete 0.0 end
Expand Down
33 changes: 32 additions & 1 deletion git-gui/lib/choose_repository.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,8 @@ method _do_new {} {
grid $w_body.where.l $w_body.where.t $w_body.where.b -sticky ew
pack $w_body.where -fill x

grid columnconfigure $w_body.where 1 -weight 1

trace add variable @local_path write [cb _write_local_path]
bind $w_body.h <Destroy> [list trace remove variable @local_path write [cb _write_local_path]]
update
Expand Down Expand Up @@ -964,7 +966,34 @@ method _readtree_wait {fd} {
return
}

set done 1
# -- Run the post-checkout hook.
#
set fd_ph [githook_read post-checkout [string repeat 0 40] \
[git rev-parse HEAD] 1]
if {$fd_ph ne {}} {
global pch_error
set pch_error {}
fconfigure $fd_ph -blocking 0 -translation binary -eofchar {}
fileevent $fd_ph readable [cb _postcheckout_wait $fd_ph]
} else {
set done 1
}
}

method _postcheckout_wait {fd_ph} {
global pch_error

append pch_error [read $fd_ph]
fconfigure $fd_ph -blocking 1
if {[eof $fd_ph]} {
if {[catch {close $fd_ph}]} {
hook_failed_popup post-checkout $pch_error 0
}
unset pch_error
set done 1
return
}
fconfigure $fd_ph -blocking 0
}

######################################################################
Expand Down Expand Up @@ -998,6 +1027,8 @@ method _do_open {} {
grid $w_body.where.l $w_body.where.t $w_body.where.b -sticky ew
pack $w_body.where -fill x

grid columnconfigure $w_body.where 1 -weight 1

trace add variable @local_path write [cb _write_local_path]
bind $w_body.h <Destroy> [list trace remove variable @local_path write [cb _write_local_path]]
update
Expand Down
Loading

0 comments on commit a8816e7

Please sign in to comment.