Skip to content

Commit b30ccd7

Browse files
committed
Merge branch 'maint' of git://git.spearce.org/git-gui into maint
* 'maint' of git://git.spearce.org/git-gui: git-gui: work from the .git dir git-gui: Fix applying a line when all following lines are deletions git-gui: Correct file_states when unstaging partly staged entry git-gui: Fix gitk for branch whose name matches local file git-gui: Keep repo_config(gui.recentrepos) and .gitconfig in sync git-gui: handle really long error messages in updateindex. git-gui: Add hotkeys for "Unstage from commit" and "Revert changes" git-gui: Makefile: consolidate .FORCE-* targets
2 parents 288123f + 87cd09f commit b30ccd7

File tree

5 files changed

+48
-23
lines changed

5 files changed

+48
-23
lines changed

git-gui/Makefile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ all::
77
# TCL_PATH must be vaild for this to work.
88
#
99

10-
GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
10+
GIT-VERSION-FILE: FORCE
1111
@$(SHELL_PATH) ./GIT-VERSION-GEN
1212
-include GIT-VERSION-FILE
1313

@@ -270,7 +270,7 @@ TRACK_VARS = \
270270
GITGUI_MACOSXAPP=$(GITGUI_MACOSXAPP) \
271271
#end TRACK_VARS
272272

273-
GIT-GUI-VARS: .FORCE-GIT-GUI-VARS
273+
GIT-GUI-VARS: FORCE
274274
@VARS='$(TRACK_VARS)'; \
275275
if test x"$$VARS" != x"`cat $@ 2>/dev/null`" ; then \
276276
echo 1>&2 " * new locations or Tcl/Tk interpreter"; \
@@ -340,5 +340,4 @@ ifdef GITGUI_WINDOWS_WRAPPER
340340
endif
341341

342342
.PHONY: all install uninstall dist-version clean
343-
.PHONY: .FORCE-GIT-VERSION-FILE
344-
.PHONY: .FORCE-GIT-GUI-VARS
343+
.PHONY: FORCE

git-gui/git-gui.sh

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,6 +1074,8 @@ if {[catch {
10741074
set _prefix {}
10751075
}]
10761076
&& [catch {
1077+
# beware that from the .git dir this sets _gitdir to .
1078+
# and _prefix to the empty string
10771079
set _gitdir [git rev-parse --git-dir]
10781080
set _prefix [git rev-parse --show-prefix]
10791081
} err]} {
@@ -1082,6 +1084,14 @@ if {[catch {
10821084
choose_repository::pick
10831085
set picked 1
10841086
}
1087+
1088+
# we expand the _gitdir when it's just a single dot (i.e. when we're being
1089+
# run from the .git dir itself) lest the routines to find the worktree
1090+
# get confused
1091+
if {$_gitdir eq "."} {
1092+
set _gitdir [pwd]
1093+
}
1094+
10851095
if {![file isdirectory $_gitdir] && [is_Cygwin]} {
10861096
catch {set _gitdir [exec cygpath --windows $_gitdir]}
10871097
}
@@ -1613,6 +1623,9 @@ proc merge_state {path new_state {head_info {}} {index_info {}}} {
16131623
} elseif {$s0 ne {_} && [string index $state 0] eq {_}
16141624
&& $head_info eq {}} {
16151625
set head_info $index_info
1626+
} elseif {$s0 eq {_} && [string index $state 0] ne {_}} {
1627+
set index_info $head_info
1628+
set head_info {}
16161629
}
16171630
16181631
set file_states($path) [list $s0$s1 $icon \
@@ -1941,7 +1954,7 @@ proc do_gitk {revs} {
19411954
cd [file dirname [gitdir]]
19421955
set env(GIT_DIR) [file tail [gitdir]]
19431956
1944-
eval exec $cmd $revs &
1957+
eval exec $cmd $revs "--" "--" &
19451958
19461959
if {$old_GIT_DIR eq {}} {
19471960
unset env(GIT_DIR)
@@ -2543,12 +2556,14 @@ if {[is_enabled multicommit] || [is_enabled singlecommit]} {
25432556
[list .mbar.commit entryconf [.mbar.commit index last] -state]
25442557
25452558
.mbar.commit add command -label [mc "Unstage From Commit"] \
2546-
-command do_unstage_selection
2559+
-command do_unstage_selection \
2560+
-accelerator $M1T-U
25472561
lappend disable_on_lock \
25482562
[list .mbar.commit entryconf [.mbar.commit index last] -state]
25492563
25502564
.mbar.commit add command -label [mc "Revert Changes"] \
2551-
-command do_revert_selection
2565+
-command do_revert_selection \
2566+
-accelerator $M1T-J
25522567
lappend disable_on_lock \
25532568
[list .mbar.commit entryconf [.mbar.commit index last] -state]
25542569
@@ -3296,6 +3311,10 @@ unset gws
32963311
bind $ui_comm <$M1B-Key-Return> {do_commit;break}
32973312
bind $ui_comm <$M1B-Key-t> {do_add_selection;break}
32983313
bind $ui_comm <$M1B-Key-T> {do_add_selection;break}
3314+
bind $ui_comm <$M1B-Key-u> {do_unstage_selection;break}
3315+
bind $ui_comm <$M1B-Key-U> {do_unstage_selection;break}
3316+
bind $ui_comm <$M1B-Key-j> {do_revert_selection;break}
3317+
bind $ui_comm <$M1B-Key-J> {do_revert_selection;break}
32993318
bind $ui_comm <$M1B-Key-i> {do_add_all;break}
33003319
bind $ui_comm <$M1B-Key-I> {do_add_all;break}
33013320
bind $ui_comm <$M1B-Key-x> {tk_textCut %W;break}

git-gui/lib/choose_repository.tcl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ proc _get_recentrepos {} {
235235
foreach p [get_config gui.recentrepo] {
236236
if {[_is_git [file join $p .git]]} {
237237
lappend recent $p
238+
} else {
239+
_unset_recentrepo $p
238240
}
239241
}
240242
return [lsort $recent]
@@ -243,6 +245,7 @@ proc _get_recentrepos {} {
243245
proc _unset_recentrepo {p} {
244246
regsub -all -- {([()\[\]{}\.^$+*?\\])} $p {\\\1} p
245247
git config --global --unset gui.recentrepo "^$p\$"
248+
load_config 1
246249
}
247250

248251
proc _append_recentrepos {path} {
@@ -261,6 +264,7 @@ proc _append_recentrepos {path} {
261264

262265
lappend recent $path
263266
git config --global --add gui.recentrepo $path
267+
load_config 1
264268

265269
while {[llength $recent] > 10} {
266270
_unset_recentrepo [lindex $recent 0]

git-gui/lib/diff.tcl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,7 @@ proc apply_line {x y} {
664664
}
665665
set i_l $next_l
666666
}
667+
set patch "$patch$pre_context"
667668
set patch "@@ -$hln,$n +$hln,[eval expr $n $sign 1] @@\n$patch"
668669

669670
if {[catch {

git-gui/lib/index.tcl

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,31 @@ proc _close_updateindex {fd after} {
1414
toplevel $w
1515
wm title $w [strcat "[appname] ([reponame]): " [mc "Index Error"]]
1616
wm geometry $w "+[winfo rootx .]+[winfo rooty .]"
17-
pack [label $w.msg \
18-
-justify left \
19-
-anchor w \
20-
-text [strcat \
21-
[mc "Updating the Git index failed. A rescan will be automatically started to resynchronize git-gui."] \
22-
"\n\n$err"] \
23-
] -anchor w
24-
25-
frame $w.buttons
26-
button $w.buttons.continue \
17+
set s [mc "Updating the Git index failed. A rescan will be automatically started to resynchronize git-gui."]
18+
text $w.msg -yscrollcommand [list $w.vs set] \
19+
-width [string length $s] -relief flat \
20+
-borderwidth 0 -highlightthickness 0 \
21+
-background [$w cget -background]
22+
$w.msg tag configure bold -font font_uibold -justify center
23+
scrollbar $w.vs -command [list $w.msg yview]
24+
$w.msg insert end $s bold \n\n$err {}
25+
$w.msg configure -state disabled
26+
27+
button $w.continue \
2728
-text [mc "Continue"] \
2829
-command [list destroy $w]
29-
pack $w.buttons.continue -side right -padx 5
30-
button $w.buttons.unlock \
30+
button $w.unlock \
3131
-text [mc "Unlock Index"] \
3232
-command "destroy $w; _delete_indexlock"
33-
pack $w.buttons.unlock -side right
34-
pack $w.buttons -side bottom -fill x -pady 10 -padx 10
33+
grid $w.msg - $w.vs -sticky news
34+
grid $w.unlock $w.continue - -sticky se -padx 2 -pady 2
35+
grid columnconfigure $w 0 -weight 1
36+
grid rowconfigure $w 0 -weight 1
3537

3638
wm protocol $w WM_DELETE_WINDOW update
37-
bind $w.buttons.continue <Visibility> "
39+
bind $w.continue <Visibility> "
3840
grab $w
39-
focus $w.buttons.continue
41+
focus %W
4042
"
4143
tkwait window $w
4244

0 commit comments

Comments
 (0)