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

Re: bug: git-bundle create foo --stdin -> segfault

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jan 19, 2010, 23:52 UTC
Message-ID
<alpine.DEB.1.00.1001192307090.3164@intel-tinevez-2-302>
In-Reply-To
<20100119002641.GA31434@gnu.kitenet.net>
Hi,
On Mon, 18 Jan 2010, Joey Hess wrote:
> joey@gnu:~/tmp/new>echo master | git bundle create ../my.bundle --stdin
> zsh: segmentation fault  git bundle create ../my.bundle --stdin
Current 'next' fails, too.
Some previous Git versions failed with a message like this:
error: unrecognized argument: --stdin'
Other previous Git versions failed at least with a message such as this:

fatal: exec rev-list failed. error: rev-list died

Something similar happens to me when I run the initial official revision of git-bundle. The reason is that "git rev-list --boundary --pretty=oneline --stdin" refuses to run.

The bad versions either segfault, or "refuse to create empty bundles".

And while 8b3dce5 purports to clean things up (even acknowledging that support code for --stdin was removed from bundle.c!), at that time git-bundle was obviously not tested/fixed.

Now, I invested a lot of time into the new Git wiki, and into trying to bisect this (it took many, many more steps than the suggested 13, and somewhere in between, the number of commits to be tested even increased!).

If you want to fix it, I suggest requiring --stdin to be the only parameter after the bundle file name, and adding a function using strbuf_getline() to parse the stdin into a string_list. Once that is done, you can substitute the argv for the rev-list call with that list (for that, you need to prepopulate with "rev-list", "--boundary" and "--pretty=oneline"). You can reuse that list for the call to setup_revisions().

Alternatively, you can try to implement the rev-list --boundary by hand (the --pretty=oneline is only needed to get a boundary marker IIRC), taking care to reset the commit flags that were set in the process. (We need to know the boundary commits before actually starting to write the pack, because the bundle file format dictates that the boundary commits are listed as prerequsites in the bundle header.)

If you want to go that route (which is arguably more elegant anyway), I suggest having a look at the merge_bases() and get_merge_bases() functions in commit.c, which do something similar (i.e. a revwalk without using revision.c's functions -- because you cannot tell what flags they will use in the future, and they have to be reset after the walk).

Ciao, Dscho

Previous: Joey HessNext: Jonathan Nieder
Message 2 of 19 in “bug: git-bundle create foo --stdin -> segfault”
  1. Joey HessJan 19, 2010
  2. Johannes SchindelinJan 19, 2010
  3. 0/2 test bundle --stdin, fix objects_array_remove_duplicates()Jonathan Nieder, Apr 19, 2010
  4. 1/2 t5704 (bundle): add tests for bundle --stdinJonathan Nieder, Apr 19, 2010
  5. 2/2 fix "bundle --stdin" segfaultJonathan Nieder, Apr 19, 2010
  6. Junio C HamanoApr 20, 2010
  7. 0/8 Re: bug: git-bundle create foo --stdin -> segfaultJonathan Nieder, Jun 26, 2010
  8. 1/8 bundle: split basis discovery into its own functionJonathan Nieder, Jun 26, 2010
  9. 2/8 bundle: use libified rev-list --boundaryJonathan Nieder, Jun 26, 2010
  10. Junio C HamanoJun 30, 2010
  11. Jonathan NiederJun 30, 2010
  12. 3/8 bundle: give list_prerequisites() loop body its own functionJonathan Nieder, Jun 26, 2010
  13. Junio C HamanoJun 30, 2010
  14. Jonathan NiederJun 30, 2010
  15. 4/8 bundle: split table of contents output into its own functionJonathan Nieder, Jun 26, 2010
  16. 5/8 bundle: reuse setup_revisions resultJonathan Nieder, Jun 26, 2010
  17. 6/8 Fix bundle --stdinJonathan Nieder, Jun 26, 2010
  18. 7/8 bundle: Keep names of basis refs after discoveryJonathan Nieder, Jun 26, 2010
  19. 8/8 bundle_create: Do not exit when given no revs to bundleJonathan Nieder, Jun 26, 2010

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.