From: Junio C Hamano Date: Tue, 10 May 2011 05:51:11 GMT Subject: [PATCH 2/9] get_pathspec(): an empty ':' pathspec should stand alone Message-ID: <1305006678-4051-3-git-send-email-gitster@pobox.com> In-Reply-To: <1305006678-4051-1-git-send-email-gitster@pobox.com> "git cmd foo :" is a user error; diagnose it as such. Signed-off-by: Junio C Hamano --- setup.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/setup.c b/setup.c index 51e354c..c1be388 100644 --- a/setup.c +++ b/setup.c @@ -256,6 +256,7 @@ const char **get_pathspec(const char *prefix, const char **pathspec) const char *entry = *pathspec; const char **src, **dst; int prefixlen; + int has_root_widen = 0; if (!prefix && !entry) return NULL; @@ -272,10 +273,15 @@ const char **get_pathspec(const char *prefix, const char **pathspec) dst = pathspec; prefixlen = prefix ? strlen(prefix) : 0; while (*src) { - *(dst++) = prefix_pathspec(prefix, prefixlen, *src); + const char *elem = prefix_pathspec(prefix, prefixlen, *src); + *(dst++) = elem; + if (!elem) + has_root_widen = 1; src++; } *dst = NULL; + if (has_root_widen && src != pathspec + 1) + die("an empty ':' pathspec with other pathspecs"); if (!*pathspec) return NULL; return pathspec; -- 1.7.5.1.290.g1b565