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 <l.stelmach@samsung.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
5ab72271e1
commit
331450f18a
@ -25,6 +25,8 @@ You are currently in the middle of a merge that has not been fully completed. Y
|
|||||||
set msg {}
|
set msg {}
|
||||||
set parents [list]
|
set parents [list]
|
||||||
if {[catch {
|
if {[catch {
|
||||||
|
set name ""
|
||||||
|
set email ""
|
||||||
set fd [git_read cat-file commit $curHEAD]
|
set fd [git_read cat-file commit $curHEAD]
|
||||||
fconfigure $fd -encoding binary -translation lf
|
fconfigure $fd -encoding binary -translation lf
|
||||||
# By default commits are assumed to be in utf-8
|
# By default commits are assumed to be in utf-8
|
||||||
@ -34,9 +36,7 @@ You are currently in the middle of a merge that has not been fully completed. Y
|
|||||||
lappend parents [string range $line 7 end]
|
lappend parents [string range $line 7 end]
|
||||||
} elseif {[string match {encoding *} $line]} {
|
} elseif {[string match {encoding *} $line]} {
|
||||||
set enc [string tolower [string range $line 9 end]]
|
set enc [string tolower [string range $line 9 end]]
|
||||||
} elseif {[regexp "author (.*)\\s<(.*)>\\s(\\d.*$)" $line all name email time]} {
|
} elseif {[regexp "author (.*)\\s<(.*)>\\s(\\d.*$)" $line all name email time]} { }
|
||||||
set commit_author [list name $name email $email date $time]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
set msg [read $fd]
|
set msg [read $fd]
|
||||||
close $fd
|
close $fd
|
||||||
@ -44,7 +44,13 @@ You are currently in the middle of a merge that has not been fully completed. Y
|
|||||||
set enc [tcl_encoding $enc]
|
set enc [tcl_encoding $enc]
|
||||||
if {$enc ne {}} {
|
if {$enc ne {}} {
|
||||||
set msg [encoding convertfrom $enc $msg]
|
set msg [encoding convertfrom $enc $msg]
|
||||||
|
set name [encoding convertfrom $enc $name]
|
||||||
|
set email [encoding convertfrom $enc $email]
|
||||||
}
|
}
|
||||||
|
if {$name ne {} && $email ne {}} {
|
||||||
|
set commit_author [list name $name email $email date $time]
|
||||||
|
}
|
||||||
|
|
||||||
set msg [string trim $msg]
|
set msg [string trim $msg]
|
||||||
} err]} {
|
} err]} {
|
||||||
error_popup [strcat [mc "Error loading commit data for amend:"] "\n\n$err"]
|
error_popup [strcat [mc "Error loading commit data for amend:"] "\n\n$err"]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user