Thread View: linux.kernel.git
3 messages
3 total messages
Started by Sami Jawhar
Tue, 17 Nov 2026 06:32
[BUG] combine-diff: wrong deletion columns at 33 parents, no hunks at 64
Author: Sami Jawhar
Date: Tue, 17 Nov 2026 06:32
Date: Tue, 17 Nov 2026 06:32
122 lines
15296 bytes
15296 bytes
What did you do before the bug happened? (Steps to reproduce your issue)
I ran git diff-tree --cc -U0 on octopus merges with 32, 33, 63 and 64
parents. Save this script as repro.sh:
#!/bin/sh
# usage: repro.sh N
set -eu
n=$1
lines=$((10 * n + 20))
dir=octopus-$n
rm -rf "$dir"
git init -q "$dir"
cd "$dir"
export GIT_AUTHOR_NAME=t GIT_AUTHOR_EMAIL=t@example.com
export GIT_COMMITTER_NAME=t GIT_COMMITTER_EMAIL=t@example.com
file() { # FIRST_LINE SIDE...: "side <i>" goes after line 10*i+10
first=$1; shift
echo "$first"
k=2
while [ "$k" -le "$lines" ]; do
echo "line $k"
for side in "$@"; do
[ "$k" -eq $((10 * side + 10)) ] && echo "side $side"
done
k=$((k + 1))
done
}
commit() { # MESSAGE PARENT... < content
blob=$(git hash-object -w --stdin)
tree=$(printf '100644 blob %s\tf.txt\n' "$blob" | git mktree)
message=$1; shift
for parent in "$@"; do set -- "$@" -p "$parent"; shift; done
git commit-tree "$tree" "$@" -m "$message"
}
base=$(file "line 1" | commit base)
parents= all=
i=0
while [ "$i" -lt "$n" ]; do
first="line 1"
{ [ "$i" -eq 1 ] || [ "$i" -eq $((n - 1)) ]; } && first="removed line"
parents="$parents $(file "$first" "$i" | commit "side $i" "$base")"
all="$all $i"
i=$((i + 1))
done
merge=$({ file "line 1" $all; echo "merge-only line"; } | commit
octopus $parents)
echo "merge of $n parents"
echo "lines showing \"merge-only line\":" \
"$(git diff-tree --cc -U0 "$merge" | grep -c 'merge-only line')"
git diff-tree --cc -U0 "$merge" | awk -v n="$n" '
function check() {
if (!open) return
for (p = 1; p <= n; p++) if (got[p] != want[p]) {
printf "hunk %s: parent %d: header says %d line(s),
body shows %d\n",
header, p, want[p], got[p]; bad++ }
}
/^@@@/ { check(); open = 1; header = $(n + 2); split($0, f, " ")
for (p = 1; p <= n; p++) {
split(substr(f[p + 1], 2), r, ",")
want[p] = (r[2] == "" ? 1 : r[2]); got[p] = 0 }
next }
open { m = substr($0, 1, n); lost = index(m, "-") > 0
for (p = 1; p <= n; p++) {
c = substr(m, p, 1)
if (c == "-" || (!lost && c == " ")) got[p]++ } }
END { check(); if (!bad) print "every hunk agrees with its header" }'
From an empty directory, run:
for n in 32 33 63 64; do
sh repro.sh "$n"
done
What did you expect to happen? (Expected behavior)
Each hunk body should agree with its header, and "merge-only line"
should appear in the diff.
What happened instead? (Actual behavior)
Git 2.43.0 and master at e1ec09b23c8e print identical output:
merge of 32 parents
lines showing "merge-only line": 1
every hunk agrees with its header
merge of 33 parents
lines showing "merge-only line": 1
hunk +1,1: parent 1: header says 1 line(s), body shows 2
merge of 63 parents
lines showing "merge-only line": 1
hunk +1,1: parent 31: header says 1 line(s), body shows 2
merge of 64 parents
lines showing "merge-only line": 0
every hunk agrees with its header
At 64 parents the diff has no hunks, so the script's final "every hunk"
message does not indicate success.
What's different between what you expected and what actually happened?
At 33 parents, "removed line" is present in parents 2 and 33, but the
diff marks its deletion in columns 1 and 2. At 63 parents, the line is
present in parents 2 and 63, but the diff marks columns 2 and 31.
In e1ec09b23c8e, coalesce_lines() at combine-diff.c:249 has:
baseend->parent_map |= 1<<parent;
parent_map is unsigned long, but 1<<parent shifts an int.
give_context():544-545, make_hunks():610-611 and dump_sline():756 also
use 1UL<<num_parent. At 64 parents, this shifts by 64, the width of
unsigned long in both builds.
[System Info]
Ubuntu 24.04.5 LTS, Linux x86_64, sizeof-long: 8
git version 2.43.0
git version 2.56.GIT
built from commit: e1ec09b23c8e0deb21a0b95ac5996422277395d4
Re: [BUG] combine-diff: wrong deletion columns at 33 parents, no hunks at 64
Author: Aniket Gupta
Date: Fri, 20 Nov 2026 16:50
Date: Fri, 20 Nov 2026 16:50
9 lines
10806 bytes
10806 bytes
Hi Sami, > parent_map is unsigned long, but 1<<parent shifts an int. Thanks for this report and the reproducer. It seems nobody has picked this. Can I send a patch to fix the shift and to handle merges with too many parents? Thanks, Aniket
Re: [BUG] combine-diff: wrong deletion columns at 33 parents, no hunks at 64
Author: Sami Jawhar
Date: Sat, 21 Nov 2026 01:03
Date: Sat, 21 Nov 2026 01:03
4 lines
11795 bytes
11795 bytes
> Can I send a patch to fix the shift and to handle merges with too many parents? Yes, please do.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads