{"thread":{"id":"52172","subject":"[PATCH] gitk: don't highlight files after submodules as submodules","startedAt":"2019-11-01T23:41:26Z","lastAt":"2019-12-15T05:33:30Z","messageCount":2,"participants":["Роман Донченко","Paul Mackerras"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"385283","messageId":"20191101233427.4108-1-dpb@corrigendum.ru","threadId":"52172","inReplyTo":null,"subject":"[PATCH] gitk: don't highlight files after submodules as submodules","fromName":"Роман Донченко","fromEmail":"dpb@corrigendum.ru","sentAt":"2019-11-01T23:34:27Z","receivedAt":"2019-11-01T23:41:26Z","isPatch":true,"sender":{"key":"dpb@corrigendum.ru","avatar":"https://avatars.githubusercontent.com/u/2391761?v=4"},"body":"gitk applies submodule highlighting (coloring lines starting with\n\"  >\" and \"  <\") when `currdiffsubmod` is not an empty string.\nHowever, it fails to reset `currdiffsubmod` after a submodule diff\nends, so any file diffs following a submodule diff will still be\nhighlighted as if they were submodule diffs.\n\nThere are two problems with the way gitk tries to reset `currdiffsubmod`:\n\n1. The code says `set $currdiffsubmod` instead of `set currdiffsubmod`,\n   so it actually sets the variable whose name is the submodule path\n   instead.\n\n2. It tries to do it after the first line in a submodule diff, which\n   is incorrect, since submodule diffs can contain multiple lines.\n\nFix this by resetting `currdiffsubmod` when a file diff starts.\n\nSigned-off-by: Роман Донченко <dpb@corrigendum.ru>\n---\n gitk | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/gitk b/gitk\nindex abe4805..7c425d2 100755\n--- a/gitk\n+++ b/gitk\n@@ -8146,6 +8146,8 @@ proc parseblobdiffline {ids line} {\n \t}\n \t# start of a new file\n \tset diffinhdr 1\n+\tset currdiffsubmod \"\"\n+\n \t$ctext insert end \"\\n\"\n \tset curdiffstart [$ctext index \"end - 1c\"]\n \tlappend ctext_file_names \"\"\n@@ -8229,11 +8231,9 @@ proc parseblobdiffline {ids line} {\n \t    $ctext insert end \"$line\\n\" filesep\n \t}\n     } elseif {$currdiffsubmod != \"\" && ![string compare -length 3 \"  >\" $line]} {\n-\tset $currdiffsubmod \"\"\n \tset line [encoding convertfrom $diffencoding $line]\n \t$ctext insert end \"$line\\n\" dresult\n     } elseif {$currdiffsubmod != \"\" && ![string compare -length 3 \"  <\" $line]} {\n-\tset $currdiffsubmod \"\"\n \tset line [encoding convertfrom $diffencoding $line]\n \t$ctext insert end \"$line\\n\" d0\n     } elseif {$diffinhdr} {\n-- \n2.19.1.windows.1\n\n"},{"id":"388221","messageId":"20191215043926.GE12512@blackberry","threadId":"52172","inReplyTo":"20191101233427.4108-1-dpb@corrigendum.ru","subject":"Re: [PATCH] gitk: don't highlight files after submodules as submodules","fromName":"Paul Mackerras","fromEmail":"paulus@ozlabs.org","sentAt":"2019-12-15T04:39:26Z","receivedAt":"2019-12-15T05:33:30Z","isPatch":true,"sender":{"key":"paulus@ozlabs.org","avatar":"https://avatars.githubusercontent.com/u/1606439?v=4"},"body":"On Sat, Nov 02, 2019 at 02:34:27AM +0300, Роман Донченко wrote:\n> gitk applies submodule highlighting (coloring lines starting with\n> \"  >\" and \"  <\") when `currdiffsubmod` is not an empty string.\n> However, it fails to reset `currdiffsubmod` after a submodule diff\n> ends, so any file diffs following a submodule diff will still be\n> highlighted as if they were submodule diffs.\n> \n> There are two problems with the way gitk tries to reset `currdiffsubmod`:\n> \n> 1. The code says `set $currdiffsubmod` instead of `set currdiffsubmod`,\n>    so it actually sets the variable whose name is the submodule path\n>    instead.\n> \n> 2. It tries to do it after the first line in a submodule diff, which\n>    is incorrect, since submodule diffs can contain multiple lines.\n> \n> Fix this by resetting `currdiffsubmod` when a file diff starts.\n> \n> Signed-off-by: Роман Донченко <dpb@corrigendum.ru>\n\nThanks, patch applied.\n\nPaul.\n"}]}