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

Re: [PATCH] transport: Catch non positive --depth option value

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 18, 2013, 16:51 UTC
Message-ID
<xmqqzjp1bqm3.fsf@gitster.dls.corp.google.com>
In-Reply-To
<5283A380.9030308@gmail.com>
"Andrés G. Aragoneses" <knocte@gmail.com> writes:
Show 8 quoted lines
> Instead of simply ignoring the value passed to --depth
> option when it is zero or negative, now it is caught
> and reported.
>
> This will let people know that they were using the
> option incorrectly (as depth<0 should be simply invalid,
> and under the hood depth==0 didn't mean 'no depth' or
> 'no history' but 'full depth' instead).

My initial knee-jerk reaction was: doesn't this change break existing use to unplug a shallow repository and bring it to a repository with an unshallow one to disallow depth=0, though?

I somehow thought that the code supports unshallowing with --depth=0 even though since 4dcb167f (fetch: add --unshallow for turning shallow repo into complete one, 2013-01-11), the officially supported way to tell Git to unshallow is with that option.

But apparently that is not the case; I do not think depth==0 meant 'full depth' (i.e. "git fetch --depth=0" did not unshallow); it was simply ignored in fetch_pack.c::find_common() and friends.

So I think it should be a safe change to disallow non-positive depth like this patch does, but the proposed commit log message may need polishing.

Thanks.
Show 19 quoted lines
> Signed-off-by: Andres G. Aragoneses <knocte@gmail.com>
> ---
>  transport.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/transport.c b/transport.c
> index 7202b77..edd63eb 100644
> --- a/transport.c
> +++ b/transport.c
> @@ -483,6 +483,8 @@ static int set_git_option(struct
> git_transport_options *opts,
>  			opts->depth = strtol(value, &end, 0);
>  			if (*end)
>  				die("transport: invalid depth option '%s'", value);
> +			if (opts->depth < 1)
> +				die("transport: invalid depth option '%s' (non positive)", value);
>  		}
>  		return 0;
>  	}
Previous: Duy NguyenNext: Andrés G. Aragoneses
Message 3 of 16 in “transport: Catch non positive --depth option value”
  1. transport: Catch non positive --depth option valueAndrés G. Aragoneses, Nov 13, 2013
  2. Duy NguyenNov 16, 2013
  3. Junio C HamanoNov 18, 2013
  4. [PATCHv2] transport: Catch non positive --depth option valueAndrés G. Aragoneses, Nov 18, 2013
  5. Junio C HamanoNov 19, 2013
  6. [PATCHv3] transport: Catch non positive --depth option valueAndrés G. Aragoneses, Nov 21, 2013
  7. Junio C HamanoNov 21, 2013
  8. Junio C HamanoNov 21, 2013
  9. Duy NguyenNov 22, 2013
  10. Andrés G. AragonesesNov 25, 2013
  11. Duy NguyenNov 26, 2013
  12. Andrés G. AragonesesNov 26, 2013
  13. Duy NguyenNov 26, 2013
  14. [PATCHv4] transport: Catch non positive --depth option valueAndrés G. Aragoneses, Nov 26, 2013
  15. Jonathan NiederNov 26, 2013
  16. Junio C HamanoNov 26, 2013

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.