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

Re: Scripted clone generating an incomplete, unusable .git/config

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Nov 11, 2010, 18:48 UTC
Message-ID
<20101111184829.GG16972@burratino>
In-Reply-To
<alpine.LNX.2.00.1011111241360.14365@iabervon.org>
On Thu, Nov 11, 2010 at 12:55:48PM -0500, Daniel Barkalow wrote:
> On Thu, 11 Nov 2010, Jonathan Nieder wrote:
Show 12 quoted lines
>> --- a/builtin/clone.c
>> +++ b/builtin/clone.c
>> @@ -667,6 +667,5 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
>>  	strbuf_release(&branch_top);
>>  	strbuf_release(&key);
>>  	strbuf_release(&value);
>> -	junk_pid = 0;
>>  	return err;
>>  }
>
> I believe that would cause it to remove the repository when it terminates, 
> regardless of whether it completed or not.
Ah, right, the second remove_junk() call is because of atexit().

So why does git clone keep running after the first remove_junk() call? It seems that the signal is initially set up (by Python's popen()?) as SIG_IGN. I guess "git clone" should explicitly override that to be SIG_DFL?

Here's a proof of concept. It is not very good because it overrides any previously set sigchain handlers (in case the "git" wrappers start to use one) and because using SIG_DFL as a sigchain_fun feels like violating an abstraction.

diff --git a/builtin/clone.c b/builtin/clone.c
index 19ed640..2f21a91 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -458,6 +458,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 	}
 	junk_git_dir = git_dir;
 	atexit(remove_junk);
+	sigchain_push_common(SIG_DFL);
 	sigchain_push_common(remove_junk_on_signal);
 
 	setenv(CONFIG_ENVIRONMENT, mkpath("%s/config", git_dir), 1);
Previous: Daniel BarkalowNext: Jeff King
Message 8 of 17 in “Scripted clone generating an incomplete, unusable .git/config”
  1. Dun PealNov 10, 2010
  2. Stefan NaeweNov 11, 2010
  3. Stefan NaeweNov 11, 2010
  4. Jonathan NiederNov 11, 2010
  5. Nguyen Thai Ngoc DuyNov 11, 2010
  6. Jonathan NiederNov 11, 2010
  7. Daniel BarkalowNov 11, 2010
  8. Jonathan NiederNov 11, 2010
  9. Jeff KingNov 11, 2010
  10. Jonathan NiederNov 12, 2010
  11. Jeff KingNov 12, 2010
  12. Jonathan NiederNov 12, 2010
  13. Jonathan NiederNov 12, 2010
  14. Jeff KingNov 12, 2010
  15. Jonathan NiederNov 12, 2010
  16. daemon, tag, verify-tag: do not pass ignored signals to child (Re: Scripted clone generating an incomplete, unusable .git/config)Jonathan Nieder, Nov 12, 2010
  17. Andreas SchwabNov 11, 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.