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

Re: [PATCH 3/5] allow cloning a repository "shallowly"

From
Junio C Hamano <junkio@cox.net>
Date
Nov 14, 2006, 07:24 UTC
Message-ID
<7v4pt21oe9.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<Pine.LNX.4.63.0610302009160.26682@wbgn013.biozentrum.uni-wuerzburg.de>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 30 quoted lines
> By specifying a depth, you can now clone a repository such that
> all fetched ancestor-chains' length is at most "depth". For example,
> if the upstream repository has only 2 branches ("A" and "B"), which
> are linear, and you specify depth 3, you will get A, A~1, A~2, A~3,
> B, B~1, B~2, and B~3. The ends are automatically made shallow
> commits.
>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
>  fetch-pack.c  |   61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
>  git-clone.sh  |   19 +++++++++++++++--
>  upload-pack.c |   21 ++++++++++++++++++-
>  3 files changed, 96 insertions(+), 5 deletions(-)
>
> diff --git a/fetch-pack.c b/fetch-pack.c
> index 488adc9..9619d6e 100644
> --- a/fetch-pack.c
> +++ b/fetch-pack.c
>...
> +		while ((len = packet_read_line(fd[0], line, sizeof(line)))) {
> +			if (!strncmp("shallow ", line, 8)) {
> +				if (get_sha1_hex(line + 8, sha1))
> +					die("invalid shallow line: %s", line);
> +				/* no need making it shallow if we have it already */
> +				if (lookup_object(sha1))
> +					continue;
> +				register_shallow(sha1);
> +			}
> +		}
> +	}

I understand "no need making it shallow", but I am not sure if a non-NULL return from lookup_object() tells us that.

Before this part of the code, we have scanned the local refs in everything_local (which parses their refs).

I think register_shallow() can take commits that are already shallow() so maybe we can remove this "if() continue"?

Previous: Johannes SchindelinNext: Johannes Schindelin
Message 2 of 5 in “allow cloning a repository "shallowly"”
  1. 3/5 allow cloning a repository "shallowly"Johannes Schindelin, Oct 30, 2006
  2. Junio C HamanoNov 14, 2006
  3. Johannes SchindelinNov 14, 2006
  4. Junio C HamanoNov 14, 2006
  5. Johannes SchindelinNov 15, 2006

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.