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

Re: [PATCH] clone: --dissociate option to mark that reference is only temporary

From
Johannes Sixt <j6t@kdbg.org>
Date
Oct 15, 2014, 19:44 UTC
Message-ID
<543ECE88.7050703@kdbg.org>
In-Reply-To
<xmqqa94yzap8.fsf@gitster.dls.corp.google.com>
Am 14.10.2014 um 21:57 schrieb Junio C Hamano:
Show 5 quoted lines
> +static void dissociate_from_references(void)
> +{
> +	struct child_process cmd;
> +
> +	memset(&cmd, 0, sizeof(cmd));
We have CHILD_PROCESS_INIT these days.
> +	argv_array_pushl(&cmd.args, "repack", "-a", "-d", NULL);
> +	cmd.git_cmd = 1;
> +	cmd.out = -1;
This requests a pipe, but you don't use it nor need it.
Show 6 quoted lines
> +	cmd.no_stdin = 1;
> +	if (run_command(&cmd))
> +		die(_("cannot repack to clean up"));
> +	if (unlink(git_path("objects/info/alternates")) && errno != ENOENT)
> +		die_errno(_("cannot unlink temporary alternates file"));
> +}

Unless you have a secret plan, you can do it even shorter with our helpers:

diff --git a/builtin/clone.c b/builtin/clone.c
index 8649090..81efb07 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -743,14 +743,9 @@ static void write_refspec_config(const char *src_ref_prefix,
 
 static void dissociate_from_references(void)
 {
-	struct child_process cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	argv_array_pushl(&cmd.args, "repack", "-a", "-d", NULL);
-	cmd.git_cmd = 1;
-	cmd.out = -1;
-	cmd.no_stdin = 1;
-	if (run_command(&cmd))
+	static const char* argv[] = { "repack", "-a", "-d", NULL };
+
+	if (run_command_v_opt(argv, RUN_GIT_CMD|RUN_COMMAND_NO_STDIN))
 		die(_("cannot repack to clean up"));
 	if (unlink(git_path("objects/info/alternates")) && errno != ENOENT)
 		die_errno(_("cannot unlink temporary alternates file"));
Previous: Junio C HamanoNext: Junio C Hamano
Message 11 of 12 in “clone: --dissociate option to mark that reference is only temporary”
  1. clone: --dissociate option to mark that reference is only temporaryJunio C Hamano, Oct 14, 2014
  2. Marc BranchaudOct 15, 2014
  3. Junio C HamanoOct 15, 2014
  4. Marc BranchaudOct 15, 2014
  5. Junio C HamanoOct 15, 2014
  6. Marc BranchaudOct 15, 2014
  7. Junio C HamanoOct 15, 2014
  8. Marc BranchaudOct 16, 2014
  9. Jakub NarębskiOct 17, 2014
  10. Junio C HamanoOct 16, 2014
  11. Johannes SixtOct 15, 2014
  12. Junio C HamanoOct 15, 2014

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.