Skip to content

Work diff canvas drops blank context lines when the user's Git config sets diff.suppressBlankEmpty #285

Closed

Description

@NopeCharon

Expected and actual behavior / 实际现象与期望

With diff.suppressBlankEmpty=true in the user's Git config, git diff writes a blank context line as an empty line instead of a single space. Git apply and GNU patch read that empty line as context. parse_unified_diff (server/unified_diff.py) drops it, so the Work attempt diff canvas loses every blank context line, and every following line in the hunk shows an old/new line number that is one too low per dropped line.

Expected: a blank context line is shown with its line numbers, and the rest of the hunk keeps the right numbers.

Steps to reproduce / 复现步骤

git config diff.suppressBlankEmpty true
printf 'a\n\nb\nc\n' > notes.txt && git add notes.txt && git commit -m base

Run an attempt that changes b to B, then open the attempt diff.

The attempt patch is

@@ -1,4 +1,4 @@
 a

-b
+B
 c

Actual: lines a (1/1), -b (old 2), +B (new 2), c (3/3). The blank line is missing.
Expected: a (1/1), blank (2/2), -b (old 3), +B (new 3), c (4/4).

Relevant environment / 使用环境

Platform-independent; current main (f86c72a). Reproduced with Git 2.43 and 2.54. There is no git diff command-line option that overrides this setting.

Sanitized evidence / 错误信息或截图(请先脱敏)

The parser skips every empty line (if current_hunk is None or not raw_line: continue), including one that the hunk header still counts as a context line.

Related issues or fixes / 相关问题或修复

Follow-up to #279 / #284, which pinned the other Git settings that change the patch format.

Activity

  1. added a commit that references this issue on Nov 9, 2026
    e903643
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

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions