DORMANTno replies

[PATCH] gitk - fix a problem with multiline author names

From: Tomo Krajina <hidden>
Date: 2016-06-15 22:55:16
Subsystem: the rest · Maintainer: Linus Torvalds

When commiting with "git-commit" no newline in the author string
is possible. But other git clients don't have the same validations
for the author name. And, it is possible to have a commit like:

commit xxxxxxxx
Merge: aaaaa bbbbb
Author: User Name
 [off-list ref]
Date:   Thu Nov 8 17:01:02 2012 +0100

    Merge branch 'master' of ...

Note that the "Author:" string is split in two lines.

The git-log command work without problems with a commit like this, but
in gitk there is a problem because it splits the headers by a newline
character and that's why the email and time is not correctly parsed
and the history tree below this commit is not shown.

Signed-off-by: Tomo Krajina <redacted>
---
 gitk-git/gitk |   16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/gitk-git/gitk b/gitk-git/gitk
index 6f24f53..87300db 100755
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -1672,13 +1672,15 @@ proc parsecommit {id contents listed} {
     foreach line [split $header "\n"] {
  set line [split $line " "]
  set tag [lindex $line 0]
- if {$tag == "author"} {
-    set audate [lrange $line end-1 end]
-    set auname [join [lrange $line 1 end-2] " "]
- } elseif {$tag == "committer"} {
-    set comdate [lrange $line end-1 end]
-    set comname [join [lrange $line 1 end-2] " "]
- }
+        if {$tag == "author"} {
+            regexp -lineanchor {\nauthor([^<]*)<([^>]*)>\s+([^\n]+)}
$header all auname email audate
+            set auname [string trim $auname]
+            set auname "$auname <$email>"
+        } elseif {$tag == "committer"} {
+            regexp -lineanchor
{\ncommitter([^<]*)<([^>]*)>\s+([^\n]+)} $header all comname email
comdate
+            set comname [string trim $comname]
+            set comname "$comname <$email>"
+        }
     }
     set headline {}
     # take the first non-blank line of the comment as the headline
--
1.7.9.5
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help