Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: git/git
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: fb5516997ef3f882d8e53ce70ba6077533683621
Choose a base ref
...
head repository: git/git
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 512536a09ea2964e93226f219898ee0a09d85a70
Choose a head ref
  • 4 commits
  • 35 files changed
  • 1 contributor

Commits on Mar 17, 2026

  1. line-log: fix crash when combined with pickaxe options

    queue_diffs() passes the caller's diff_options, which may carry
    user-specified pickaxe state, to diff_tree_oid() and diffcore_std()
    when detecting renames for line-level history tracking.  When pickaxe
    options are present on the command line (-G and -S to filter by text
    pattern, --find-object to filter by object identity), diffcore_std()
    also runs diffcore_pickaxe(), which may discard diff pairs that are
    relevant for rename detection.  Losing those pairs breaks rename
    following.
    
    Before a2bb801 (line-log: avoid unnecessary full tree diffs,
    2019-08-21), this silently truncated history at rename boundaries.
    That commit moved filter_diffs_for_paths() inside the rename-
    detection block, so it only runs when diff_might_be_rename() returns
    true.  When pickaxe discards a rename pair, the rename goes
    undetected, and a deletion pair at a subsequent commit passes
    through uncleaned, reaching process_diff_filepair() with an invalid
    filespec and triggering an assertion failure.
    
    Fix this by building a private diff_options for the rename-detection
    path inside queue_diffs(), following the same pattern used by blame's
    find_rename().  This isolates the rename machinery from unrelated
    user-specified options.
    
    Reported-by: Matthew Hughes <matthewhughes934@gmail.com>
    Signed-off-by: Michael Montalbo <mmontalbo@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    mmontalbo authored and gitster committed Mar 17, 2026
    Configuration menu
    Copy the full SHA
    81cf6cc View commit details
    Browse the repository at this point in the history
  2. line-log: route -L output through the standard diff pipeline

    `git log -L` has always bypassed the standard diff pipeline.
    `dump_diff_hacky()` in line-log.c hand-rolls its own diff headers and
    hunk output, which means most diff formatting options are silently
    ignored.  A NEEDSWORK comment has acknowledged this since the feature
    was introduced:
    
        /*
         * NEEDSWORK: manually building a diff here is not the Right
         * Thing(tm).  log -L should be built into the diff pipeline.
         */
    
    Remove `dump_diff_hacky()` and its helpers and route -L output through
    `builtin_diff()` / `fn_out_consume()`, the same path used by `git diff`
    and `git log -p`.  The mechanism is a pair of callback wrappers that sit
    between `xdi_diff_outf()` and `fn_out_consume()`, filtering xdiff's
    output to only the tracked line ranges.  To ensure xdiff emits all lines
    within each range as context, the context length is inflated to span the
    largest range.
    
    Wire up the `-L` implies `--patch` default in revision setup rather
    than forcing it at output time, so `line_log_print()` is just
    `diffcore_std()` + `diff_flush()` with no format save/restore.
    Rename detection is a no-op since pairs are already resolved during
    the history walk in `queue_diffs()`, but running `diffcore_std()`
    means `-S`/`-G` (pickaxe), `--orderfile`, and `--diff-filter` now
    work with `-L`, and `diff_resolve_rename_copy()` sets pair statuses
    correctly without manual assignment.
    
    Switch `diff_filepair_dup()` from `xmalloc` to `xcalloc` so that new
    fields (including `line_ranges`) are zero-initialized by default.
    
    As a result, diff formatting options that were previously silently
    ignored (e.g. --word-diff, --no-prefix, -w, --color-moved) now work
    with -L, and output gains `index` lines, `new file mode` headers, and
    funcname context in `@@` headers.  This is a user-visible output change:
    tools that parse -L output may need to handle the additional header
    lines.
    
    The context-length inflation means xdiff may process more output than
    needed for very wide line ranges, but benchmarks on files up to 7800
    lines show no measurable regression.
    
    Signed-off-by: Michael Montalbo <mmontalbo@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    mmontalbo authored and gitster committed Mar 17, 2026
    Configuration menu
    Copy the full SHA
    86e986f View commit details
    Browse the repository at this point in the history
  3. t4211: add tests for -L with standard diff options

    Now that -L output flows through the standard diff pipeline, verify
    that previously-ignored diff options work: formatting (--word-diff,
    --word-diff-regex, --no-prefix, --src/dst-prefix, --full-index,
    --abbrev), whitespace handling (-w, -b), output indicators
    (--output-indicator-new/old/context), direction reversal (-R),
    --color-moved, and pickaxe options (-S, -G).
    
    Signed-off-by: Michael Montalbo <mmontalbo@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    mmontalbo authored and gitster committed Mar 17, 2026
    Configuration menu
    Copy the full SHA
    0e51f7a View commit details
    Browse the repository at this point in the history
  4. doc: note that -L supports patch formatting and pickaxe options

    Now that -L output flows through the standard diff pipeline,
    document that patch formatting options like --word-diff,
    --color-moved, --no-prefix, whitespace handling (-w, -b),
    and pickaxe options (-S, -G) are supported.
    
    Signed-off-by: Michael Montalbo <mmontalbo@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    mmontalbo authored and gitster committed Mar 17, 2026
    Configuration menu
    Copy the full SHA
    512536a View commit details
    Browse the repository at this point in the history
Loading