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

Re: [PATCH] fetch: add a config option to always use the depth argument

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 1, 2014, 20:58 UTC
Message-ID
<xmqqvblvnl3r.fsf@gitster.dls.corp.google.com>
In-Reply-To
<xmqqzjb7nlyx.fsf@gitster.dls.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 12 quoted lines
> Stefan Beller <sbeller@google.com> writes:
>
>> +fetch.depth::
>> +	If set, fetch will automatically behave as if the `--depth`
>> +	option was given on the command line.  This allows users to keep
>> +	the git directory at low space requirements, and thus comes in handy
>> +	for users with large binary files in the repository.
>> +
>
> Hmm, is this something a user would typically want repository-wide?
> I am wondering if "remote.$nick.fetchDepth" or something scoped to
> remote is more appropriate.

Regardless of what configuration variable is used, I think setting depth directly from the config will mean the user cannot defeat a configured value by passing --unshallow because of this code sequence in builtin/fetch.c; am I mistaken?

	...
	git_config(git_fetch_config, NULL);
	argc = parse_options(argc, argv, prefix,
			     builtin_fetch_options, builtin_fetch_usage, 0);
	if (unshallow) {
		if (depth)
			die(_("--depth and --unshallow cannot be used together"));
	...
I think depth variable should be left alone.

The right solution may be to leave the above "unshallow and depth are incompatible" check done only for the command line options as the original code, and much later in the code path after you figure out which remote we are talking to, only when neither --depth nor --unshallow is given, consult the configuration system to see if there is a default, perhaps in prepare_transport(). That approach will let you later support "remote.$nick.fetchDepth", even if you start with a repository-wide "fetch.depth" option, I would think.

Previous: Junio C Hamano
Message 3 of 3 in “fetch: add a config option to always use the depth argument”
  1. fetch: add a config option to always use the depth argumentStefan Beller, Dec 1, 2014
  2. Junio C HamanoDec 1, 2014
  3. Junio C HamanoDec 1, 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.