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

Re: [PATCH] Add git-bundle: move objects and references by archive

From
Junio C Hamano <junkio@cox.net>
Date
Feb 22, 2007, 07:08 UTC
Message-ID
<7v4ppellev.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<7v8xeqllxk.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano <junkio@cox.net> writes:
Show 31 quoted lines
>> +static int verify_bundle(struct bundle_header *header)
>> +{
>> +	/*
>> +	 * Do fast check, then if any prereqs are missing then go line by line
>> +	 * to be verbose about the errors
>> +	 */
>> +	struct ref_list *p = &header->prerequisites;
>> +	const char *argv[5] = {"rev-list", "--stdin", "--not", "--all", NULL};
>> +	int pid, in, out, i, ret = 0;
>> +	char buffer[1024];
>> +
>> +	in = out = -1;
>> +	pid = fork_with_pipe(argv, &in, &out);
>> +	if (pid < 0)
>> +		return error("Could not fork rev-list");
>> +	if (!fork()) {
>> +		for (i = 0; i < p->nr; i++) {
>> +			write(in, sha1_to_hex(p->list[i].sha1), 40);
>> +			write(in, "\n", 1);
>> +		}
>> +		close(in);
>> +		exit(0);
>> +	}
>> +	close(in);
>
> What if write() fails?  That can happen when one of the objects
> you feed here, or its parent objects, is missing from your
> repository -- receiving rev-list would die() and the writing
> child would sigpipe.
>
> I also wonder who waits for this child...

In general, fork() to avoid bidirectional pipe deadlock is a good discipline, but in this particular case I think it would be easier to handle errors if you don't (and it would save another process). The other side "rev-list --stdin --not --all" is running a limited traversal, and would not emit anything until you stop feeding it from --stdin, or until it dies because you fed it a commit that does not exist. So as long as you check the error condition from write() for EPIPE to notice the other end died, I think you are Ok.

Previous: Junio C HamanoNext: Johannes Schindelin
Message 13 of 28 in “Add git-bundle: move objects and references by archive”
  1. Add git-bundle: move objects and references by archiveJohannes Schindelin, Feb 22, 2007
  2. Nicolas PitreFeb 22, 2007
  3. Johannes SchindelinFeb 22, 2007
  4. Simon 'corecode' SchubertFeb 22, 2007
  5. Nicolas PitreFeb 22, 2007
  6. Johannes SchindelinFeb 22, 2007
  7. Simon 'corecode' SchubertFeb 22, 2007
  8. Johannes SchindelinFeb 22, 2007
  9. Nicolas PitreFeb 22, 2007
  10. Johannes SchindelinFeb 22, 2007
  11. Nicolas PitreFeb 22, 2007
  12. Junio C HamanoFeb 22, 2007
  13. Junio C HamanoFeb 22, 2007
  14. Johannes SchindelinFeb 22, 2007
  15. Junio C HamanoFeb 22, 2007
  16. Johannes SchindelinFeb 22, 2007
  17. Junio C HamanoFeb 22, 2007
  18. Johannes SchindelinFeb 22, 2007
  19. Johannes SchindelinFeb 22, 2007
  20. Mark LevedahlFeb 23, 2007
  21. Junio C HamanoFeb 23, 2007
  22. Johannes SixtFeb 22, 2007
  23. git-bundle: assorted fixesJohannes Schindelin, Feb 22, 2007
  24. Mark LevedahlFeb 23, 2007
  25. Johannes SchindelinFeb 23, 2007
  26. Mark LevedahlFeb 23, 2007
  27. Johannes SchindelinFeb 23, 2007
  28. Mark LevedahlFeb 23, 2007

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.