Skip to content

Commit 20f1a10

Browse files
committed
git-gui: Work around bad interaction between Tcl and cmd.exe on ^{tree}
From Johannes Sixt <[email protected]>: > It seems that MSYS's wish does some quoting for Bourne shells, > in particular, escape the first '{' of the "^{tree}" suffix, but > then it uses cmd.exe to run "git rev-parse". However, cmd.exe does > not remove the backslash, so that the resulting rev expression > ends up in git's guts as unrecognizable garbage: rev-parse fails, > and git-gui hickups in a way that it must be restarted. Johannes originally submitted a patch to this section of commit.tcl to use `git rev-parse $PARENT:`, but not all versions of Git will accept that format. So I'm just taking the really simple approach here of scanning the first line of the commit to grab its tree. About the same cost, but works everywhere. Signed-off-by: Shawn O. Pearce <[email protected]>
1 parent e87fb0f commit 20f1a10

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

lib/commit.tcl

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,18 @@ proc commit_committree {fd_wt curHEAD msg} {
260260
# -- Verify this wasn't an empty change.
261261
#
262262
if {$commit_type eq {normal}} {
263-
set old_tree [git rev-parse "$PARENT^{tree}"]
263+
set fd_ot [open "| git cat-file commit $PARENT" r]
264+
fconfigure $fd_ot -encoding binary -translation lf
265+
set old_tree [gets $fd_ot]
266+
close $fd_ot
267+
268+
if {[string equal -length 5 {tree } $old_tree]
269+
&& [string length $old_tree] == 45} {
270+
set old_tree [string range $old_tree 5 end]
271+
} else {
272+
error "Commit $PARENT appears to be corrupt"
273+
}
274+
264275
if {$tree_id eq $old_tree} {
265276
info_popup {No changes to commit.
266277

0 commit comments

Comments
 (0)