From: "Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Elijah Newren <newren@gmail.com>, Elijah Newren <newren@gmail.com>
Subject: [PATCH 1/2] upload-pack: fix ambiguous error message
Date: Mon, 04 Nov 2024 19:02:43 +0000 [thread overview]
Message-ID: <bb8dbc5c7086ce5c09f8980c923ec85da38c9147.1730746964.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.1822.git.1730746964.gitgitgadget@gmail.com>
From: Elijah Newren <newren@gmail.com>
upload-pack.c takes any --shallow-exclude argument(s) from
clone/fetch/etc. and passes them through expand_ref(). If it does not
get back exactly one ref from the call to expand_ref(), it will die with
the following error:
fatal: git upload-pack: ambiguous deepen-not: %s
Given that the documentation suggests to users that --shallow-exclude
accepts a revision rather than a ref (which will be corrected in a
subsequent commit), users may try to pass a revision. In such a case,
expand_ref() will return 0 matches, but the error message we print will
be misleading since "ambiguous" suggests there are multiple matches.
Provide a clearer error message for such a case.
Signed-off-by: Elijah Newren <newren@gmail.com>
---
t/t5500-fetch-pack.sh | 7 +++++++
upload-pack.c | 6 +++++-
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh
index 8da8e7fe423..6552da78d19 100755
--- a/t/t5500-fetch-pack.sh
+++ b/t/t5500-fetch-pack.sh
@@ -926,6 +926,13 @@ test_expect_success 'fetch exclude tag one' '
test_cmp expected actual
'
+test_expect_success 'fetch exclude tag one as revision' '
+ test_when_finished rm -f rev err &&
+ git -C shallow-exclude rev-parse one >rev &&
+ test_must_fail git -C shallow12 fetch --shallow-exclude $(cat rev) origin 2>err &&
+ grep "deepen-not is not a ref:" err
+'
+
test_expect_success 'fetching deepen' '
test_create_repo shallow-deepen &&
(
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);
oidset_insert(deepen_not, &oid);
free(ref);
*deepen_rev_list = 1;
--
gitgitgadget
next prev parent reply other threads:[~2024-11-04 19:02 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-04 19:02 [PATCH 0/2] A few --shallow-exclude fixes Elijah Newren via GitGitGadget
2024-11-04 19:02 ` Elijah Newren via GitGitGadget [this message]
2024-11-05 6:27 ` [PATCH 1/2] upload-pack: fix ambiguous error message Patrick Steinhardt
2024-11-04 19:02 ` [PATCH 2/2] doc: correct misleading descriptions for --shallow-exclude Elijah Newren via GitGitGadget
2024-11-05 6:27 ` Patrick Steinhardt
2024-11-05 6:55 ` Junio C Hamano
2024-11-05 1:27 ` [PATCH 0/2] A few --shallow-exclude fixes Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bb8dbc5c7086ce5c09f8980c923ec85da38c9147.1730746964.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=git@vger.kernel.org \
--cc=newren@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).