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

Re: git crashes in `git commit --patch` with diff.suppressBlankEmpty = true

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Jul 4, 2024, 13:14 UTC
Message-ID
<ab974e62-098c-4200-bee3-7de8d9115516@gmail.com>
In-Reply-To
<9b31e86f-c408-4625-8d13-f48a209b541b@gmail.com>
Hi Ilya

Thanks for reporting this and for the example reproduction. The problem is that the code that splits hunks expects context lines to begin with ' '. We could fix that fairly simply but I wonder if we should change 'diff-index' and 'diff-files' to ignore diff.suppressBlankEmpty instead. The plumbing diff commands already ignore most of the options that change diff output so I'm not quite sure why they respect this particular config setting. I've cc'd a few people to see what they think.

Best Wishes
Phillip
On 03/07/2024 15:41, Ilya Tumaykin wrote:
Show 61 quoted lines
> Hello.
> 
> `git commit --patch` crashes with diff.suppressBlankEmpty option enabled 
> under certain conditions.
> 
> 
> Steps to reproduce:
> 1. Prepare .gitconfig:
> [user]
>      name = User
>      email = user@example.com
> [diff]
>      suppressBlankEmpty = true
> 
> 2. Initialize repo:
> $ mkdir git_bug && cd git_bug
> $ git init
> $ echo -e 'test\n\n test \n\ntest' > test.txt
> $ git add test.txt
> $ git commit test.txt -m 'initial'
> 
> 3. Make changes:
> $ echo -e 'test\n\n test\ntest\n \n' > test.txt
> 
> 4. Try to commit new changes
> $ git commit --patch test.txt
> 
> 5. Try to split the first hunk, press 's' in the git-commit interactive 
> interface.
> 
> 
> Actual results:
> diff --git a/test.txt b/test.txt
> index 366cd4b..611ca9d 100644
> --- a/test.txt
> +++ b/test.txt
> @@ -1,5 +1,6 @@
>   test
> 
> - test
> -
> + test
>   test
> +
> +
> (1/1) Stage this hunk [y,n,q,a,d,s,e,p,?]? s
> BUG: add-patch.c:994: unhandled diff marker: '
> '
> Aborted (core dumped)
> 
> 
> Expected results:
> git-commit splits the hunk and continues.
> 
> 
> Comment:
> If I set diff.suppressBlankEmpty = false, then I get the expected behavior.
> 
> git --version: 2.45.2
> OS: up-to-date Fedora 40
> 
Previous: Ilya TumaykinNext: Junio C Hamano
Message 2 of 12 in “git crashes in `git commit --patch` with diff.suppressBlankEmpty = true”
  1. Ilya TumaykinJul 3, 2024
  2. Phillip WoodJul 4, 2024
  3. Junio C HamanoJul 5, 2024
  4. add-patch: handle splitting hunks with diff.suppressBlankEmptyJeff King, Jul 10, 2024
  5. Phillip WoodJul 10, 2024
  6. Jeff KingJul 11, 2024
  7. phillip.wood123@gmail.comJul 13, 2024
  8. Jeff KingJul 13, 2024
  9. Phillip WoodJul 18, 2024
  10. Phillip WoodJul 18, 2024
  11. Junio C HamanoJul 10, 2024
  12. Jeff KingJul 11, 2024

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.