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

Re: [PATCH/GSoC/RFC] fetch: git fetch --deepen

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 14, 2015, 05:35 UTC
Message-ID
<xmqqlhj0xhsl.fsf@gitster.dls.corp.google.com>
In-Reply-To
<1426251846-1604-1-git-send-email-dongcan.jiang@gmail.com>
Dongcan Jiang <dongcan.jiang@gmail.com> writes:
Show 37 quoted lines
> This patch is just for discusstion. An option --deepen is added to
> 'git fetch'. When it comes to '--deepen', git should fetch N more
> commits ahead the local shallow commit, where N is indicated by
> '--depth=N'. [1]
>
> e.g.
>
>>  (upstream)
>>   ---o---o---o---A---B
>>
>>  (you)
>>                  A---B
>
> After excuting "git fetch --depth=1 --deepen", (you) get one more
> tip and it becomes
>
>>  (you)
>>              o---A---B
>
> '--deepen' is designed to be a boolean option in this patch, which
> is a little different from [1]. It's designed in this way, because
> it can reuse '--depth' in the program, and just costs one more bit
> in some data structure, such as fetch_pack_args,
> git_transport_options.
>
> Of course, as a patch for discussion, it remains a long way to go
> before being complete.
>
> 	1) Documents should be completed.
> 	2) More test cases, expecially corner cases, should be added.
> 	3) No need to get remote refs when it comes to '--deepen' option.
> 	4) Validity on options combination should be checked.
> 	5) smart-http protocol remains to be supported. [2]
>
> Besides, I still have one question:
> What does (you) exactly mean in [1]? The local branch or the local
> remote ref?

As this operation is not about moving _any_ refs, whether local branches or remote-tracking branches, any ref that used to point at commit B before you executed "fetch --deepen" would point at the same commit after the command finishes.

The "you" does not explicitly depict any ref, because the picture is meant to illustrate _everything_ the repository at the receiving end of "fetch" has. It used to have two commits, A and B (and the tree and blob objects necessary to complete these two commits). After deepening the history by one commit, it then will have commit A^ and its trees and blobs.

Show 28 quoted lines
> diff --git a/upload-pack.c b/upload-pack.c
> index b531a32..8004f2f 100644
> --- a/upload-pack.c
> +++ b/upload-pack.c
> @@ -31,6 +31,7 @@ static const char upload_pack_usage[] = "git upload-pack [--strict] [--timeout=<
>
>  static unsigned long oldest_have;
>
> +static int depth_deepen;
>  static int multi_ack;
>  static int no_done;
>  static int use_thin_pack, use_ofs_delta, use_include_tag;
> @@ -563,11 +564,11 @@ static void receive_needs(void)
>  			}
>  			continue;
>  		}
> -		if (starts_with(line, "deepen ")) {
> +		if (starts_with(line, "depth ")) {
>  			char *end;
> -			depth = strtol(line + 7, &end, 0);
> -			if (end == line + 7 || depth <= 0)
> -				die("Invalid deepen: %s", line);
> +			depth = strtol(line + 6, &end, 0);
> +			if (end == line + 6 || depth <= 0)
> +				die("Invalid depth: %s", line);
>  			continue;
>  		}
>  		if (!starts_with(line, "want ") ||

I do not quite understand this hunk. What happens when this program is talking to an existing fetch-pack that requested "deepen"?

Show 22 quoted lines
> @@ -577,6 +578,8 @@ static void receive_needs(void)
>
>  		features = line + 45;
>
> +		if (parse_feature_request(features, "depth_deepen"))
> +			depth_deepen = 1;
>  		if (parse_feature_request(features, "multi_ack_detailed"))
>  			multi_ack = 2;
>  		else if (parse_feature_request(features, "multi_ack"))
> @@ -631,6 +634,10 @@ static void receive_needs(void)
>  				struct object *object = shallows.objects[i].item;
>  				object->flags |= NOT_SHALLOW;
>  			}
> +		else if (depth_deepen)
> +			backup = result =
> +				get_shallow_commits(&shallows, depth + 1,
> +						    SHALLOW, NOT_SHALLOW);
>  		else
>  			backup = result =
>  				get_shallow_commits(&want_obj, depth,
> --
> 2.3.1.253.gb3fd89e
Previous: Dongcan JiangNext: Duy Nguyen
Message 4 of 14 in “fetch: git fetch --deepen”
  1. fetch: git fetch --deepenDongcan Jiang, Mar 13, 2015
  2. Eric SunshineMar 13, 2015
  3. Dongcan JiangMar 16, 2015
  4. Junio C HamanoMar 14, 2015
  5. Duy NguyenMar 14, 2015
  6. Junio C HamanoMar 14, 2015
  7. Dongcan JiangMar 16, 2015
  8. Duy NguyenMar 14, 2015
  9. Dongcan JiangMar 16, 2015
  10. Duy NguyenMar 17, 2015
  11. Dongcan JiangMar 17, 2015
  12. fetch: git fetch --deepenDongcan Jiang, Mar 22, 2015
  13. Eric SunshineMar 22, 2015
  14. Duy NguyenMar 22, 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.