git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[BUG] combine-diff: wrong deletion columns at 33 parents, no hunks at 64

From
SJSami Jawhar <sami@theorem.dev>
Date
Nov 17, 2026, 06:32 UTC
Message-ID
<CAOJ8FdczW9KxFknceHodV0jmhyEB24OMtqQUmhkP3E2vfsmgag@mail.gmail.com>
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

Next: Aniket Gupta
Message 1 of 2 in “[BUG] combine-diff: wrong deletion columns at 33 parents, no hunks at 64”
  1. Sami JawharNov 17, 2026
  2. Aniket GuptaNov 20, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.