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

'BUG' in builtin add -p (was :Re: [ANNOUNCE] Git v2.40.0-rc2)

From
Philippe Blain <levraiphilippeblain@gmail.com>
Date
Mar 8, 2023, 20:51 UTC
Message-ID
<bff58f23-6188-9b1e-b23a-fc3d94e9f72f@gmail.com>
In-Reply-To
<xmqqy1o8wdgi.fsf@gitster.g>
Hi Dscho,
Le 2023-03-07 à 14:47, Junio C Hamano a écrit :
> A release candidate Git v2.40.0-rc2 is now available for testing at
> the usual places.  It is comprised of 461 non-merge commits since
> v2.39.0, contributed by 78 people, 30 of which are new faces [*].
> 
Show 5 quoted lines
> ----------------------------------------------------------------
> 
> Git v2.40 Release Notes (draft)
> ===============================
> 
>  * Finally retire the scripted "git add -p/-i" implementation and have
>    everybody use the one reimplemented in C.

I just hit a 'BUG' in the builtin add -p, I'll try to write a reproducer later but wanted to send a heads up now in case you can reproduced easily on your own with the below info. Note that this is not new in 2.40-rc2, I'm still on 2.39.1.

Basically I have an unmerged path from a conflicted 'git checkout $branch -m'. I resolved the conflict, but did not run 'git add'. And then I ran (in the 'doc' directory of the repository) 'git restore -S -p ../doc/path/to/file' and got:

```
BUG: add-patch.c:498: diff starts with unexpected line:
* Unmerged path doc/path/to/file
Aborted (core dumped)
```
and the backtrace from the core dump is the below:
```
Reading symbols from /home/me/bin/git...
[New LWP 4172500]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Core was generated by `git restore -S -p path/to/file'.
Program terminated with signal SIGABRT, Aborted.
#0  0x000014d138b0b7ff in raise () from /lib64/libc.so.6
(gdb) bt
#0  0x000014d138b0b7ff in raise () from /lib64/libc.so.6
#1  0x000014d138af5c35 in abort () from /lib64/libc.so.6
#2  0x0000000000703b75 in BUG_vfl (file=0x779d41 "add-patch.c", line=498, fmt=0x779d50 "diff starts with unexpected line:\n%.*s\n", params=0x7ffdd37529f0) at usage.c:320
#3  0x0000000000703c39 in BUG_fl (file=0x779d41 "add-patch.c", line=498, fmt=0x779d50 "diff starts with unexpected line:\n%.*s\n") at usage.c:330
#4  0x000000000051089a in parse_diff (s=0x7ffdd3752d90, ps=0x7ffdd3753910) at add-patch.c:497
#5  0x0000000000515339 in run_add_p (r=0xa5b3a0 <the_repo>, mode=ADD_P_RESET, revision=0xec35e0 "HEAD", ps=0x7ffdd3753910) at add-patch.c:1758
#6  0x0000000000408511 in run_add_interactive (revision=0xec35e0 "HEAD", patch_mode=0x74119d "--patch=reset", pathspec=0x7ffdd3753910) at builtin/add.c:273
#7  0x0000000000427f4b in checkout_paths (opts=0x7ffdd3753600, new_branch_info=0x7ffdd37533a0) at builtin/checkout.c:528
#8  0x000000000042c24d in checkout_main (argc=1, argv=0x7ffdd3753d40, prefix=0xebe58b "doc/", opts=0x7ffdd3753600, options=0xec0d80, usagestr=0xa342c0 <restore_usage>, new_branch_info=0x7ffdd37533a0)
    at builtin/checkout.c:1820
#9  0x000000000042cd1e in cmd_restore (argc=4, argv=0x7ffdd3753d40, prefix=0xebe58b "doc/") at builtin/checkout.c:1953
#10 0x0000000000406a83 in run_builtin (p=0xa371d8 <commands+2520>, argc=4, argv=0x7ffdd3753d40) at git.c:466
#11 0x0000000000406e68 in handle_builtin (argc=4, argv=0x7ffdd3753d40) at git.c:721
#12 0x00000000004070b6 in run_argv (argcp=0x7ffdd3753bcc, argv=0x7ffdd3753bc0) at git.c:788
#13 0x00000000004075cf in cmd_main (argc=4, argv=0x7ffdd3753d40) at git.c:926
#14 0x000000000050a80b in main (argc=5, argv=0x7ffdd3753d38) at common-main.c:57
```
Hope this helps,
Philippe.
Previous: Junio C HamanoNext: Jeff King
Message 2 of 5 in “[ANNOUNCE] Git v2.40.0-rc2”
  1. Junio C HamanoMar 7, 2023
  2. 'BUG' in builtin add -p (was :Re: [ANNOUNCE] Git v2.40.0-rc2)Philippe Blain, Mar 8, 2023
  3. add-patch: handle "* Unmerged path" linesJeff King, Mar 9, 2023
  4. Junio C HamanoMar 9, 2023
  5. Jeff KingMar 10, 2023

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.