зеркало из https://github.com/microsoft/git.git
Merge branch 'gitk-and-git-gui-patches'
These are Git for Windows' Git GUI and gitk patches. We will have to decide at some point what to do about them, but that's a little lower priority (as Git GUI seems to be unmaintained for the time being, and the gitk maintainer keeps a very low profile on the Git mailing list, too). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
Коммит
0c9d990bee
|
@ -293,6 +293,7 @@ install: all
|
|||
$(QUIET)$(INSTALL_D0)'$(DESTDIR_SQ)$(gitexecdir_SQ)' $(INSTALL_D1)
|
||||
$(QUIET)$(INSTALL_X0)git-gui $(INSTALL_X1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
|
||||
$(QUIET)$(INSTALL_X0)git-gui--askpass $(INSTALL_X1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
|
||||
$(QUIET)$(INSTALL_X0)git-gui--askyesno $(INSTALL_X1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
|
||||
$(QUIET)$(foreach p,$(GITGUI_BUILT_INS), $(INSTALL_L0)'$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' $(INSTALL_L1)'$(DESTDIR_SQ)$(gitexecdir_SQ)/git-gui' $(INSTALL_L2)'$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' $(INSTALL_L3) &&) true
|
||||
ifdef GITGUI_WINDOWS_WRAPPER
|
||||
$(QUIET)$(INSTALL_R0)git-gui.tcl $(INSTALL_R1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
|
||||
|
@ -311,6 +312,7 @@ uninstall:
|
|||
$(QUIET)$(CLEAN_DST) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
|
||||
$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui $(REMOVE_F1)
|
||||
$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui--askpass $(REMOVE_F1)
|
||||
$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui--askyesno $(REMOVE_F1)
|
||||
$(QUIET)$(foreach p,$(GITGUI_BUILT_INS), $(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/$p $(REMOVE_F1) &&) true
|
||||
ifdef GITGUI_WINDOWS_WRAPPER
|
||||
$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui.tcl $(REMOVE_F1)
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
#!/bin/sh
|
||||
# Tcl ignores the next line -*- tcl -*- \
|
||||
exec wish "$0" -- "$@"
|
||||
|
||||
# This is an implementation of a simple yes no dialog
|
||||
# which is injected into the git commandline by git gui
|
||||
# in case a yesno question needs to be answered.
|
||||
|
||||
set NS {}
|
||||
set use_ttk [package vsatisfies [package provide Tk] 8.5]
|
||||
if {$use_ttk} {
|
||||
set NS ttk
|
||||
}
|
||||
|
||||
set title "Question?"
|
||||
if {$argc < 1} {
|
||||
puts stderr "Usage: $argv0 <question>"
|
||||
exit 1
|
||||
} else {
|
||||
if {$argc > 2 && [lindex $argv 0] == "--title"} {
|
||||
set title [lindex $argv 1]
|
||||
set argv [lreplace $argv 0 1]
|
||||
}
|
||||
set prompt [join $argv " "]
|
||||
}
|
||||
|
||||
${NS}::frame .t
|
||||
${NS}::label .t.m -text $prompt -justify center -width 400px
|
||||
.t.m configure -wraplength 400px
|
||||
pack .t.m -side top -fill x -padx 20 -pady 20 -expand 1
|
||||
pack .t -side top -fill x -ipadx 20 -ipady 20 -expand 1
|
||||
|
||||
${NS}::frame .b
|
||||
${NS}::frame .b.left -width 200
|
||||
${NS}::button .b.yes -text Yes -command yes
|
||||
${NS}::button .b.no -text No -command no
|
||||
|
||||
|
||||
pack .b.left -side left -expand 1 -fill x
|
||||
pack .b.yes -side left -expand 1
|
||||
pack .b.no -side right -expand 1 -ipadx 5
|
||||
pack .b -side bottom -fill x -ipadx 20 -ipady 15
|
||||
|
||||
bind . <Key-Return> {exit 0}
|
||||
bind . <Key-Escape> {exit 1}
|
||||
|
||||
proc no {} {
|
||||
exit 1
|
||||
}
|
||||
|
||||
proc yes {} {
|
||||
exit 0
|
||||
}
|
||||
|
||||
if {$::tcl_platform(platform) eq {windows}} {
|
||||
set icopath [file dirname [file normalize $argv0]]
|
||||
if {[file tail $icopath] eq {git-core}} {
|
||||
set icopath [file dirname $icopath]
|
||||
}
|
||||
set icopath [file dirname $icopath]
|
||||
set icopath [file join $icopath share git git-for-windows.ico]
|
||||
if {[file exists $icopath]} {
|
||||
wm iconbitmap . -default $icopath
|
||||
}
|
||||
}
|
||||
|
||||
wm title . $title
|
||||
tk::PlaceWindow .
|
|
@ -623,7 +623,11 @@ proc git_write {args} {
|
|||
}
|
||||
|
||||
proc githook_read {hook_name args} {
|
||||
set pchook [gitdir hooks $hook_name]
|
||||
if {[package vcompare $::_git_version 2.5.0] >= 0} {
|
||||
set pchook [git rev-parse --git-path "hooks/$hook_name"]
|
||||
} else {
|
||||
set pchook [gitdir hooks $hook_name]
|
||||
}
|
||||
lappend args 2>@1
|
||||
|
||||
# On Windows [file executable] might lie so we need to ask
|
||||
|
@ -1229,6 +1233,12 @@ set have_tk85 [expr {[package vcompare $tk_version "8.5"] >= 0}]
|
|||
if {![info exists env(SSH_ASKPASS)]} {
|
||||
set env(SSH_ASKPASS) [gitexec git-gui--askpass]
|
||||
}
|
||||
if {![info exists env(GIT_ASKPASS)]} {
|
||||
set env(GIT_ASKPASS) [gitexec git-gui--askpass]
|
||||
}
|
||||
if {![info exists env(GIT_ASK_YESNO)]} {
|
||||
set env(GIT_ASK_YESNO) [gitexec git-gui--askyesno]
|
||||
}
|
||||
|
||||
######################################################################
|
||||
##
|
||||
|
@ -1325,9 +1335,6 @@ if {[lindex $_reponame end] eq {.git}} {
|
|||
set _reponame [lindex $_reponame end]
|
||||
}
|
||||
|
||||
set env(GIT_DIR) $_gitdir
|
||||
set env(GIT_WORK_TREE) $_gitworktree
|
||||
|
||||
######################################################################
|
||||
##
|
||||
## global init
|
||||
|
@ -2152,7 +2159,7 @@ set starting_gitk_msg [mc "Starting gitk... please wait..."]
|
|||
|
||||
proc do_gitk {revs {is_submodule false}} {
|
||||
global current_diff_path file_states current_diff_side ui_index
|
||||
global _gitdir _gitworktree
|
||||
global _gitworktree
|
||||
|
||||
# -- Always start gitk through whatever we were loaded with. This
|
||||
# lets us bypass using shell process on Windows systems.
|
||||
|
@ -2164,12 +2171,19 @@ proc do_gitk {revs {is_submodule false}} {
|
|||
} else {
|
||||
global env
|
||||
|
||||
if {[info exists env(GIT_DIR)]} {
|
||||
set old_GIT_DIR $env(GIT_DIR)
|
||||
} else {
|
||||
set old_GIT_DIR {}
|
||||
}
|
||||
|
||||
set pwd [pwd]
|
||||
|
||||
if {!$is_submodule} {
|
||||
if {![is_bare]} {
|
||||
cd $_gitworktree
|
||||
}
|
||||
set env(GIT_DIR) [file normalize [gitdir]]
|
||||
} else {
|
||||
cd $current_diff_path
|
||||
if {$revs eq {--}} {
|
||||
|
@ -2190,18 +2204,17 @@ proc do_gitk {revs {is_submodule false}} {
|
|||
}
|
||||
set revs $old_sha1...$new_sha1
|
||||
}
|
||||
# GIT_DIR and GIT_WORK_TREE for the submodule are not the ones
|
||||
# we've been using for the main repository, so unset them.
|
||||
# TODO we could make life easier (start up faster?) for gitk
|
||||
# by setting these to the appropriate values to allow gitk
|
||||
# to skip the heuristics to find their proper value
|
||||
unset env(GIT_DIR)
|
||||
unset env(GIT_WORK_TREE)
|
||||
if {[info exists env(GIT_DIR)]} {
|
||||
unset env(GIT_DIR)
|
||||
}
|
||||
}
|
||||
eval exec $cmd $revs "--" "--" &
|
||||
|
||||
set env(GIT_DIR) $_gitdir
|
||||
set env(GIT_WORK_TREE) $_gitworktree
|
||||
if {$old_GIT_DIR ne {}} {
|
||||
set env(GIT_DIR) $old_GIT_DIR
|
||||
} else {
|
||||
unset env(GIT_DIR)
|
||||
}
|
||||
cd $pwd
|
||||
|
||||
ui_status $::starting_gitk_msg
|
||||
|
@ -2222,20 +2235,22 @@ proc do_git_gui {} {
|
|||
error_popup [mc "Couldn't find git gui in PATH"]
|
||||
} else {
|
||||
global env
|
||||
global _gitdir _gitworktree
|
||||
|
||||
# see note in do_gitk about unsetting these vars when
|
||||
# running tools in a submodule
|
||||
unset env(GIT_DIR)
|
||||
unset env(GIT_WORK_TREE)
|
||||
if {[info exists env(GIT_DIR)]} {
|
||||
set old_GIT_DIR $env(GIT_DIR)
|
||||
unset env(GIT_DIR)
|
||||
} else {
|
||||
set old_GIT_DIR {}
|
||||
}
|
||||
|
||||
set pwd [pwd]
|
||||
cd $current_diff_path
|
||||
|
||||
eval exec $exe gui &
|
||||
|
||||
set env(GIT_DIR) $_gitdir
|
||||
set env(GIT_WORK_TREE) $_gitworktree
|
||||
if {$old_GIT_DIR ne {}} {
|
||||
set env(GIT_DIR) $old_GIT_DIR
|
||||
}
|
||||
cd $pwd
|
||||
|
||||
ui_status $::starting_gitk_msg
|
||||
|
@ -2706,10 +2721,18 @@ if {![is_bare]} {
|
|||
}
|
||||
|
||||
if {[is_Windows]} {
|
||||
# Use /git-bash.exe if available
|
||||
set normalized [file normalize $::argv0]
|
||||
regsub "/mingw../libexec/git-core/git-gui$" \
|
||||
$normalized "/git-bash.exe" cmdLine
|
||||
if {$cmdLine != $normalized && [file exists $cmdLine]} {
|
||||
set cmdLine [list "Git Bash" $cmdLine &]
|
||||
} else {
|
||||
set cmdLine [list "Git Bash" bash --login -l &]
|
||||
}
|
||||
.mbar.repository add command \
|
||||
-label [mc "Git Bash"] \
|
||||
-command {eval exec [auto_execok start] \
|
||||
[list "Git Bash" bash --login -l &]}
|
||||
-command {eval exec [auto_execok start] $cmdLine}
|
||||
}
|
||||
|
||||
if {[is_Windows] || ![is_bare]} {
|
||||
|
|
|
@ -2084,7 +2084,7 @@ proc makewindow {} {
|
|||
global headctxmenu progresscanv progressitem progresscoords statusw
|
||||
global fprogitem fprogcoord lastprogupdate progupdatepending
|
||||
global rprogitem rprogcoord rownumsel numcommits
|
||||
global have_tk85 use_ttk NS
|
||||
global have_tk85 have_tk86 use_ttk NS
|
||||
global git_version
|
||||
global worddiff
|
||||
|
||||
|
@ -2574,8 +2574,13 @@ proc makewindow {} {
|
|||
bind . <Key-Down> "selnextline 1"
|
||||
bind . <Shift-Key-Up> "dofind -1 0"
|
||||
bind . <Shift-Key-Down> "dofind 1 0"
|
||||
bindkey <Key-Right> "goforw"
|
||||
bindkey <Key-Left> "goback"
|
||||
if {$have_tk86} {
|
||||
bindkey <<NextChar>> "goforw"
|
||||
bindkey <<PrevChar>> "goback"
|
||||
} else {
|
||||
bindkey <Key-Right> "goforw"
|
||||
bindkey <Key-Left> "goback"
|
||||
}
|
||||
bind . <Key-Prior> "selnextpage -1"
|
||||
bind . <Key-Next> "selnextpage 1"
|
||||
bind . <$M1B-Home> "allcanvs yview moveto 0.0"
|
||||
|
@ -7642,7 +7647,7 @@ proc gettreeline {gtf id} {
|
|||
if {[string index $fname 0] eq "\""} {
|
||||
set fname [lindex $fname 0]
|
||||
}
|
||||
set fname [encoding convertfrom $fname]
|
||||
set fname [encoding convertfrom utf-8 $fname]
|
||||
lappend treefilelist($id) $fname
|
||||
}
|
||||
if {![eof $gtf]} {
|
||||
|
@ -7904,7 +7909,7 @@ proc gettreediffline {gdtf ids} {
|
|||
if {[string index $file 0] eq "\""} {
|
||||
set file [lindex $file 0]
|
||||
}
|
||||
set file [encoding convertfrom $file]
|
||||
set file [encoding convertfrom utf-8 $file]
|
||||
if {$file ne [lindex $treediff end]} {
|
||||
lappend treediff $file
|
||||
lappend sublist $file
|
||||
|
@ -8049,7 +8054,7 @@ proc makediffhdr {fname ids} {
|
|||
global ctext curdiffstart treediffs diffencoding
|
||||
global ctext_file_names jump_to_here targetline diffline
|
||||
|
||||
set fname [encoding convertfrom $fname]
|
||||
set fname [encoding convertfrom utf-8 $fname]
|
||||
set diffencoding [get_path_encoding $fname]
|
||||
set i [lsearch -exact $treediffs($ids) $fname]
|
||||
if {$i >= 0} {
|
||||
|
@ -8111,7 +8116,7 @@ proc parseblobdiffline {ids line} {
|
|||
|
||||
if {![string compare -length 5 "diff " $line]} {
|
||||
if {![regexp {^diff (--cc|--git) } $line m type]} {
|
||||
set line [encoding convertfrom $line]
|
||||
set line [encoding convertfrom utf-8 $line]
|
||||
$ctext insert end "$line\n" hunksep
|
||||
continue
|
||||
}
|
||||
|
@ -8158,7 +8163,7 @@ proc parseblobdiffline {ids line} {
|
|||
makediffhdr $fname $ids
|
||||
|
||||
} elseif {![string compare -length 16 "* Unmerged path " $line]} {
|
||||
set fname [encoding convertfrom [string range $line 16 end]]
|
||||
set fname [encoding convertfrom utf-8 [string range $line 16 end]]
|
||||
$ctext insert end "\n"
|
||||
set curdiffstart [$ctext index "end - 1c"]
|
||||
lappend ctext_file_names $fname
|
||||
|
@ -8213,7 +8218,7 @@ proc parseblobdiffline {ids line} {
|
|||
if {[string index $fname 0] eq "\""} {
|
||||
set fname [lindex $fname 0]
|
||||
}
|
||||
set fname [encoding convertfrom $fname]
|
||||
set fname [encoding convertfrom utf-8 $fname]
|
||||
set i [lsearch -exact $treediffs($ids) $fname]
|
||||
if {$i >= 0} {
|
||||
setinlist difffilestart $i $curdiffstart
|
||||
|
@ -8232,6 +8237,7 @@ proc parseblobdiffline {ids line} {
|
|||
set diffinhdr 0
|
||||
return
|
||||
}
|
||||
set line [encoding convertfrom utf-8 $line]
|
||||
$ctext insert end "$line\n" filesep
|
||||
|
||||
} else {
|
||||
|
@ -9990,7 +9996,7 @@ proc showrefs {} {
|
|||
text $top.list -background $bgcolor -foreground $fgcolor \
|
||||
-selectbackground $selectbgcolor -font mainfont \
|
||||
-xscrollcommand "$top.xsb set" -yscrollcommand "$top.ysb set" \
|
||||
-width 30 -height 20 -cursor $maincursor \
|
||||
-width 60 -height 20 -cursor $maincursor \
|
||||
-spacing1 1 -spacing3 1 -state disabled
|
||||
$top.list tag configure highlight -background $selectbgcolor
|
||||
if {![lsearch -exact $bglist $top.list]} {
|
||||
|
@ -12175,7 +12181,7 @@ proc cache_gitattr {attr pathlist} {
|
|||
foreach row [split $rlist "\n"] {
|
||||
if {[regexp "(.*): $attr: (.*)" $row m path value]} {
|
||||
if {[string index $path 0] eq "\""} {
|
||||
set path [encoding convertfrom [lindex $path 0]]
|
||||
set path [encoding convertfrom utf-8 [lindex $path 0]]
|
||||
}
|
||||
set path_attr_cache($attr,$path) $value
|
||||
}
|
||||
|
@ -12205,7 +12211,6 @@ if { [info exists ::env(GITK_MSGSDIR)] } {
|
|||
set gitk_prefix [file dirname [file dirname [file normalize $argv0]]]
|
||||
set gitk_libdir [file join $gitk_prefix share gitk lib]
|
||||
set gitk_msgsdir [file join $gitk_libdir msgs]
|
||||
unset gitk_prefix
|
||||
}
|
||||
|
||||
## Internationalization (i18n) through msgcat and gettext. See
|
||||
|
@ -12496,6 +12501,7 @@ set nullid2 "0000000000000000000000000000000000000001"
|
|||
set nullfile "/dev/null"
|
||||
|
||||
set have_tk85 [expr {[package vcompare $tk_version "8.5"] >= 0}]
|
||||
set have_tk86 [expr {[package vcompare $tk_version "8.6"] >= 0}]
|
||||
if {![info exists have_ttk]} {
|
||||
set have_ttk [llength [info commands ::ttk::style]]
|
||||
}
|
||||
|
@ -12560,28 +12566,32 @@ if {[expr {[exec git rev-parse --is-inside-work-tree] == "true"}]} {
|
|||
set worktree [exec git rev-parse --show-toplevel]
|
||||
setcoords
|
||||
makewindow
|
||||
catch {
|
||||
image create photo gitlogo -width 16 -height 16
|
||||
if {$::tcl_platform(platform) eq {windows} && [file exists $gitk_prefix/etc/git.ico]} {
|
||||
wm iconbitmap . -default $gitk_prefix/etc/git.ico
|
||||
} else {
|
||||
catch {
|
||||
image create photo gitlogo -width 16 -height 16
|
||||
|
||||
image create photo gitlogominus -width 4 -height 2
|
||||
gitlogominus put #C00000 -to 0 0 4 2
|
||||
gitlogo copy gitlogominus -to 1 5
|
||||
gitlogo copy gitlogominus -to 6 5
|
||||
gitlogo copy gitlogominus -to 11 5
|
||||
image delete gitlogominus
|
||||
image create photo gitlogominus -width 4 -height 2
|
||||
gitlogominus put #C00000 -to 0 0 4 2
|
||||
gitlogo copy gitlogominus -to 1 5
|
||||
gitlogo copy gitlogominus -to 6 5
|
||||
gitlogo copy gitlogominus -to 11 5
|
||||
image delete gitlogominus
|
||||
|
||||
image create photo gitlogoplus -width 4 -height 4
|
||||
gitlogoplus put #008000 -to 1 0 3 4
|
||||
gitlogoplus put #008000 -to 0 1 4 3
|
||||
gitlogo copy gitlogoplus -to 1 9
|
||||
gitlogo copy gitlogoplus -to 6 9
|
||||
gitlogo copy gitlogoplus -to 11 9
|
||||
image delete gitlogoplus
|
||||
image create photo gitlogoplus -width 4 -height 4
|
||||
gitlogoplus put #008000 -to 1 0 3 4
|
||||
gitlogoplus put #008000 -to 0 1 4 3
|
||||
gitlogo copy gitlogoplus -to 1 9
|
||||
gitlogo copy gitlogoplus -to 6 9
|
||||
gitlogo copy gitlogoplus -to 11 9
|
||||
image delete gitlogoplus
|
||||
|
||||
image create photo gitlogo32 -width 32 -height 32
|
||||
gitlogo32 copy gitlogo -zoom 2 2
|
||||
image create photo gitlogo32 -width 32 -height 32
|
||||
gitlogo32 copy gitlogo -zoom 2 2
|
||||
|
||||
wm iconphoto . -default gitlogo gitlogo32
|
||||
wm iconphoto . -default gitlogo gitlogo32
|
||||
}
|
||||
}
|
||||
# wait for the window to become visible
|
||||
tkwait visibility .
|
||||
|
|
Загрузка…
Ссылка в новой задаче