Commit 7cb5f7c
committed
blame: fix object casting regression
Commit 1b0d400 refactored the prepare_final() function so
that it could be reused in multiple places. Originally, the
loop had two outputs: a commit to stuff into sb->final, and
the name of the commit from the rev->pending array.
After the refactor, that loop is put in its own function
with a single return value: the object_array_entry from the
rev->pending array. This contains both the name and the object,
but with one important difference: the object is the
_original_ object found by the revision parser, not the
dereferenced commit. If one feeds a tag to "git blame", we
end up casting the tag object to a "struct commit", which
causes a segfault.
Instead, let's return the commit (properly casted) directly
from the function, and take the "name" as an optional
out-parameter. This does the right thing, and actually
simplifies the callers, who no longer need to cast or
dereference the object_array_entry themselves.
[test case by Max Kirillov <max@max630.net>]
Signed-off-by: Jeff King <peff@peff.net>1 parent 700fd28 commit 7cb5f7c
2 files changed
+21
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2396 | 2396 | | |
2397 | 2397 | | |
2398 | 2398 | | |
2399 | | - | |
| 2399 | + | |
| 2400 | + | |
2400 | 2401 | | |
2401 | 2402 | | |
2402 | | - | |
| 2403 | + | |
| 2404 | + | |
2403 | 2405 | | |
2404 | 2406 | | |
2405 | 2407 | | |
| |||
2411 | 2413 | | |
2412 | 2414 | | |
2413 | 2415 | | |
2414 | | - | |
2415 | | - | |
2416 | | - | |
| 2416 | + | |
| 2417 | + | |
| 2418 | + | |
2417 | 2419 | | |
| 2420 | + | |
| 2421 | + | |
2418 | 2422 | | |
2419 | 2423 | | |
2420 | 2424 | | |
2421 | 2425 | | |
2422 | 2426 | | |
2423 | | - | |
2424 | | - | |
2425 | | - | |
2426 | | - | |
2427 | | - | |
2428 | | - | |
2429 | | - | |
| 2427 | + | |
| 2428 | + | |
| 2429 | + | |
2430 | 2430 | | |
2431 | 2431 | | |
2432 | 2432 | | |
| |||
2712 | 2712 | | |
2713 | 2713 | | |
2714 | 2714 | | |
2715 | | - | |
2716 | | - | |
| 2715 | + | |
| 2716 | + | |
2717 | 2717 | | |
2718 | | - | |
2719 | | - | |
2720 | 2718 | | |
2721 | 2719 | | |
2722 | 2720 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
71 | 78 | | |
72 | 79 | | |
73 | 80 | | |
| |||
0 commit comments