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

[PATCH 6/8] Fix bundle --stdin

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Jun 26, 2010, 06:28 UTC
Message-ID
<20100626062811.GG15881@burratino>
In-Reply-To
<20100626061735.GA15881@burratino>

To write a bundle’s table of contents, the name passed on the command line for each ref is needed. Unfortunately, names passed through stdin are put in a temporary buffer and then freed; the random gibberish that tends to replace them does not look like a meaningful ref name to bundle_list_refs(), so no valid toc entries are found and ‘git bundle --stdin’ thinks it has been asked to create an empty bundle.

So teach the revision walker to keep rev names after reading them from stdin. This fixes ‘git bundle --stdin’ at the cost of a memory leak.

Reported-by: Joey Hess <joey@kitenet.net>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
 revision.c        |    2 +-
 t/t5704-bundle.sh |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/revision.c b/revision.c
index f4b8b38..cf86af3 100644
--- a/revision.c
+++ b/revision.c
@@ -1022,7 +1022,7 @@ static void read_revisions_from_stdin(struct rev_info *revs, const char ***prune
 			}
 			die("options not supported in --stdin mode");
 		}
-		if (handle_revision_arg(sb.buf, revs, 0, 1))
+		if (handle_revision_arg(xstrdup(sb.buf), revs, 0, 1))
 			die("bad revision '%s'", sb.buf);
 	}
 	if (seen_dashdash)
diff --git a/t/t5704-bundle.sh b/t/t5704-bundle.sh
index ddc3dc5..cc463f3 100755
--- a/t/t5704-bundle.sh
+++ b/t/t5704-bundle.sh
@@ -30,7 +30,7 @@ test_expect_success 'tags can be excluded by rev-list options' '
 
 '
 
-test_expect_failure 'bundle --stdin' '
+test_expect_success 'bundle --stdin' '
 
 	echo master | git bundle create stdin-bundle.bdl --stdin &&
 	git ls-remote stdin-bundle.bdl >output &&
@@ -38,7 +38,7 @@ test_expect_failure 'bundle --stdin' '
 
 '
 
-test_expect_failure 'bundle --stdin <rev-list options>' '
+test_expect_success 'bundle --stdin <rev-list options>' '
 
 	echo master | git bundle create hybrid-bundle.bdl --stdin tag &&
 	git ls-remote hybrid-bundle.bdl >output &&
-- 
1.7.1.198.g8d802
Previous: Jonathan NiederNext: Jonathan Nieder
Message 17 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.