Skip to content

fix(cli): keep the commit-session trailer dedup working on git 2.39 #940

Closed as not planned

Description

@mriffault

Observed

cli/tests/contexts/telemetry/domain/formats/commit-session-trailer.integration.test.ts:72 ("never doubles a trailer a prior run already wrote") runs the trailer-writing delegate twice and asserts the trailer token appears once.

On git 2.39.2 the test fails with AssertionError: expected 2 to be 1: the fixture message has no trailing newline, so git appends the trailer without a blank-line separator; the second pass then sees no trailer block and --if-exists doNothing appends again. The same delegate on a message ending in a newline dedupes correctly.

Reproduction

  1. git --version -> 2.39.2 (or any version sharing this behavior).
  2. cd cli && npx vitest run tests/contexts/telemetry/domain/formats/commit-session-trailer.integration.test.ts -> fails alone, deterministic, also under env -i.
  3. The same test passes on newer git (CI's).

Impact

The suite reports one failure per run on machines with this git, masking real regressions in the file and eroding trust in the suite's signal. The test and its source are byte-identical to next, so the failure predates any recent change.

Suggested fix

End the fixture message with a newline, or have the delegate normalize the message before appending.

Standalone repro verified on the machine that reported it: message without trailing newline doubles the trailer; message with one dedupes.

Activity

  1. blafourcade commented on Oct 6, 2026

    @blafourcade
    Contributor

    Confirmed on Git 2.39.5: running the delegate twice on a message without a trailing newline writes the trailer twice. Ensuring a non-empty message ends with a newline before calling git interpret-trailers produces one valid, parsed trailer. The fix should normalize that final newline, keep --if-exists doNothing, and cover repeated runs with and without a trailing newline.

  2. added theissue type on Oct 6, 2026
  3. blafourcade commented on Oct 15, 2026

    @blafourcade
    Contributor

    Superseded by #993: the commit-session trailer was removed with the old journal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    Priority

    Low

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions