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: Automatically spell check commit messages as the user types
  git-gui: support Git Gui.app under OS X 10.5
  git-gui: Update German translation.
  git-gui: (i18n) Fix a bunch of still untranslated strings.
  • Loading branch information
Junio C Hamano committed Feb 13, 2008
2 parents 6bc4c72 + 95b002e commit 41e2edf
Show file tree
Hide file tree
Showing 12 changed files with 618 additions and 84 deletions.
17 changes: 13 additions & 4 deletions git-gui/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE

uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')

SCRIPT_SH = git-gui.sh
GITGUI_MAIN := git-gui
Expand Down Expand Up @@ -93,7 +94,14 @@ endif

TCL_PATH ?= tclsh
TCLTK_PATH ?= wish
TKFRAMEWORK = /Library/Frameworks/Tk.framework/Resources/Wish.app

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
endif
TKEXECUTABLE = $(shell basename "$(TKFRAMEWORK)" .app)
endif

ifeq ($(findstring $(MAKEFLAGS),s),s)
QUIET_GEN =
Expand Down Expand Up @@ -147,7 +155,7 @@ git-gui: GIT-VERSION-FILE GIT-GUI-VARS
echo then >>$@+ && \
echo ' 'echo \'git-gui version '$(GITGUI_VERSION)'\' >>$@+ && \
echo else >>$@+ && \
echo ' 'exec \''$(libdir_SQ)/Git Gui.app/Contents/MacOS/Wish'\' \
echo ' 'exec \''$(libdir_SQ)/Git Gui.app/Contents/MacOS/$(subst \,,$(TKEXECUTABLE))'\' \
'"$$0" "$$@"' >>$@+ && \
echo fi >>$@+ && \
chmod +x $@+ && \
Expand All @@ -157,14 +165,15 @@ Git\ Gui.app: GIT-VERSION-FILE GIT-GUI-VARS \
macosx/Info.plist \
macosx/git-gui.icns \
macosx/AppMain.tcl \
$(TKFRAMEWORK)/Contents/MacOS/Wish
$(TKFRAMEWORK)/Contents/MacOS/$(TKEXECUTABLE)
$(QUIET_GEN)rm -rf '$@' '$@'+ && \
mkdir -p '$@'+/Contents/MacOS && \
mkdir -p '$@'+/Contents/Resources/Scripts && \
cp '$(subst ','\'',$(TKFRAMEWORK))/Contents/MacOS/Wish' \
cp '$(subst ','\'',$(subst \,,$(TKFRAMEWORK)/Contents/MacOS/$(TKEXECUTABLE)))' \
'$@'+/Contents/MacOS && \
cp macosx/git-gui.icns '$@'+/Contents/Resources && \
sed -e 's/@@GITGUI_VERSION@@/$(GITGUI_VERSION)/g' \
-e 's/@@GITGUI_TKEXECUTABLE@@/$(TKEXECUTABLE)/g' \
macosx/Info.plist \
>'$@'+/Contents/Info.plist && \
sed -e 's|@@gitexecdir@@|$(gitexecdir_SQ)|' \
Expand Down
34 changes: 33 additions & 1 deletion git-gui/git-gui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,7 @@ set default_config(gui.pruneduringfetch) false
set default_config(gui.trustmtime) false
set default_config(gui.diffcontext) 5
set default_config(gui.newbranchtemplate) {}
set default_config(gui.spellingdictionary) {}
set default_config(gui.fontui) [font configure font_ui]
set default_config(gui.fontdiff) [font configure font_diff]
set font_descs {
Expand Down Expand Up @@ -1683,6 +1684,7 @@ set is_quitting 0
proc do_quit {} {
global ui_comm is_quitting repo_config commit_type
global GITGUI_BCK_exists GITGUI_BCK_i
global ui_comm_spell
if {$is_quitting} return
set is_quitting 1
Expand Down Expand Up @@ -1710,6 +1712,12 @@ proc do_quit {} {
}
}
# -- Cancel our spellchecker if its running.
#
if {[info exists ui_comm_spell]} {
$ui_comm_spell stop
}
# -- Remove our editor backup, its not needed.
#
after cancel $GITGUI_BCK_i
Expand Down Expand Up @@ -2454,7 +2462,7 @@ $ctxm add separator
$ctxm add command \
-label [mc "Sign Off"] \
-command do_signoff
bind_button3 $ui_comm "tk_popup $ctxm %X %Y"
set ui_comm_ctxm $ctxm
# -- Diff Header
#
Expand Down Expand Up @@ -2857,6 +2865,30 @@ if {[winfo exists $ui_comm]} {
}
backup_commit_buffer
# -- If the user has aspell available we can drive it
# in pipe mode to spellcheck the commit message.
#
set spell_cmd [list |]
set spell_dict [get_config gui.spellingdictionary]
lappend spell_cmd aspell
if {$spell_dict ne {}} {
lappend spell_cmd --master=$spell_dict
}
lappend spell_cmd --mode=none
lappend spell_cmd --encoding=utf-8
lappend spell_cmd pipe
if {$spell_dict eq {none}
|| [catch {set spell_fd [open $spell_cmd r+]} spell_err]} {
bind_button3 $ui_comm [list tk_popup $ui_comm_ctxm %X %Y]
} else {
set ui_comm_spell [spellcheck::init \
$spell_fd \
$ui_comm \
$ui_comm_ctxm \
]
}
unset -nocomplain spell_cmd spell_fd spell_err spell_dict
}
lock_index begin-read
Expand Down
5 changes: 5 additions & 0 deletions git-gui/lib/about.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
proc do_about {} {
global appvers copyright oguilib
global tcl_patchLevel tk_patchLevel
global ui_comm_spell

set w .about_dialog
toplevel $w
Expand Down Expand Up @@ -40,6 +41,10 @@ proc do_about {} {
append v "Tcl version $tcl_patchLevel"
append v ", Tk version $tk_patchLevel"
}
if {[info exists ui_comm_spell]} {
append v "\n"
append v [$ui_comm_spell version]
}

set d {}
append d "git wrapper: $::_git\n"
Expand Down
6 changes: 3 additions & 3 deletions git-gui/lib/checkout_op.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ The rescan will be automatically started now.
} elseif {[is_config_true gui.trustmtime]} {
_readtree $this
} else {
ui_status {Refreshing file status...}
ui_status [mc "Refreshing file status..."]
set fd [git_read update-index \
-q \
--unmerged \
Expand Down Expand Up @@ -320,7 +320,7 @@ method _readtree {} {
set readtree_d {}
$::main_status start \
[mc "Updating working directory to '%s'..." [_name $this]] \
{files checked out}
[mc "files checked out"]

set fd [git_read --stderr read-tree \
-m \
Expand Down Expand Up @@ -447,7 +447,7 @@ If you wanted to be on a branch, create one now starting from 'This Detached Che
} else {
repository_state commit_type HEAD MERGE_HEAD
set PARENT $HEAD
ui_status "Checked out '$name'."
ui_status [mc "Checked out '%s'." $name]
}
delete_this
}
Expand Down
16 changes: 8 additions & 8 deletions git-gui/lib/commit.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ A good commit message has the following format:
return
}

ui_status {Calling pre-commit hook...}
ui_status [mc "Calling pre-commit hook..."]
set pch_error {}
fconfigure $fd_ph -blocking 0 -translation binary -eofchar {}
fileevent $fd_ph readable \
Expand All @@ -233,7 +233,7 @@ proc commit_prehook_wait {fd_ph curHEAD msg_p} {
if {[eof $fd_ph]} {
if {[catch {close $fd_ph}]} {
catch {file delete $msg_p}
ui_status {Commit declined by pre-commit hook.}
ui_status [mc "Commit declined by pre-commit hook."]
hook_failed_popup pre-commit $pch_error
unlock_index
} else {
Expand All @@ -256,7 +256,7 @@ proc commit_commitmsg {curHEAD msg_p} {
return
}

ui_status {Calling commit-msg hook...}
ui_status [mc "Calling commit-msg hook..."]
set pch_error {}
fconfigure $fd_ph -blocking 0 -translation binary -eofchar {}
fileevent $fd_ph readable \
Expand All @@ -271,7 +271,7 @@ proc commit_commitmsg_wait {fd_ph curHEAD msg_p} {
if {[eof $fd_ph]} {
if {[catch {close $fd_ph}]} {
catch {file delete $msg_p}
ui_status {Commit declined by commit-msg hook.}
ui_status [mc "Commit declined by commit-msg hook."]
hook_failed_popup commit-msg $pch_error
unlock_index
} else {
Expand All @@ -284,7 +284,7 @@ proc commit_commitmsg_wait {fd_ph curHEAD msg_p} {
}

proc commit_writetree {curHEAD msg_p} {
ui_status {Committing changes...}
ui_status [mc "Committing changes..."]
set fd_wt [git_read write-tree]
fileevent $fd_wt readable \
[list commit_committree $fd_wt $curHEAD $msg_p]
Expand All @@ -301,7 +301,7 @@ proc commit_committree {fd_wt curHEAD msg_p} {
if {[catch {close $fd_wt} err]} {
catch {file delete $msg_p}
error_popup [strcat [mc "write-tree failed:"] "\n\n$err"]
ui_status {Commit failed.}
ui_status [mc "Commit failed."]
unlock_index
return
}
Expand Down Expand Up @@ -345,7 +345,7 @@ A rescan will be automatically started now.
if {[catch {set cmt_id [eval git $cmd]} err]} {
catch {file delete $msg_p}
error_popup [strcat [mc "commit-tree failed:"] "\n\n$err"]
ui_status {Commit failed.}
ui_status [mc "Commit failed."]
unlock_index
return
}
Expand All @@ -365,7 +365,7 @@ A rescan will be automatically started now.
} err]} {
catch {file delete $msg_p}
error_popup [strcat [mc "update-ref failed:"] "\n\n$err"]
ui_status {Commit failed.}
ui_status [mc "Commit failed."]
unlock_index
return
}
Expand Down
2 changes: 1 addition & 1 deletion git-gui/lib/index.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ proc add_helper {txt paths} {
update_index \
$txt \
$pathList \
[concat $after {ui_status {Ready to commit.}}]
[concat $after {ui_status [mc "Ready to commit."]}]
}
}

Expand Down
5 changes: 2 additions & 3 deletions git-gui/lib/merge.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ method _start {} {
lappend cmd HEAD
lappend cmd $name

set msg [mc "Merging %s and %s" $current_branch $stitle]
ui_status "$msg..."
ui_status [mc "Merging %s and %s..." $current_branch $stitle]
set cons [console::new [mc "Merge"] "merge $stitle"]
console::exec $cons $cmd [cb _finish $cons]

Expand Down Expand Up @@ -236,7 +235,7 @@ Continue with resetting the current changes?"]
set fd [git_read --stderr read-tree --reset -u -v HEAD]
fconfigure $fd -blocking 0 -translation binary
fileevent $fd readable [namespace code [list _reset_wait $fd]]
$::main_status start [mc "Aborting"] {files reset}
$::main_status start [mc "Aborting"] [mc "files reset"]
} else {
unlock_index
}
Expand Down
41 changes: 41 additions & 0 deletions git-gui/lib/option.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ proc save_config {} {
global default_config font_descs
global repo_config global_config
global repo_config_new global_config_new
global ui_comm_spell

foreach option $font_descs {
set name [lindex $option 0]
Expand Down Expand Up @@ -52,11 +53,23 @@ proc save_config {} {
set repo_config($name) $value
}
}

if {[info exists repo_config(gui.spellingdictionary)]} {
set value $repo_config(gui.spellingdictionary)
if {$value eq {none}} {
if {[info exists ui_comm_spell]} {
$ui_comm_spell stop
}
} elseif {[info exists ui_comm_spell]} {
$ui_comm_spell lang $value
}
}
}

proc do_options {} {
global repo_config global_config font_descs
global repo_config_new global_config_new
global ui_comm_spell

array unset repo_config_new
array unset global_config_new
Expand Down Expand Up @@ -159,6 +172,34 @@ proc do_options {} {
}
}

set all_dicts [linsert \
[spellcheck::available_langs] \
0 \
none]
incr optid
foreach f {repo global} {
if {![info exists ${f}_config_new(gui.spellingdictionary)]} {
if {[info exists ui_comm_spell]} {
set value [$ui_comm_spell lang]
} else {
set value none
}
set ${f}_config_new(gui.spellingdictionary) $value
}

frame $w.$f.$optid
label $w.$f.$optid.l -text [mc "Spelling Dictionary:"]
eval tk_optionMenu $w.$f.$optid.v \
${f}_config_new(gui.spellingdictionary) \
$all_dicts
pack $w.$f.$optid.l -side left -anchor w -fill x
pack $w.$f.$optid.v -side left -anchor w \
-fill x -expand 1 \
-padx 5
pack $w.$f.$optid -side top -anchor w -fill x
}
unset all_dicts

set all_fonts [lsort [font families]]
foreach option $font_descs {
set name [lindex $option 0]
Expand Down
Loading

0 comments on commit 41e2edf

Please sign in to comment.