Skip to content

Commit 47d45a5

Browse files
committed
Merge git://repo.or.cz/git-gui
* git://repo.or.cz/git-gui: git-gui: incremental goto line in blame view git-gui: clear the goto line input when hiding git-gui: only accept numbers in the goto-line input git-gui: search and linenumber input are mutual exclusive in the blame view git-gui: deal with unknown files when pressing the "Stage Changed" button git-gui: drop the 'n' and 'Shift-n' bindings from the last patch. git-gui: Add keyboard shortcuts for search and goto commands in blame view. git-gui: Enable jumping to a specific line number in blame view. Fix tooltip display with multiple monitors on windows. Fix typo: existant->existent git-gui: updated translator README for current procedures. git-gui: warn when trying to commit on a detached head git-gui: Corrected a typo in the Swedish translation of 'Continue'
2 parents cdb51a1 + 843d659 commit 47d45a5

File tree

9 files changed

+159
-29
lines changed

9 files changed

+159
-29
lines changed

git-gui/git-gui.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,7 @@ set default_config(gui.fontdiff) [font configure font_diff]
854854
# TODO: this option should be added to the git-config documentation
855855
set default_config(gui.maxfilesdisplayed) 5000
856856
set default_config(gui.usettk) 1
857+
set default_config(gui.warndetachedcommit) 1
857858
set font_descs {
858859
{fontui font_ui {mc "Main Font"}}
859860
{fontdiff font_diff {mc "Diff/Console Font"}}
@@ -1526,7 +1527,7 @@ proc run_prepare_commit_msg_hook {} {
15261527
15271528
# prepare-commit-msg requires PREPARE_COMMIT_MSG exist. From git-gui
15281529
# it will be .git/MERGE_MSG (merge), .git/SQUASH_MSG (squash), or an
1529-
# empty file but existant file.
1530+
# empty file but existent file.
15301531
15311532
set fd_pcm [open [gitdir PREPARE_COMMIT_MSG] a]
15321533

git-gui/lib/blame.tcl

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ field w_asim ; # text column: annotations (simple computation)
2222
field w_file ; # text column: actual file data
2323
field w_cviewer ; # pane showing commit message
2424
field finder ; # find mini-dialog frame
25+
field gotoline ; # line goto mini-dialog frame
2526
field status ; # status mega-widget instance
2627
field old_height ; # last known height of $w.file_pane
2728

@@ -231,6 +232,11 @@ constructor new {i_commit i_path i_jump} {
231232
-column [expr {[llength $w_columns] - 1}] \
232233
]
233234

235+
set gotoline [::linebar::new \
236+
$w.file_pane.out.lf $w_file \
237+
-column [expr {[llength $w_columns] - 1}] \
238+
]
239+
234240
set w_cviewer $w.file_pane.cm.t
235241
text $w_cviewer \
236242
-background white \
@@ -274,7 +280,11 @@ constructor new {i_commit i_path i_jump} {
274280
$w.ctxm add command \
275281
-label [mc "Find Text..."] \
276282
-accelerator F7 \
277-
-command [list searchbar::show $finder]
283+
-command [cb _show_finder]
284+
$w.ctxm add command \
285+
-label [mc "Goto Line..."] \
286+
-accelerator "Ctrl-G" \
287+
-command [cb _show_linebar]
278288
menu $w.ctxm.enc
279289
build_encoding_menu $w.ctxm.enc [cb _setencoding]
280290
$w.ctxm add cascade \
@@ -341,10 +351,13 @@ constructor new {i_commit i_path i_jump} {
341351
bind $w_cviewer <Tab> "[list focus $w_file];break"
342352
bind $w_cviewer <Button-1> [list focus $w_cviewer]
343353
bind $w_file <Visibility> [cb _focus_search $w_file]
344-
bind $top <F7> [list searchbar::show $finder]
354+
bind $top <F7> [cb _show_finder]
355+
bind $top <Key-slash> [cb _show_finder]
356+
bind $top <Control-Key-s> [cb _show_finder]
345357
bind $top <Escape> [list searchbar::hide $finder]
346358
bind $top <F3> [list searchbar::find_next $finder]
347359
bind $top <Shift-F3> [list searchbar::find_prev $finder]
360+
bind $top <Control-Key-g> [cb _show_linebar]
348361
catch { bind $top <Shift-Key-XF86_Switch_VT_3> [list searchbar::find_prev $finder] }
349362

350363
grid configure $w.header -sticky ew
@@ -1298,9 +1311,9 @@ method _position_tooltip {} {
12981311
set pos_y [expr {[winfo pointery .] + 10}]
12991312

13001313
set g "${req_w}x${req_h}"
1301-
if {$pos_x >= 0} {append g +}
1314+
if {[tk windowingsystem] eq "win32" || $pos_x >= 0} {append g +}
13021315
append g $pos_x
1303-
if {$pos_y >= 0} {append g +}
1316+
if {[tk windowingsystem] eq "win32" || $pos_y >= 0} {append g +}
13041317
append g $pos_y
13051318

13061319
wm geometry $tooltip_wm $g
@@ -1336,4 +1349,14 @@ method _resize {new_height} {
13361349
set old_height $new_height
13371350
}
13381351

1352+
method _show_finder {} {
1353+
linebar::hide $gotoline
1354+
searchbar::show $finder
1355+
}
1356+
1357+
method _show_linebar {} {
1358+
searchbar::hide $finder
1359+
linebar::show $gotoline
1360+
}
1361+
13391362
}

git-gui/lib/choose_rev.tcl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,9 +610,9 @@ method _position_tooltip {} {
610610
set pos_y [expr {[winfo pointery .] + 10}]
611611

612612
set g "${req_w}x${req_h}"
613-
if {$pos_x >= 0} {append g +}
613+
if {[tk windowingsystem] eq "win32" || $pos_x >= 0} {append g +}
614614
append g $pos_x
615-
if {$pos_y >= 0} {append g +}
615+
if {[tk windowingsystem] eq "win32" || $pos_y >= 0} {append g +}
616616
append g $pos_y
617617

618618
wm geometry $tooltip_wm $g

git-gui/lib/commit.tcl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,23 @@ proc commit_prehook_wait {fd_ph curHEAD msg_p} {
260260
}
261261

262262
proc commit_commitmsg {curHEAD msg_p} {
263+
global is_detached repo_config
263264
global pch_error
264265

266+
if {$is_detached && $repo_config(gui.warndetachedcommit)} {
267+
set msg [mc "You are about to commit on a detached head.\
268+
This is a potentially dangerous thing to do because if you switch\
269+
to another branch you will loose your changes and it can be difficult\
270+
to retrieve them later from the reflog. You should probably cancel this\
271+
commit and create a new branch to continue.\n\
272+
\n\
273+
Do you really want to proceed with your Commit?"]
274+
if {[ask_popup $msg] ne yes} {
275+
unlock_index
276+
return
277+
}
278+
}
279+
265280
# -- Run the commit-msg hook.
266281
#
267282
set fd_ph [githook_read commit-msg $msg_p]

git-gui/lib/index.tcl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,12 +356,21 @@ proc do_add_all {} {
356356
global file_states
357357

358358
set paths [list]
359+
set unknown_paths [list]
359360
foreach path [array names file_states] {
360361
switch -glob -- [lindex $file_states($path) 0] {
361362
U? {continue}
362363
?M -
363364
?T -
364365
?D {lappend paths $path}
366+
?O {lappend unknown_paths $path}
367+
}
368+
}
369+
if {[llength $unknown_paths]} {
370+
set reply [ask_popup [mc "There are unknown files do you also want
371+
to stage those?"]]
372+
if {$reply} {
373+
set paths [concat $paths $unknown_paths]
365374
}
366375
}
367376
add_helper {Adding all changed files} $paths

git-gui/lib/line.tcl

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# goto line number
2+
# based on code from gitk, Copyright (C) Paul Mackerras
3+
4+
class linebar {
5+
6+
field w
7+
field ctext
8+
9+
field linenum {}
10+
11+
constructor new {i_w i_text args} {
12+
global use_ttk NS
13+
set w $i_w
14+
set ctext $i_text
15+
16+
${NS}::frame $w
17+
${NS}::label $w.l -text [mc "Goto Line:"]
18+
entry $w.ent \
19+
-textvariable ${__this}::linenum \
20+
-background lightgreen \
21+
-validate key \
22+
-validatecommand [cb _validate %P]
23+
${NS}::button $w.bn -text [mc Go] -command [cb _goto]
24+
25+
pack $w.l -side left
26+
pack $w.bn -side right
27+
pack $w.ent -side left -expand 1 -fill x
28+
29+
eval grid conf $w -sticky we $args
30+
grid remove $w
31+
32+
trace add variable linenum write [cb _goto_cb]
33+
bind $w.ent <Return> [cb _goto]
34+
bind $w.ent <Escape> [cb hide]
35+
36+
bind $w <Destroy> [list delete_this $this]
37+
return $this
38+
}
39+
40+
method show {} {
41+
if {![visible $this]} {
42+
grid $w
43+
}
44+
focus -force $w.ent
45+
}
46+
47+
method hide {} {
48+
if {[visible $this]} {
49+
$w.ent delete 0 end
50+
focus $ctext
51+
grid remove $w
52+
}
53+
}
54+
55+
method visible {} {
56+
return [winfo ismapped $w]
57+
}
58+
59+
method editor {} {
60+
return $w.ent
61+
}
62+
63+
method _validate {P} {
64+
# only accept numbers as input
65+
string is integer $P
66+
}
67+
68+
method _goto_cb {name ix op} {
69+
after idle [cb _goto 1]
70+
}
71+
72+
method _goto {{nohide {0}}} {
73+
if {$linenum ne {}} {
74+
$ctext see $linenum.0
75+
if {!$nohide} {
76+
hide $this
77+
}
78+
}
79+
}
80+
81+
}

git-gui/lib/search.tcl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ constructor new {i_w i_text args} {
3535
grid remove $w
3636

3737
trace add variable searchstring write [cb _incrsearch_cb]
38+
bind $w.ent <Return> [cb find_next]
39+
bind $w.ent <Shift-Return> [cb find_prev]
3840

3941
bind $w <Destroy> [list delete_this $this]
4042
return $this
@@ -196,4 +198,4 @@ method scrolled {} {
196198
}
197199
}
198200

199-
}
201+
}

git-gui/po/README

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,23 @@ specialized so-called "po file editors" (e.g. emacs po-mode, KBabel,
1818
poedit, GTranslator --- any of them would work well). Please install
1919
them.
2020

21-
You would then need to clone the git-gui internationalization project
22-
repository, so that you can work on it:
21+
You would then need to clone the git-gui project repository and create
22+
a feature branch to begin working:
2323

24-
$ git clone [email protected]:/srv/git/git-gui/git-gui-i18n.git/
25-
$ cd git-gui-i18n
26-
$ git checkout --track -b mob origin/mob
27-
$ git config remote.origin.push mob
24+
$ git clone git://repo.or.cz/git-gui.git
25+
$ cd git-gui.git
26+
$ git checkout -b my-translation
2827

29-
The "git checkout" command creates a 'mob' branch from upstream's
30-
corresponding branch and makes it your current branch. You will be
31-
working on this branch.
32-
33-
The "git config" command records in your repository configuration file
34-
that you would push "mob" branch to the upstream when you say "git
35-
push".
28+
The "git checkout" command creates a new branch to keep your work
29+
isolated and to make it simple to post your patch series when
30+
completed. You will be working on this branch.
3631

3732

3833
2. Starting a new language.
3934

40-
In the git-gui-i18n directory is a po/ subdirectory. It has a
41-
handful files whose names end with ".po". Is there a file that has
42-
messages in your language?
35+
In the git-gui directory is a po/ subdirectory. It has a handful of
36+
files whose names end with ".po". Is there a file that has messages
37+
in your language?
4338

4439
If you do not know what your language should be named, you need to find
4540
it. This currently follows ISO 639-1 two letter codes:
@@ -149,15 +144,18 @@ There is a trick to test your translation without first installing:
149144
$ make
150145
$ LANG=af ./git-gui.sh
151146

152-
When you are satisfied with your translation, commit your changes, and
153-
push it back to the 'mob' branch:
147+
When you are satisfied with your translation, commit your changes then submit
148+
your patch series to the maintainer and the Git mailing list:
154149

155150
$ edit po/af.po
156151
... be sure to update Last-Translator: and
157152
... PO-Revision-Date: lines.
158153
$ git add po/af.po
159-
$ git commit -m 'Started Afrikaans translation.'
160-
$ git push
154+
$ git commit -s -m 'git-gui: added Afrikaans translation.'
155+
$ git send-email --to '[email protected]' \
156+
--cc 'Pat Thoyts <[email protected]>' \
157+
--subject 'git-gui: Afrikaans translation' \
158+
master..
161159

162160

163161
3. Updating your translation.
@@ -169,6 +167,7 @@ itself was updated and there are new messages that need translation.
169167

170168
In any case, make sure you are up-to-date before starting your work:
171169

170+
$ git checkout master
172171
$ git pull
173172

174173
In the former case, you will edit po/af.po (again, replace "af" with

git-gui/po/sv.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1714,7 +1714,7 @@ msgstr ""
17141714

17151715
#: lib/index.tcl:30
17161716
msgid "Continue"
1717-
msgstr "Forstätt"
1717+
msgstr "Fortsätt"
17181718

17191719
#: lib/index.tcl:33
17201720
msgid "Unlock Index"

0 commit comments

Comments
 (0)