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
This commit is contained in:
Junio C Hamano 2010-01-24 11:16:26 -08:00
commit b30ccd7573
5 changed files with 47 additions and 22 deletions

View File

@ -7,7 +7,7 @@ all::
# TCL_PATH must be vaild for this to work. # TCL_PATH must be vaild for this to work.
# #
GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE GIT-VERSION-FILE: FORCE
@$(SHELL_PATH) ./GIT-VERSION-GEN @$(SHELL_PATH) ./GIT-VERSION-GEN
-include GIT-VERSION-FILE -include GIT-VERSION-FILE
@ -270,7 +270,7 @@ TRACK_VARS = \
GITGUI_MACOSXAPP=$(GITGUI_MACOSXAPP) \ GITGUI_MACOSXAPP=$(GITGUI_MACOSXAPP) \
#end TRACK_VARS #end TRACK_VARS
GIT-GUI-VARS: .FORCE-GIT-GUI-VARS GIT-GUI-VARS: FORCE
@VARS='$(TRACK_VARS)'; \ @VARS='$(TRACK_VARS)'; \
if test x"$$VARS" != x"`cat $@ 2>/dev/null`" ; then \ if test x"$$VARS" != x"`cat $@ 2>/dev/null`" ; then \
echo 1>&2 " * new locations or Tcl/Tk interpreter"; \ echo 1>&2 " * new locations or Tcl/Tk interpreter"; \
@ -340,5 +340,4 @@ ifdef GITGUI_WINDOWS_WRAPPER
endif endif
.PHONY: all install uninstall dist-version clean .PHONY: all install uninstall dist-version clean
.PHONY: .FORCE-GIT-VERSION-FILE .PHONY: FORCE
.PHONY: .FORCE-GIT-GUI-VARS

View File

@ -1074,6 +1074,8 @@ if {[catch {
set _prefix {} set _prefix {}
}] }]
&& [catch { && [catch {
# beware that from the .git dir this sets _gitdir to .
# and _prefix to the empty string
set _gitdir [git rev-parse --git-dir] set _gitdir [git rev-parse --git-dir]
set _prefix [git rev-parse --show-prefix] set _prefix [git rev-parse --show-prefix]
} err]} { } err]} {
@ -1082,6 +1084,14 @@ if {[catch {
choose_repository::pick choose_repository::pick
set picked 1 set picked 1
} }
# we expand the _gitdir when it's just a single dot (i.e. when we're being
# run from the .git dir itself) lest the routines to find the worktree
# get confused
if {$_gitdir eq "."} {
set _gitdir [pwd]
}
if {![file isdirectory $_gitdir] && [is_Cygwin]} { if {![file isdirectory $_gitdir] && [is_Cygwin]} {
catch {set _gitdir [exec cygpath --windows $_gitdir]} catch {set _gitdir [exec cygpath --windows $_gitdir]}
} }
@ -1613,6 +1623,9 @@ proc merge_state {path new_state {head_info {}} {index_info {}}} {
} elseif {$s0 ne {_} && [string index $state 0] eq {_} } elseif {$s0 ne {_} && [string index $state 0] eq {_}
&& $head_info eq {}} { && $head_info eq {}} {
set head_info $index_info set head_info $index_info
} elseif {$s0 eq {_} && [string index $state 0] ne {_}} {
set index_info $head_info
set head_info {}
} }
set file_states($path) [list $s0$s1 $icon \ set file_states($path) [list $s0$s1 $icon \
@ -1941,7 +1954,7 @@ proc do_gitk {revs} {
cd [file dirname [gitdir]] cd [file dirname [gitdir]]
set env(GIT_DIR) [file tail [gitdir]] set env(GIT_DIR) [file tail [gitdir]]
eval exec $cmd $revs & eval exec $cmd $revs "--" "--" &
if {$old_GIT_DIR eq {}} { if {$old_GIT_DIR eq {}} {
unset env(GIT_DIR) unset env(GIT_DIR)
@ -2543,12 +2556,14 @@ if {[is_enabled multicommit] || [is_enabled singlecommit]} {
[list .mbar.commit entryconf [.mbar.commit index last] -state] [list .mbar.commit entryconf [.mbar.commit index last] -state]
.mbar.commit add command -label [mc "Unstage From Commit"] \ .mbar.commit add command -label [mc "Unstage From Commit"] \
-command do_unstage_selection -command do_unstage_selection \
-accelerator $M1T-U
lappend disable_on_lock \ lappend disable_on_lock \
[list .mbar.commit entryconf [.mbar.commit index last] -state] [list .mbar.commit entryconf [.mbar.commit index last] -state]
.mbar.commit add command -label [mc "Revert Changes"] \ .mbar.commit add command -label [mc "Revert Changes"] \
-command do_revert_selection -command do_revert_selection \
-accelerator $M1T-J
lappend disable_on_lock \ lappend disable_on_lock \
[list .mbar.commit entryconf [.mbar.commit index last] -state] [list .mbar.commit entryconf [.mbar.commit index last] -state]
@ -3296,6 +3311,10 @@ unset gws
bind $ui_comm <$M1B-Key-Return> {do_commit;break} bind $ui_comm <$M1B-Key-Return> {do_commit;break}
bind $ui_comm <$M1B-Key-t> {do_add_selection;break} bind $ui_comm <$M1B-Key-t> {do_add_selection;break}
bind $ui_comm <$M1B-Key-T> {do_add_selection;break} bind $ui_comm <$M1B-Key-T> {do_add_selection;break}
bind $ui_comm <$M1B-Key-u> {do_unstage_selection;break}
bind $ui_comm <$M1B-Key-U> {do_unstage_selection;break}
bind $ui_comm <$M1B-Key-j> {do_revert_selection;break}
bind $ui_comm <$M1B-Key-J> {do_revert_selection;break}
bind $ui_comm <$M1B-Key-i> {do_add_all;break} bind $ui_comm <$M1B-Key-i> {do_add_all;break}
bind $ui_comm <$M1B-Key-I> {do_add_all;break} bind $ui_comm <$M1B-Key-I> {do_add_all;break}
bind $ui_comm <$M1B-Key-x> {tk_textCut %W;break} bind $ui_comm <$M1B-Key-x> {tk_textCut %W;break}

View File

@ -235,6 +235,8 @@ proc _get_recentrepos {} {
foreach p [get_config gui.recentrepo] { foreach p [get_config gui.recentrepo] {
if {[_is_git [file join $p .git]]} { if {[_is_git [file join $p .git]]} {
lappend recent $p lappend recent $p
} else {
_unset_recentrepo $p
} }
} }
return [lsort $recent] return [lsort $recent]
@ -243,6 +245,7 @@ proc _get_recentrepos {} {
proc _unset_recentrepo {p} { proc _unset_recentrepo {p} {
regsub -all -- {([()\[\]{}\.^$+*?\\])} $p {\\\1} p regsub -all -- {([()\[\]{}\.^$+*?\\])} $p {\\\1} p
git config --global --unset gui.recentrepo "^$p\$" git config --global --unset gui.recentrepo "^$p\$"
load_config 1
} }
proc _append_recentrepos {path} { proc _append_recentrepos {path} {
@ -261,6 +264,7 @@ proc _append_recentrepos {path} {
lappend recent $path lappend recent $path
git config --global --add gui.recentrepo $path git config --global --add gui.recentrepo $path
load_config 1
while {[llength $recent] > 10} { while {[llength $recent] > 10} {
_unset_recentrepo [lindex $recent 0] _unset_recentrepo [lindex $recent 0]

View File

@ -664,6 +664,7 @@ proc apply_line {x y} {
} }
set i_l $next_l set i_l $next_l
} }
set patch "$patch$pre_context"
set patch "@@ -$hln,$n +$hln,[eval expr $n $sign 1] @@\n$patch" set patch "@@ -$hln,$n +$hln,[eval expr $n $sign 1] @@\n$patch"
if {[catch { if {[catch {

View File

@ -14,29 +14,31 @@ proc _close_updateindex {fd after} {
toplevel $w toplevel $w
wm title $w [strcat "[appname] ([reponame]): " [mc "Index Error"]] wm title $w [strcat "[appname] ([reponame]): " [mc "Index Error"]]
wm geometry $w "+[winfo rootx .]+[winfo rooty .]" wm geometry $w "+[winfo rootx .]+[winfo rooty .]"
pack [label $w.msg \ set s [mc "Updating the Git index failed. A rescan will be automatically started to resynchronize git-gui."]
-justify left \ text $w.msg -yscrollcommand [list $w.vs set] \
-anchor w \ -width [string length $s] -relief flat \
-text [strcat \ -borderwidth 0 -highlightthickness 0 \
[mc "Updating the Git index failed. A rescan will be automatically started to resynchronize git-gui."] \ -background [$w cget -background]
"\n\n$err"] \ $w.msg tag configure bold -font font_uibold -justify center
] -anchor w scrollbar $w.vs -command [list $w.msg yview]
$w.msg insert end $s bold \n\n$err {}
$w.msg configure -state disabled
frame $w.buttons button $w.continue \
button $w.buttons.continue \
-text [mc "Continue"] \ -text [mc "Continue"] \
-command [list destroy $w] -command [list destroy $w]
pack $w.buttons.continue -side right -padx 5 button $w.unlock \
button $w.buttons.unlock \
-text [mc "Unlock Index"] \ -text [mc "Unlock Index"] \
-command "destroy $w; _delete_indexlock" -command "destroy $w; _delete_indexlock"
pack $w.buttons.unlock -side right grid $w.msg - $w.vs -sticky news
pack $w.buttons -side bottom -fill x -pady 10 -padx 10 grid $w.unlock $w.continue - -sticky se -padx 2 -pady 2
grid columnconfigure $w 0 -weight 1
grid rowconfigure $w 0 -weight 1
wm protocol $w WM_DELETE_WINDOW update wm protocol $w WM_DELETE_WINDOW update
bind $w.buttons.continue <Visibility> " bind $w.continue <Visibility> "
grab $w grab $w
focus $w.buttons.continue focus %W
" "
tkwait window $w tkwait window $w