Skip to contentSkip to conversation

gitk: fix the context menu not appearing in the presence of submodule diffs

PATCH Applied Роман Донченко 2 participants 3 messages Dec 15, 2019 – Apr 29, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gitk: fix the context menu not appearing in the presence of submodule diffs

Currently, submodule diffs can cause the diff context menu to fail to appear because of a couple bugs in parseblobdiffline:

* it appends the submodule name to ctext_file_lines instead of a line number, which breaks the binary search in find_ctext_fileinfo;

* it can desynchronize ctext_file_names and ctext_file_lines by appending to the former but not the latter, which also breaks find_ctext_fileinfo.

Fix both of these.

Note: a side effect of this patch is that the context menu also starts appearing when you right-click on submodule diffs (and not just regular diffs). The menu is non-functional in this case, though, since you can't run blame on submodules.

---
 gitk | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
gitk +3 -3
index da84e22..2a9bd45 100755
@@ -8224,10 +8224,10 @@ proc parseblobdiffline {ids line} {
 	if {$currdiffsubmod != $fname} {
 	    $ctext insert end "\n";     # Add newline after commit message
 	}
-	set curdiffstart [$ctext index "end - 1c"]
-	lappend ctext_file_names ""
 	if {$currdiffsubmod != $fname} {
-	    lappend ctext_file_lines $fname
+	    set curdiffstart [$ctext index "end - 1c"]
+	    lappend ctext_file_names ""
+	    lappend ctext_file_lines [lindex [split $curdiffstart "."] 0]
 	    makediffhdr $fname $ids
 	    set currdiffsubmod $fname
 	    $ctext insert end "\n$line\n" filesep
Signature · 1 line
2.24.1.windows.2
#1 lore raw
Quoted 10 lines · Роман Донченко

Currently, submodule diffs can cause the diff context menu to fail to appear because of a couple bugs in parseblobdiffline:

* it appends the submodule name to ctext_file_lines instead of a line number, which breaks the binary search in find_ctext_fileinfo;

* it can desynchronize ctext_file_names and ctext_file_lines by appending to the former but not the latter, which also breaks find_ctext_fileinfo.

Quoted 8 lines

Fix both of these.

Note: a side effect of this patch is that the context menu also starts appearing when you right-click on submodule diffs (and not just regular diffs). The menu is non-functional in this case, though, since you can't run blame on submodules.

Thanks, applied.

Paul.

#2 lore raw

Hi,

I just checked the repository, and it doesn't seem like it's actually applied...

-Roman.

13.04.2020 8:11, Paul Mackerras пишет:

Quoted 24 lines · Роман Донченко
Quoted 10 lines

Currently, submodule diffs can cause the diff context menu to fail to appear because of a couple bugs in parseblobdiffline:

* it appends the submodule name to ctext_file_lines instead of a line number, which breaks the binary search in find_ctext_fileinfo;

* it can desynchronize ctext_file_names and ctext_file_lines by appending to the former but not the latter, which also breaks find_ctext_fileinfo.

Quoted 8 lines

Fix both of these.

Note: a side effect of this patch is that the context menu also starts appearing when you right-click on submodule diffs (and not just regular diffs). The menu is non-functional in this case, though, since you can't run blame on submodules.

Thanks, applied.

Paul.