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

Re: [PATCH v2 0/1] git-clone: fix relative path problem in the alternates

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 22, 2011, 20:38 UTC
Message-ID
<7vzkj1uqpa.fsf@alter.siamese.dyndns.org>
In-Reply-To
<7v7h65w9d7.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 8 quoted lines
>> 3. current existing add_to_alternates_file() will unconditionally append
>> "/objects" at each new added line, that need us to parse and  remove
>> "/objects" from each line read out from source alternates, this is a little
>> bit complicated.
>
> Clone with --reference is the only other caller of that function; I would
> say it is perfectly fine to make it the caller's responsibility to append
> "/objects" if that makes the resulting code easier to maintain.

I would further suggest moving add_to_alternates_file() from sha1_file.c to builtin/clone.c and make it file-scope static function, and change the way it should be used.

 - The caller should first obtain a lock file to info/alternates. If it
   truncates first or opens the file for appending is up to the caller.
 - When adding an alternate (either from --reference or your new
   codepath), the caller should give the lockfile instance it obtained
   earlier, and a path to the object store it wants to borrow objects from
   (not the repository, i.e. the caller should add "/objects" at the end
   if needed before calling the function), to add_to_alternates_file()
   function;
 - The function should just write the path to the locked info/alternates
   file, and link it to alt_odb list. Do not commit the alternates file,
   to allow multiple calls to the function be made without opening and
   closing the file number of times.
 - The caller should commit the updated alternates file once it is done.

While at it, we may probably want to update the command option handling so that you can give more than one --reference= parameters.

Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 10 in “git-clone: fix relative path problem in the alternates”
  1. 0/1 git-clone: fix relative path problem in the alternatesHui Wang, Aug 22, 2011
  2. 1/1 clone: replace relative paths in the alternatesHui Wang, Aug 22, 2011
  3. Junio C HamanoAug 22, 2011
  4. Junio C HamanoAug 22, 2011
  5. Junio C HamanoAug 22, 2011
  6. 0/2 clone-local fixupJunio C Hamano, Aug 23, 2011
  7. 1/2 clone: allow more than one --referenceJunio C Hamano, Aug 23, 2011
  8. 2/2 clone: clone from a repository with relative alternatesJunio C Hamano, Aug 23, 2011
  9. Hui WangAug 23, 2011
  10. Junio C HamanoAug 23, 2011

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.