@@ -79,10 +79,8 @@ proc is_Cygwin {} {
79
79
80
80
if {[is_Windows]} {
81
81
set _path_sep {;}
82
- set _search_exe .exe
83
82
} else {
84
83
set _path_sep {:}
85
- set _search_exe {}
86
84
}
87
85
88
86
if {[is_Windows]} {
@@ -112,15 +110,15 @@ set env(PATH) [join $_search_path $_path_sep]
112
110
113
111
if {[ is_Windows] } {
114
112
proc _which {what args} {
115
- global _search_exe _search_path
113
+ global _search_path
116
114
117
115
if {[ lsearch -exact $args -script] >= 0} {
118
116
set suffix {}
119
- } elseif {[ string match *$_search_exe [string tolower $what ] ]} {
117
+ } elseif {[ string match *.exe [string tolower $what ] ]} {
120
118
# The search string already has the file extension
121
119
set suffix {}
122
120
} else {
123
- set suffix $_search_exe
121
+ set suffix .exe
124
122
}
125
123
126
124
foreach p $_search_path {
@@ -363,7 +361,6 @@ set _appname {Git Gui}
363
361
set _gitdir {}
364
362
set _gitworktree {}
365
363
set _isbare {}
366
- set _gitexec {}
367
364
set _githtmldir {}
368
365
set _reponame {}
369
366
set _shellpath {@@SHELL_PATH@@}
@@ -428,20 +425,6 @@ proc gitdir {args} {
428
425
return [ eval [list file join $_gitdir ] $args ]
429
426
}
430
427
431
- proc gitexec {args} {
432
- global _gitexec
433
- if {$_gitexec eq {}} {
434
- if {[ catch {set _gitexec [git --exec-path] } err]} {
435
- error " Git not installed?\n\n $err "
436
- }
437
- set _gitexec [ file normalize $_gitexec ]
438
- }
439
- if {$args eq {}} {
440
- return $_gitexec
441
- }
442
- return [ eval [list file join $_gitexec ] $args ]
443
- }
444
-
445
428
proc githtmldir {args} {
446
429
global _githtmldir
447
430
if {$_githtmldir eq {}} {
@@ -574,56 +557,6 @@ proc _trace_exec {cmd} {
574
557
575
558
#'" fix poor old emacs font-lock mode
576
559
577
- proc _git_cmd {name} {
578
- global _git_cmd_path
579
-
580
- if {[catch {set v $_git_cmd_path($name) }]} {
581
- switch -- $name {
582
- version -
583
- --version -
584
- --exec-path { return [list $::_git $name ] }
585
- }
586
-
587
- set p [gitexec git-$name$::_search_exe ]
588
- if {[file exists $p ]} {
589
- set v [list $p ]
590
- } elseif {[is_Windows] && [file exists [gitexec git-$name ]]} {
591
- # Try to determine what sort of magic will make
592
- # git-$name go and do its thing, because native
593
- # Tcl on Windows doesn't know it.
594
- #
595
- set p [gitexec git-$name ]
596
- set f [safe_open_file $p r]
597
- set s [gets $f ]
598
- close $f
599
-
600
- switch -glob -- [lindex $s 0] {
601
- # !*sh { set i sh }
602
- # !*perl { set i perl }
603
- # !*python { set i python }
604
- default { error " git-$name is not supported: $s " }
605
- }
606
-
607
- upvar #0 _$i interp
608
- if {![info exists interp]} {
609
- set interp [_which $i ]
610
- }
611
- if {$interp eq {}} {
612
- error " git-$name requires $i (not in PATH)"
613
- }
614
- set v [concat [list $interp ] [lrange $s 1 end] [list $p ]]
615
- } else {
616
- # Assume it is builtin to git somehow and we
617
- # aren't actually able to see a file for it.
618
- #
619
- set v [list $::_git $name ]
620
- }
621
- set _git_cmd_path($name ) $v
622
- }
623
- return $v
624
- }
625
-
626
- # Run a shell command connected via pipes on stdout.
627
560
# This is for use with textconv filters and uses sh -c "..." to allow it to
628
561
# contain a command with arguments. We presume this
629
562
# to be a shellscript that the configured shell (/bin/sh by default) knows
@@ -679,30 +612,30 @@ proc safe_open_command {cmd {redir {}}} {
679
612
}
680
613
681
614
proc git_read {cmd {redir {}}} {
682
- set cmdp [_git_cmd [ lindex $cmd 0]]
683
- set cmd [ lrange $cmd 1 end ]
615
+ global _git
616
+ set cmdp [ concat [ list $_git ] $cmd ]
684
617
685
- return [safe_open_command [ concat $cmdp $cmd ] $redir ]
618
+ return [safe_open_command $cmdp $redir ]
686
619
}
687
620
688
621
proc git_read_nice {cmd} {
622
+ global _git
689
623
set opt [list ]
690
624
691
625
_lappend_nice opt
692
626
693
- set cmdp [_git_cmd [lindex $cmd 0]]
694
- set cmd [lrange $cmd 1 end]
627
+ set cmdp [concat [list $_git ] $cmd ]
695
628
696
- return [safe_open_command [concat $opt $cmdp $cmd ]]
629
+ return [safe_open_command [concat $opt $cmdp ]]
697
630
}
698
631
699
632
proc git_write {cmd} {
633
+ global _git
700
634
set cmd [make_arglist_safe $cmd ]
701
- set cmdp [_git_cmd [lindex $cmd 0]]
702
- set cmd [lrange $cmd 1 end]
635
+ set cmdp [concat [list $_git ] $cmd ]
703
636
704
- _trace_exec [ concat $cmdp $cmd ]
705
- return [open [concat [list | ] $cmdp $cmd ] w]
637
+ _trace_exec $cmdp
638
+ return [open [concat [list | ] $cmdp ] w]
706
639
}
707
640
708
641
proc githook_read {hook_name args} {
@@ -742,27 +675,8 @@ proc sq {value} {
742
675
proc load_current_branch {} {
743
676
global current_branch is_detached
744
677
745
- set fd [safe_open_file [gitdir HEAD] r]
746
- fconfigure $fd -translation binary -encoding utf-8
747
- if {[gets $fd ref] < 1} {
748
- set ref {}
749
- }
750
- close $fd
751
-
752
- set pfx {ref: refs/heads/}
753
- set len [string length $pfx ]
754
- if {[string equal -length $len $pfx $ref ]} {
755
- # We're on a branch. It might not exist. But
756
- # HEAD looks good enough to be a branch.
757
- #
758
- set current_branch [string range $ref $len end]
759
- set is_detached 0
760
- } else {
761
- # Assume this is a detached head.
762
- #
763
- set current_branch HEAD
764
- set is_detached 1
765
- }
678
+ set current_branch [git branch --show-current]
679
+ set is_detached [expr [string length $current_branch ] == 0]
766
680
}
767
681
768
682
auto_load tk_optionMenu
@@ -981,6 +895,8 @@ if {$_git eq {}} {
981
895
# #
982
896
# # version check
983
897
898
+ set MIN_GIT_VERSION 2.36
899
+
984
900
if {[catch {set _git_version [git --version]} err]} {
985
901
catch {wm withdraw .}
986
902
tk_messageBox \
@@ -991,9 +907,10 @@ if {[catch {set _git_version [git --version]} err]} {
991
907
992
908
$err
993
909
994
- [ appname] requires Git 1.5.0 or later."
910
+ [ appname] requires Git $MIN_GIT_VERSION or later."
995
911
exit 1
996
912
}
913
+
997
914
if {![regsub {^git version } $_git_version {} _git_version]} {
998
915
catch {wm withdraw .}
999
916
tk_messageBox \
@@ -1018,85 +935,21 @@ proc get_trimmed_version {s} {
1018
935
set _real_git_version $_git_version
1019
936
set _git_version [get_trimmed_version $_git_version ]
1020
937
1021
- if {![regexp {^[1-9]+(\.[0-9]+)+$} $_git_version ]} {
1022
- catch {wm withdraw .}
1023
- if {[tk_messageBox \
1024
- -icon warning \
1025
- -type yesno \
1026
- -default no \
1027
- -title " [ appname] : warning" \
1028
- -message [mc " Git version cannot be determined.
1029
-
1030
- %s claims it is version '%s'.
938
+ if {[catch {set vcheck [package vcompare $_git_version $MIN_GIT_VERSION ]}] ||
939
+ [expr $vcheck < 0] } {
1031
940
1032
- %s requires at least Git 1.5.0 or later.
1033
-
1034
- Assume '%s' is version 1.5.0?
1035
- " $_git $_real_git_version [appname] $_real_git_version ]] eq {yes}} {
1036
- set _git_version 1.5.0
1037
- } else {
1038
- exit 1
1039
- }
1040
- }
1041
- unset _real_git_version
1042
-
1043
- proc git-version {args} {
1044
- global _git_version
1045
-
1046
- switch [llength $args ] {
1047
- 0 {
1048
- return $_git_version
1049
- }
1050
-
1051
- 2 {
1052
- set op [lindex $args 0]
1053
- set vr [lindex $args 1]
1054
- set cm [package vcompare $_git_version $vr ]
1055
- return [expr $cm $op 0]
1056
- }
1057
-
1058
- 4 {
1059
- set type [lindex $args 0]
1060
- set name [lindex $args 1]
1061
- set parm [lindex $args 2]
1062
- set body [lindex $args 3]
1063
-
1064
- if {($type ne {proc } && $type ne {method})} {
1065
- error " Invalid arguments to git-version"
1066
- }
1067
- if {[llength $body ] < 2 || [lindex $body end-1] ne {default}} {
1068
- error " Last arm of $type $name must be default"
1069
- }
1070
-
1071
- foreach {op vr cb} [lrange $body 0 end-2] {
1072
- if {[git-version $op $vr ]} {
1073
- return [uplevel [list $type $name $parm $cb ]]
1074
- }
1075
- }
1076
-
1077
- return [uplevel [list $type $name $parm [lindex $body end]]]
1078
- }
1079
-
1080
- default {
1081
- error " git-version >= x"
1082
- }
1083
-
1084
- }
1085
- }
1086
-
1087
- if {[git-version < 1.5]} {
941
+ set msg1 [mc " Insufficient git version, require: " ]
942
+ set msg2 [mc " git returned:" ]
943
+ set message " $msg1 $MIN_GIT_VERSION \n $msg2 $_real_git_version "
1088
944
catch {wm withdraw .}
1089
945
tk_messageBox \
1090
946
-icon error \
1091
947
-type ok \
1092
948
-title [mc " git-gui: fatal error" ] \
1093
- -message " [ appname] requires Git 1.5.0 or later.
1094
-
1095
- You are using [ git-version] :
1096
-
1097
- [ git --version] "
949
+ -message $message
1098
950
exit 1
1099
951
}
952
+ unset _real_git_version
1100
953
1101
954
# #####################################################################
1102
955
# #
@@ -1261,7 +1114,7 @@ citool {
1261
1114
1262
1115
# Suggest our implementation of askpass, if none is set
1263
1116
if {![info exists env(SSH_ASKPASS)]} {
1264
- set env(SSH_ASKPASS) [gitexec git-gui--askpass]
1117
+ set env(SSH_ASKPASS) [file join [git --exec-path] git-gui--askpass]
1265
1118
}
1266
1119
1267
1120
# #####################################################################
@@ -1282,6 +1135,9 @@ if {[catch {
1282
1135
load_config 1
1283
1136
apply_config
1284
1137
choose_repository::pick
1138
+ if {![file isdirectory $_gitdir ]} {
1139
+ exit 1
1140
+ }
1285
1141
set picked 1
1286
1142
}
1287
1143
@@ -1312,20 +1168,7 @@ if {![file isdirectory $_gitdir]} {
1312
1168
load_config 0
1313
1169
apply_config
1314
1170
1315
- # v1.7.0 introduced --show-toplevel to return the canonical work-tree
1316
- if {[package vcompare $_git_version 1.7.0] >= 0} {
1317
- set _gitworktree [git rev-parse --show-toplevel]
1318
- } else {
1319
- # try to set work tree from environment, core.worktree or use
1320
- # cdup to obtain a relative path to the top of the worktree. If
1321
- # run from the top, the ./ prefix ensures normalize expands pwd.
1322
- if {[catch { set _gitworktree $env(GIT_WORK_TREE) }]} {
1323
- set _gitworktree [get_config core.worktree]
1324
- if {$_gitworktree eq " " } {
1325
- set _gitworktree [file normalize ./[git rev-parse --show-cdup]]
1326
- }
1327
- }
1328
- }
1171
+ set _gitworktree [git rev-parse --show-toplevel]
1329
1172
1330
1173
if {$_prefix ne {}} {
1331
1174
if {$_gitworktree eq {}} {
@@ -1551,30 +1394,15 @@ proc rescan_stage2 {fd after} {
1551
1394
close $fd
1552
1395
}
1553
1396
1554
- if {[package vcompare $::_git_version 1.6.3] >= 0} {
1555
- set ls_others [list --exclude-standard]
1556
- } else {
1557
- set ls_others [list --exclude-per-directory=.gitignore]
1558
- if {[have_info_exclude]} {
1559
- lappend ls_others " --exclude-from=[ gitdir info exclude] "
1560
- }
1561
- set user_exclude [get_config core.excludesfile]
1562
- if {$user_exclude ne {} && [file readable $user_exclude ]} {
1563
- lappend ls_others " --exclude-from=[ file normalize $user_exclude ] "
1564
- }
1565
- }
1397
+ set ls_others [list --exclude-standard]
1566
1398
1567
1399
set buf_rdi {}
1568
1400
set buf_rdf {}
1569
1401
set buf_rlo {}
1570
1402
1571
1403
set rescan_active 2
1572
1404
ui_status [mc " Scanning for modified files ..." ]
1573
- if {[git-version >= " 1.7.2" ]} {
1574
- set fd_di [git_read [list diff-index --cached --ignore-submodules=dirty -z [PARENT]]]
1575
- } else {
1576
- set fd_di [git_read [list diff-index --cached -z [PARENT]]]
1577
- }
1405
+ set fd_di [git_read [list diff-index --cached --ignore-submodules=dirty -z [PARENT]]]
1578
1406
set fd_df [git_read [list diff-files -z]]
1579
1407
1580
1408
fconfigure $fd_di -blocking 0 -translation binary -encoding binary
0 commit comments