Skip to content

Commit 331450f

Browse files
Łukasz Stelmachgitster
authored andcommitted
git-gui: prevent double UTF-8 conversion
Convert author's name and e-mail address from the UTF-8 (or any other) encoding in load_last_commit function the same way commit message is converted. Amending commits in git-gui without such conversion breaks UTF-8 strings. For example, "\305\201ukasz" (as written by git cat-file) becomes "\303\205\302\201ukasz" in an amended commit. Signed-off-by: Łukasz Stelmach <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5ab7227 commit 331450f

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lib/commit.tcl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ You are currently in the middle of a merge that has not been fully completed. Y
2525
set msg {}
2626
set parents [list]
2727
if {[catch {
28+
set name ""
29+
set email ""
2830
set fd [git_read cat-file commit $curHEAD]
2931
fconfigure $fd -encoding binary -translation lf
3032
# By default commits are assumed to be in utf-8
@@ -34,17 +36,21 @@ You are currently in the middle of a merge that has not been fully completed. Y
3436
lappend parents [string range $line 7 end]
3537
} elseif {[string match {encoding *} $line]} {
3638
set enc [string tolower [string range $line 9 end]]
37-
} elseif {[regexp "author (.*)\\s<(.*)>\\s(\\d.*$)" $line all name email time]} {
38-
set commit_author [list name $name email $email date $time]
39-
}
39+
} elseif {[regexp "author (.*)\\s<(.*)>\\s(\\d.*$)" $line all name email time]} { }
4040
}
4141
set msg [read $fd]
4242
close $fd
4343

4444
set enc [tcl_encoding $enc]
4545
if {$enc ne {}} {
4646
set msg [encoding convertfrom $enc $msg]
47+
set name [encoding convertfrom $enc $name]
48+
set email [encoding convertfrom $enc $email]
4749
}
50+
if {$name ne {} && $email ne {}} {
51+
set commit_author [list name $name email $email date $time]
52+
}
53+
4854
set msg [string trim $msg]
4955
} err]} {
5056
error_popup [strcat [mc "Error loading commit data for amend:"] "\n\n$err"]

0 commit comments

Comments
 (0)