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

Re: [PATCH] Consider object stores in alternates during a dissociating clone

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 22, 2015, 16:12 UTC
Message-ID
<xmqq7fmeubkf.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<5628EBAF.1030205@cetitec.com>
Alexander Riesen <alexander.riesen@cetitec.com> writes:
Show 17 quoted lines
> I think I understand. How about this?
>
>  builtin/clone.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/builtin/clone.c b/builtin/clone.c
> index 9eaecd9..a7d0c07 100644
> --- a/builtin/clone.c
> +++ b/builtin/clone.c
> @@ -801,11 +801,15 @@ static void write_refspec_config(const char *src_ref_prefix,
>  static void dissociate_from_references(void)
>  {
>      static const char* argv[] = { "repack", "-a", "-d", NULL };
> +    char *alts = git_pathdup("objects/info/alternates");
>
> +    if (access(alts, F_OK) < 0)
> +        return;
You leak alts here.
Show 20 quoted lines
>      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)
> +    if (unlink(alts) && errno != ENOENT)
>          die_errno(_("cannot unlink temporary alternates file"));
> +    free(alts);
>  }
>
>  int cmd_clone(int argc, const char **argv, const char *prefix)
> @@ -954,10 +958,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
>
>      if (option_reference.nr)
>          setup_reference();
> -    else if (option_dissociate) {
> -        warning(_("--dissociate given, but there is no --reference"));
> -        option_dissociate = 0;
> -    }
>
>      fetch_pattern = value.buf;
>      refspec = parse_fetch_refspec(1, &fetch_pattern);

Perhaps you would want a new test somewhere that (1) prepares the ultimate source, (2) prepares a borrowing source with "clone --reference" from the previous, (3) creates a local clone of the previous with "clone --local" without "--reference" but with "--dissociate", and (4) checks the end result by ensuring the absense of $GIT_DIR/objects/info/alternates and runs "fsck" on it.

Other than these two points, the patch looks good to me.
Previous: Alexander RiesenNext: Alexander Riesen
Message 7 of 16 in “Use the alternates of the source repository for dissociating clone”
  1. Use the alternates of the source repository for dissociating cloneAlexander Riesen, Oct 15, 2015
  2. Johannes SchindelinOct 15, 2015
  3. Allow "clone --dissociate" to dissociate from alternatesAlexander Riesen, Oct 15, 2015
  4. Alexander RiesenOct 21, 2015
  5. Junio C HamanoOct 21, 2015
  6. Consider object stores in alternates during a dissociating cloneAlexander Riesen, Oct 22, 2015
  7. Junio C HamanoOct 22, 2015
  8. Alexander RiesenOct 22, 2015
  9. Junio C HamanoOct 22, 2015
  10. Alexander RiesenOct 22, 2015
  11. Junio C HamanoOct 22, 2015
  12. Junio C HamanoOct 22, 2015
  13. Documentation: AsciiDoc spells em-dash as double-dashes, not tripleJunio C Hamano, Oct 22, 2015
  14. Johannes LöthbergOct 23, 2015
  15. Junio C HamanoOct 15, 2015
  16. Alexander RiesenOct 16, 2015

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.