Skip to content

Commit 8255167

Browse files
j6tttaylorr
authored andcommitted
git-gui: remove git config --list handling for git < 1.5.3
git-gui uses `git config --null --list` to parse configuration. Git versions prior to 1.5.3 do not have --null and need different treatment. Nobody should be using such an old version anymore. (Moreover, since 0730a5a, git-gui requires git v2.36 or later). Keep only the code for modern Git. Signed-off-by: Johannes Sixt <[email protected]> Signed-off-by: Taylor Blau <[email protected]>
1 parent f9a2e8a commit 8255167

File tree

1 file changed

+23
-46
lines changed

1 file changed

+23
-46
lines changed

git-gui.sh

Lines changed: 23 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,53 +1083,30 @@ unset -nocomplain idx fd
10831083
##
10841084
## config file parsing
10851085

1086-
git-version proc _parse_config {arr_name args} {
1087-
>= 1.5.3 {
1088-
upvar $arr_name arr
1089-
array unset arr
1090-
set buf {}
1091-
catch {
1092-
set fd_rc [eval \
1093-
[list git_read config] \
1094-
$args \
1095-
[list --null --list]]
1096-
fconfigure $fd_rc -translation binary -encoding utf-8
1097-
set buf [read $fd_rc]
1098-
close $fd_rc
1099-
}
1100-
foreach line [split $buf "\0"] {
1101-
if {[regexp {^([^\n]+)\n(.*)$} $line line name value]} {
1102-
if {[is_many_config $name]} {
1103-
lappend arr($name) $value
1104-
} else {
1105-
set arr($name) $value
1106-
}
1107-
} elseif {[regexp {^([^\n]+)$} $line line name]} {
1108-
# no value given, but interpreting them as
1109-
# boolean will be handled as true
1110-
set arr($name) {}
1111-
}
1112-
}
1113-
}
1114-
default {
1115-
upvar $arr_name arr
1116-
array unset arr
1117-
catch {
1118-
set fd_rc [eval [list git_read config --list] $args]
1119-
while {[gets $fd_rc line] >= 0} {
1120-
if {[regexp {^([^=]+)=(.*)$} $line line name value]} {
1121-
if {[is_many_config $name]} {
1122-
lappend arr($name) $value
1123-
} else {
1124-
set arr($name) $value
1125-
}
1126-
} elseif {[regexp {^([^=]+)$} $line line name]} {
1127-
# no value given, but interpreting them as
1128-
# boolean will be handled as true
1129-
set arr($name) {}
1130-
}
1086+
proc _parse_config {arr_name args} {
1087+
upvar $arr_name arr
1088+
array unset arr
1089+
set buf {}
1090+
catch {
1091+
set fd_rc [eval \
1092+
[list git_read config] \
1093+
$args \
1094+
[list --null --list]]
1095+
fconfigure $fd_rc -translation binary -encoding utf-8
1096+
set buf [read $fd_rc]
1097+
close $fd_rc
1098+
}
1099+
foreach line [split $buf "\0"] {
1100+
if {[regexp {^([^\n]+)\n(.*)$} $line line name value]} {
1101+
if {[is_many_config $name]} {
1102+
lappend arr($name) $value
1103+
} else {
1104+
set arr($name) $value
11311105
}
1132-
close $fd_rc
1106+
} elseif {[regexp {^([^\n]+)$} $line line name]} {
1107+
# no value given, but interpreting them as
1108+
# boolean will be handled as true
1109+
set arr($name) {}
11331110
}
11341111
}
11351112
}

0 commit comments

Comments
 (0)