From: Aniket Gupta Date: Sat, 21 Nov 2026 10:42:33 GMT Subject: [PATCH 1/2] combine-diff: fix the shift for the 33rd parent and later Message-ID: <20261121104234.98386-2-aniketgupta3001@gmail.com> In-Reply-To: <20261121104234.98386-1-aniketgupta3001@gmail.com> coalesce_lines() records which parents lost a line by setting a bit in the parent_map of that line. The bit is computed with 1< Signed-off-by: Aniket Gupta --- combine-diff.c | 2 +- t/t4038-diff-combined.sh | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/combine-diff.c b/combine-diff.c index 717d537688..54d0aed6b2 100644 --- a/combine-diff.c +++ b/combine-diff.c @@ -246,7 +246,7 @@ static struct lline *coalesce_lines(struct lline *base, int *lenbase, j--; while (i != 0 || j != 0) { if (directions[i][j] == MATCH) { - baseend->parent_map |= 1<parent_map |= 1UL << parent; baseend = baseend->prev; newend = newend->prev; i--; diff --git a/t/t4038-diff-combined.sh b/t/t4038-diff-combined.sh index e11b711388..fcf7333d7b 100755 --- a/t/t4038-diff-combined.sh +++ b/t/t4038-diff-combined.sh @@ -127,6 +127,30 @@ test_expect_success 'check --cc --raw with forty trees' ' test_grep "^::::::::::::::::::::::::::::::::::::::::[^:]" out ' +test_expect_success LONG_IS_64BIT 'check --cc with forty parents, two losing the same line' ' + blob=$(echo file | git hash-object --stdin -w) && + result_tree=$(echo "100644 blob $blob file" | git mktree) && + parent_trees= && + for i in $(test_seq 1 40) + do + case $i in + 2 | 40) + extra=common + ;; + *) + extra= + ;; + esac && + blob=$(test_write_lines $extra file file$i | git hash-object --stdin -w) && + parent_trees="$parent_trees$(echo "100644 blob $blob file" | git mktree)$LF" || return 1 + done && + git diff --cc $result_tree $parent_trees >out && + # Check that the second and the fortieth column mark the line: + printf " -%37s-common\n" "" >expect && + grep common out >actual && + test_cmp expect actual +' + test_expect_success 'setup combined ignore spaces' ' git checkout main && >test && -- 2.54.0 (Apple Git-157)