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

Re: [PATCH 1/2] upload-pack: fix ambiguous error message

From
Patrick Steinhardt <ps@pks.im>
Date
Nov 5, 2024, 06:27 UTC
Message-ID
<Zym65pRWPqu9VIvq@pks.im>
In-Reply-To
<bb8dbc5c7086ce5c09f8980c923ec85da38c9147.1730746964.git.gitgitgadget@gmail.com>
On Mon, Nov 04, 2024 at 07:02:43PM +0000, Elijah Newren via GitGitGadget wrote:
Show 17 quoted lines
> diff --git a/upload-pack.c b/upload-pack.c
> index 6d6e0f9f980..640d45295e1 100644
> --- a/upload-pack.c
> +++ b/upload-pack.c
> @@ -1025,10 +1025,14 @@ static int process_deepen_not(const char *line, struct oidset *deepen_not, int *
>  {
>  	const char *arg;
>  	if (skip_prefix(line, "deepen-not ", &arg)) {
> +		int cnt;
>  		char *ref = NULL;
>  		struct object_id oid;
> -		if (expand_ref(the_repository, arg, strlen(arg), &oid, &ref) != 1)
> +		cnt = expand_ref(the_repository, arg, strlen(arg), &oid, &ref);
> +		if (cnt > 1)
>  			die("git upload-pack: ambiguous deepen-not: %s", line);
> +		if (cnt < 1)
> +			die("git upload-pack: deepen-not is not a ref: %s", line);

I was wondering whether `expand_ref()` could ever return negative, but after reading through its implementation that doesn't seem to be the case. It's somewhat misleading that it returns `int`, as `size_t` would convey the return value in a better spirit.

Anyway, that is not an issue of this patch series, and the change looks good.

Patrick
Previous: Elijah Newren via GitGitGadgetNext: Elijah Newren via GitGitGadget
Message 3 of 7 in “A few --shallow-exclude fixes”
  1. 0/2 A few --shallow-exclude fixesElijah Newren via GitGitGadget, Nov 4, 2024
  2. 1/2 upload-pack: fix ambiguous error messageElijah Newren via GitGitGadget, Nov 4, 2024
  3. Patrick SteinhardtNov 5, 2024
  4. 2/2 doc: correct misleading descriptions for --shallow-excludeElijah Newren via GitGitGadget, Nov 4, 2024
  5. Patrick SteinhardtNov 5, 2024
  6. Junio C HamanoNov 5, 2024
  7. Junio C HamanoNov 5, 2024

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.