summaryrefslogtreecommitdiffstats
path: root/upload-pack.c
diff options
context:
space:
mode:
authorElijah Newren <newren@gmail.com>2024-11-04 20:02:43 +0100
committerJunio C Hamano <gitster@pobox.com>2024-11-05 02:20:21 +0100
commit5a875ff7fbd4b8edd99b339c7c9eaa0650b7b195 (patch)
tree133b8f614e5a9552aaa723c4a649e2d12060fbe6 /upload-pack.c
parentThe seventh batch (diff)
downloadgit-5a875ff7fbd4b8edd99b339c7c9eaa0650b7b195.tar.xz
git-5a875ff7fbd4b8edd99b339c7c9eaa0650b7b195.zip
upload-pack: fix ambiguous error message
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to '')
-rw-r--r--upload-pack.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/upload-pack.c b/upload-pack.c
index 6d6e0f9f98..640d45295e 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;