Merge tag 'gitgui-0.17.0' of git://repo.or.cz/git-gui

git-gui 0.17.0

* tag 'gitgui-0.17.0' of git://repo.or.cz/git-gui:
  git-gui 0.17
  git-gui: Don't prepend the prefix if value looks like a full path
  git-gui: Detect full path when parsing arguments
  git-gui: remove .git/CHERRY_PICK_HEAD after committing
  git-gui: Fix a loose/lose mistake
  git-gui: Fix semi-working shortcuts for unstage and revert
  git-gui: de.po: translate "remote" as "extern"
  git-gui: de.po: translate "bare" as "bloß"
  git-gui: de.po: consistently add untranslated hook names within braces
  git-gui: preserve commit messages in utf-8
  git-gui: open console when using --trace on windows
  git-gui: fix a typo in po/ files
  git-gui: Use PWD if it exists on Mac OS X
  git-gui: fix git-gui crash due to uninitialized variable
diff --git a/git-gui/GIT-VERSION-GEN b/git-gui/GIT-VERSION-GEN
index 6570943..49b62ea 100755
--- a/git-gui/GIT-VERSION-GEN
+++ b/git-gui/GIT-VERSION-GEN
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 GVF=GIT-VERSION-FILE
-DEF_VER=0.16.GITGUI
+DEF_VER=0.17.GITGUI
 
 LF='
 '
diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh
index ba4e5c1..89f636f 100755
--- a/git-gui/git-gui.sh
+++ b/git-gui/git-gui.sh
@@ -154,6 +154,7 @@
 if {$_trace >= 0} {
 	set argv [lreplace $argv $_trace $_trace]
 	set _trace 1
+	if {[tk windowingsystem] eq "win32"} { console show }
 } else {
 	set _trace 0
 }
@@ -1463,7 +1464,7 @@
 		(![$ui_comm edit modified]
 		|| [string trim [$ui_comm get 0.0 end]] eq {})} {
 		if {[string match amend* $commit_type]} {
-		} elseif {[load_message GITGUI_MSG]} {
+		} elseif {[load_message GITGUI_MSG utf-8]} {
 		} elseif {[run_prepare_commit_msg_hook]} {
 		} elseif {[load_message MERGE_MSG]} {
 		} elseif {[load_message SQUASH_MSG]} {
@@ -1549,7 +1550,7 @@
 	fileevent $fd_lo readable [list read_ls_others $fd_lo $after]
 }
 
-proc load_message {file} {
+proc load_message {file {encoding {}}} {
 	global ui_comm
 
 	set f [gitdir $file]
@@ -1558,6 +1559,9 @@
 			return 0
 		}
 		fconfigure $fd -eofchar {}
+		if {$encoding ne {}} {
+			fconfigure $fd -encoding $encoding
+		}
 		set content [string trim [read $fd]]
 		close $fd
 		regsub -all -line {[ \r\t]+$} $content {} content
@@ -2266,6 +2270,7 @@
 				&& $msg ne {}} {
 				catch {
 					set fd [open $save w]
+					fconfigure $fd -encoding utf-8
 					puts -nonewline $fd $msg
 					close $fd
 				}
@@ -2998,10 +3003,19 @@
 	set jump_spec {}
 	set is_path 0
 	foreach a $argv {
-		if {$is_path || [file exists $_prefix$a]} {
+		if {[file exists $a]} {
+			if {$path ne {}} usage
+			set path [normalize_relpath $a]
+			break
+		} elseif {[file exists $_prefix$a]} {
 			if {$path ne {}} usage
 			set path [normalize_relpath $_prefix$a]
 			break
+		}
+
+		if {$is_path} {
+			if {$path ne {}} usage
+			break
 		} elseif {$a eq {--}} {
 			if {$path ne {}} {
 				if {$head ne {}} usage
@@ -3023,8 +3037,13 @@
 	unset is_path
 
 	if {$head ne {} && $path eq {}} {
-		set path [normalize_relpath $_prefix$head]
-		set head {}
+		if {[string index $head 0] eq {/}} {
+			set path [normalize_relpath $head]
+			set head {}
+		} else {
+			set path [normalize_relpath $_prefix$head]
+			set head {}
+		}
 	}
 
 	if {$head eq {}} {
@@ -3710,6 +3729,8 @@
 bind $ui_diff <$M1B-Key-V> {break}
 bind $ui_diff <$M1B-Key-a> {%W tag add sel 0.0 end;break}
 bind $ui_diff <$M1B-Key-A> {%W tag add sel 0.0 end;break}
+bind $ui_diff <$M1B-Key-j> {do_revert_selection;break}
+bind $ui_diff <$M1B-Key-J> {do_revert_selection;break}
 bind $ui_diff <Key-Up>     {catch {%W yview scroll -1 units};break}
 bind $ui_diff <Key-Down>   {catch {%W yview scroll  1 units};break}
 bind $ui_diff <Key-Left>   {catch {%W xview scroll -1 units};break}
@@ -3742,6 +3763,8 @@
 bind .   <$M1B-Key-S> do_signoff
 bind .   <$M1B-Key-t> do_add_selection
 bind .   <$M1B-Key-T> do_add_selection
+bind .   <$M1B-Key-u> do_unstage_selection
+bind .   <$M1B-Key-U> do_unstage_selection
 bind .   <$M1B-Key-j> do_revert_selection
 bind .   <$M1B-Key-J> do_revert_selection
 bind .   <$M1B-Key-i> do_add_all
@@ -3835,7 +3858,7 @@
 }
 
 if {[winfo exists $ui_comm]} {
-	set GITGUI_BCK_exists [load_message GITGUI_BCK]
+	set GITGUI_BCK_exists [load_message GITGUI_BCK utf-8]
 
 	# -- If both our backup and message files exist use the
 	#    newer of the two files to initialize the buffer.
@@ -3872,6 +3895,7 @@
 			} elseif {$m} {
 				catch {
 					set fd [open [gitdir GITGUI_BCK] w]
+					fconfigure $fd -encoding utf-8
 					puts -nonewline $fd $msg
 					close $fd
 					set GITGUI_BCK_exists 1
diff --git a/git-gui/lib/commit.tcl b/git-gui/lib/commit.tcl
index 0d81432..864b687 100644
--- a/git-gui/lib/commit.tcl
+++ b/git-gui/lib/commit.tcl
@@ -268,7 +268,7 @@
 	    && 	[is_config_true gui.warndetachedcommit]} {
 		set msg [mc "You are about to commit on a detached head.\
 This is a potentially dangerous thing to do because if you switch\
-to another branch you will loose your changes and it can be difficult\
+to another branch you will lose your changes and it can be difficult\
 to retrieve them later from the reflog. You should probably cancel this\
 commit and create a new branch to continue.\n\
 \n\
@@ -409,6 +409,7 @@
 	catch {file delete [gitdir MERGE_MSG]}
 	catch {file delete [gitdir SQUASH_MSG]}
 	catch {file delete [gitdir GITGUI_MSG]}
+	catch {file delete [gitdir CHERRY_PICK_HEAD]}
 
 	# -- Let rerere do its thing.
 	#
diff --git a/git-gui/lib/status_bar.tcl b/git-gui/lib/status_bar.tcl
index 95cb449..02111a1 100644
--- a/git-gui/lib/status_bar.tcl
+++ b/git-gui/lib/status_bar.tcl
@@ -77,6 +77,7 @@
 
 method update {have total} {
 	set pdone 0
+	set cdone 0
 	if {$total > 0} {
 		set pdone [expr {100 * $have / $total}]
 		set cdone [expr {[winfo width $w_c] * $have / $total}]
diff --git a/git-gui/macosx/AppMain.tcl b/git-gui/macosx/AppMain.tcl
index ddbe633..738bdd0 100644
--- a/git-gui/macosx/AppMain.tcl
+++ b/git-gui/macosx/AppMain.tcl
@@ -12,7 +12,9 @@
 } else {
 	set argv0 [file join $gitexecdir [file tail [lindex $argv 0]]]
 	set AppMain_source [file join $gitguilib git-gui.tcl]
-	if {[pwd] eq {/}} {
+	if {[info exists env(PWD)]} {
+		cd $env(PWD)
+	} elseif {[pwd] eq {/}} {
 		cd $env(HOME)
 	}
 }
diff --git a/git-gui/po/de.po b/git-gui/po/de.po
index 44c5ddc..baebff2 100644
--- a/git-gui/po/de.po
+++ b/git-gui/po/de.po
@@ -72,7 +72,7 @@
 
 #: git-gui.sh:1154
 msgid "Cannot use bare repository:"
-msgstr "Leeres Projektarchiv kann nicht benutzt werden:"
+msgstr "Bloßes Projektarchiv kann nicht benutzt werden:"
 
 #: git-gui.sh:1162
 msgid "No working directory"
@@ -88,7 +88,7 @@
 
 #: git-gui.sh:1454
 msgid "Calling prepare-commit-msg hook..."
-msgstr "Aufrufen der Eintragen-Vorbereiten-Kontrolle..."
+msgstr "Aufrufen der Eintragen-Vorbereiten-Kontrolle (»prepare-commit hook«)..."
 
 #: git-gui.sh:1471
 msgid "Commit declined by prepare-commit-msg hook."
@@ -188,7 +188,7 @@
 
 #: git-gui.sh:2465 lib/choose_rev.tcl:557
 msgid "Remote"
-msgstr "Andere Archive"
+msgstr "Externe Archive"
 
 #: git-gui.sh:2468
 msgid "Tools"
@@ -478,7 +478,7 @@
 
 #: git-gui.sh:3328
 msgid "Use Remote Version"
-msgstr "Entfernte Version benutzen"
+msgstr "Externe Version benutzen"
 
 #: git-gui.sh:3332
 msgid "Use Local Version"
@@ -771,7 +771,7 @@
 #: lib/branch_create.tcl:140
 #, tcl-format
 msgid "Tracking branch %s is not a branch in the remote repository."
-msgstr "Übernahmezweig »%s« ist kein Zweig im anderen Projektarchiv."
+msgstr "Übernahmezweig »%s« ist kein Zweig im externen Projektarchiv."
 
 #: lib/branch_create.tcl:153 lib/branch_rename.tcl:86
 msgid "Please supply a branch name."
@@ -1446,7 +1446,7 @@
 
 #: lib/commit.tcl:234
 msgid "Calling pre-commit hook..."
-msgstr "Aufrufen der Vor-Eintragen-Kontrolle..."
+msgstr "Aufrufen der Vor-Eintragen-Kontrolle (»pre-commit hook«)..."
 
 #: lib/commit.tcl:249
 msgid "Commit declined by pre-commit hook."
@@ -1454,7 +1454,7 @@
 
 #: lib/commit.tcl:272
 msgid "Calling commit-msg hook..."
-msgstr "Aufrufen der Versionsbeschreibungs-Kontrolle..."
+msgstr "Aufrufen der Versionsbeschreibungs-Kontrolle (»commit-message hook«)..."
 
 #: lib/commit.tcl:287
 msgid "Commit declined by commit-msg hook."
@@ -2134,11 +2134,11 @@
 
 #: lib/remote_add.tcl:19
 msgid "Add Remote"
-msgstr "Anderes Archiv hinzufügen"
+msgstr "Externes Archiv hinzufügen"
 
 #: lib/remote_add.tcl:24
 msgid "Add New Remote"
-msgstr "Neues anderes Archiv hinzufügen"
+msgstr "Neues externes Archiv hinzufügen"
 
 #: lib/remote_add.tcl:28 lib/tools_dlg.tcl:36
 msgid "Add"
@@ -2146,7 +2146,7 @@
 
 #: lib/remote_add.tcl:37
 msgid "Remote Details"
-msgstr "Einzelheiten des anderen Archivs"
+msgstr "Einzelheiten des externen Archivs"
 
 #: lib/remote_add.tcl:50
 msgid "Location:"
@@ -2162,7 +2162,7 @@
 
 #: lib/remote_add.tcl:71
 msgid "Initialize Remote Repository and Push"
-msgstr "Anderes Archiv initialisieren und dahin versenden"
+msgstr "Externes Archiv initialisieren und dahin versenden"
 
 #: lib/remote_add.tcl:77
 msgid "Do Nothing Else Now"
@@ -2170,17 +2170,17 @@
 
 #: lib/remote_add.tcl:101
 msgid "Please supply a remote name."
-msgstr "Bitte geben Sie einen Namen des anderen Archivs an."
+msgstr "Bitte geben Sie einen Namen des externen Archivs an."
 
 #: lib/remote_add.tcl:114
 #, tcl-format
 msgid "'%s' is not an acceptable remote name."
-msgstr "»%s« ist kein zulässiger Name eines anderen Archivs."
+msgstr "»%s« ist kein zulässiger Name eines externen Archivs."
 
 #: lib/remote_add.tcl:125
 #, tcl-format
 msgid "Failed to add remote '%s' of location '%s'."
-msgstr "Fehler beim Hinzufügen des anderen Archivs »%s« aus Herkunftsort »%s«."
+msgstr "Fehler beim Hinzufügen des externen Archivs »%s« aus Herkunftsort »%s«."
 
 #: lib/remote_add.tcl:133 lib/transport.tcl:6
 #, tcl-format
@@ -2195,7 +2195,7 @@
 #: lib/remote_add.tcl:157
 #, tcl-format
 msgid "Do not know how to initialize repository at location '%s'."
-msgstr "Initialisieren eines anderen Archivs an Adresse »%s« ist nicht möglich."
+msgstr "Initialisieren eines externen Archivs an Adresse »%s« ist nicht möglich."
 
 #: lib/remote_add.tcl:163 lib/transport.tcl:25 lib/transport.tcl:63
 #: lib/transport.tcl:81
@@ -2210,7 +2210,7 @@
 
 #: lib/remote_branch_delete.tcl:29 lib/remote_branch_delete.tcl:34
 msgid "Delete Branch Remotely"
-msgstr "Zweig in anderem Archiv löschen"
+msgstr "Zweig in externem Archiv löschen"
 
 #: lib/remote_branch_delete.tcl:47
 msgid "From Repository"
@@ -2218,7 +2218,7 @@
 
 #: lib/remote_branch_delete.tcl:50 lib/transport.tcl:134
 msgid "Remote:"
-msgstr "Anderes Archiv:"
+msgstr "Externes Archiv:"
 
 #: lib/remote_branch_delete.tcl:66 lib/transport.tcl:149
 msgid "Arbitrary Location:"
@@ -2281,7 +2281,7 @@
 
 #: lib/remote.tcl:163
 msgid "Remove Remote"
-msgstr "Anderes Archiv entfernen"
+msgstr "Externes Archiv entfernen"
 
 #: lib/remote.tcl:168
 msgid "Prune from"
@@ -2397,7 +2397,7 @@
 msgstr "Schlüsselerzeugung fehlgeschlagen."
 
 #: lib/sshkey.tcl:118
-msgid "Generation succeded, but no keys found."
+msgid "Generation succeeded, but no keys found."
 msgstr "Schlüsselerzeugung erfolgreich, aber keine Schlüssel gefunden."
 
 #: lib/sshkey.tcl:121
diff --git a/git-gui/po/fr.po b/git-gui/po/fr.po
index 8170696..40441db 100644
--- a/git-gui/po/fr.po
+++ b/git-gui/po/fr.po
@@ -2399,7 +2399,7 @@
 msgstr "La génération a échoué."
 
 #: lib/sshkey.tcl:118
-msgid "Generation succeded, but no keys found."
+msgid "Generation succeeded, but no keys found."
 msgstr "La génération a réussi, mais aucune clé n'a été trouvée."
 
 #: lib/sshkey.tcl:121
diff --git a/git-gui/po/git-gui.pot b/git-gui/po/git-gui.pot
index 1ae2aaa..0c94f9c 100644
--- a/git-gui/po/git-gui.pot
+++ b/git-gui/po/git-gui.pot
@@ -2203,7 +2203,7 @@
 msgstr ""
 
 #: lib/sshkey.tcl:118
-msgid "Generation succeded, but no keys found."
+msgid "Generation succeeded, but no keys found."
 msgstr ""
 
 #: lib/sshkey.tcl:121
diff --git a/git-gui/po/hu.po b/git-gui/po/hu.po
index 0f87bc1..d106dad 100644
--- a/git-gui/po/hu.po
+++ b/git-gui/po/hu.po
@@ -2354,7 +2354,7 @@
 msgstr "A generálás nem sikerült."
 
 #: lib/sshkey.tcl:118
-msgid "Generation succeded, but no keys found."
+msgid "Generation succeeded, but no keys found."
 msgstr "A generálás sikeres, de egy kulcs se található."
 
 #: lib/sshkey.tcl:121
diff --git a/git-gui/po/it.po b/git-gui/po/it.po
index aa15a20..1bd8b8e 100644
--- a/git-gui/po/it.po
+++ b/git-gui/po/it.po
@@ -2397,7 +2397,7 @@
 msgstr "Errore durante la creazione della chiave."
 
 #: lib/sshkey.tcl:118
-msgid "Generation succeded, but no keys found."
+msgid "Generation succeeded, but no keys found."
 msgstr "La chiave è stata creata con successo, ma non è stata trovata."
 
 #: lib/sshkey.tcl:121
diff --git a/git-gui/po/ja.po b/git-gui/po/ja.po
index 1501798..9aff249 100644
--- a/git-gui/po/ja.po
+++ b/git-gui/po/ja.po
@@ -2362,7 +2362,7 @@
 msgstr "生成に失敗しました。"
 
 #: lib/sshkey.tcl:118
-msgid "Generation succeded, but no keys found."
+msgid "Generation succeeded, but no keys found."
 msgstr "生成には成功しましたが、鍵が見つかりません。"
 
 #: lib/sshkey.tcl:121
diff --git a/git-gui/po/nb.po b/git-gui/po/nb.po
index 6de93c2..d66aa50 100644
--- a/git-gui/po/nb.po
+++ b/git-gui/po/nb.po
@@ -2286,7 +2286,7 @@
 msgstr "Generering feilet."
 
 #: lib/sshkey.tcl:118
-msgid "Generation succeded, but no keys found."
+msgid "Generation succeeded, but no keys found."
 msgstr "Generering vellykket, men ingen nøkler er funnet."
 
 #: lib/sshkey.tcl:121
diff --git a/git-gui/po/pt_br.po b/git-gui/po/pt_br.po
index b175b97..bad116c 100644
--- a/git-gui/po/pt_br.po
+++ b/git-gui/po/pt_br.po
@@ -2375,7 +2375,7 @@
 msgstr "A geração da chave falhou."
 
 #: lib/sshkey.tcl:118
-msgid "Generation succeded, but no keys found."
+msgid "Generation succeeded, but no keys found."
 msgstr "A geração da chave foi bem-sucedida, mas nenhuma chave foi encontrada."
 
 #: lib/sshkey.tcl:121
diff --git a/git-gui/po/ru.po b/git-gui/po/ru.po
index 30f4b77..ca4343b 100644
--- a/git-gui/po/ru.po
+++ b/git-gui/po/ru.po
@@ -2370,7 +2370,7 @@
 msgstr "Ключ не создан."
 
 #: lib/sshkey.tcl:118
-msgid "Generation succeded, but no keys found."
+msgid "Generation succeeded, but no keys found."
 msgstr "Создание ключа завершилось, но результат не был найден"
 
 #: lib/sshkey.tcl:121
diff --git a/git-gui/po/sv.po b/git-gui/po/sv.po
index 24cc4e3..fcb063f 100644
--- a/git-gui/po/sv.po
+++ b/git-gui/po/sv.po
@@ -2382,7 +2382,7 @@
 msgstr "Misslyckades med att skapa."
 
 #: lib/sshkey.tcl:120
-msgid "Generation succeded, but no keys found."
+msgid "Generation succeeded, but no keys found."
 msgstr "Lyckades skapa nyckeln, men hittar inte någon nyckel."
 
 #: lib/sshkey.tcl:123