From: Junio C Hamano <gitster@pobox.com>
To: Dmitry Potapov <dpotapov@gmail.com>
Cc: Pierre Habouzit <madcoder@debian.org>, Git ML <git@vger.kernel.org>
Subject: Re: [PATCH] git-clean: correct printing relative path
Date: Thu, 06 Mar 2008 14:54:37 -0800 [thread overview]
Message-ID: <7vwsof8nv6.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <20080305234124.GD11519@dpotapov.dyndns.org> (Dmitry Potapov's message of "Thu, 6 Mar 2008 02:41:24 +0300")
Dmitry Potapov <dpotapov@gmail.com> writes:
> In addition, when I ran 'git clean -n ..' at the top a repository, the
> current master version of Git though printed the error that '..' is
> outside the repository, still exited with 0. When I test this with
> 1.5.4, git clean exists with 128 after printing the error. Bisect blames
> d089ebaad5315325d67db30176df1bbd7754fda9 for changing the exit code to 0.
You need a change similar to the one that updates builtin-ls-files.c in
d089eba (setup: sanitize absolute and funny paths in get_pathspec()). The
commit should have adjusted builtin-clean.c but was overlooked.
When you give a set of paths that includes bogus ones, get_pathspec()
issues an error message and gives back a pathspec that does not contain
the entries corresponding to the bogus ones, and that is an indication for
a caller that wants to refuse to operate upon bogus input. Other callers
that want to issue an error diagnosis and handle the remaining valid input
do not have to die, but "git-clean" is destructive so it would be sensible
to error out the whole operation if you see the user input was bogus.
commit d089ebaad5315325d67db30176df1bbd7754fda9
Author: Junio C Hamano <gitster@pobox.com>
setup: sanitize absolute and funny paths in get_pathspec()
diff --git a/builtin-ls-files.c b/builtin-ls-files.c
index 0f0ab2d..3801cf4 100644
--- a/builtin-ls-files.c
+++ b/builtin-ls-files.c
@@ -572,8 +572,17 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)
pathspec = get_pathspec(prefix, argv + i);
/* Verify that the pathspec matches the prefix */
- if (pathspec)
+ if (pathspec) {
+ if (argc != i) {
+ int cnt;
+ for (cnt = 0; pathspec[cnt]; cnt++)
+ ;
+ if (cnt != (argc - i))
+ exit(1); /* error message already given */
+ }
prefix = verify_pathspec(prefix);
+ } else if (argc != i)
+ exit(1); /* error message already given */
/* Treat unmatching pathspec elements as errors */
if (pathspec && error_unmatch) {
prev parent reply other threads:[~2008-03-06 22:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-05 9:40 [bug] git-clean Pierre Habouzit
2008-03-05 13:47 ` [PATCH] git-clean: correct printing relative path Dmitry Potapov
2008-03-05 14:17 ` Dmitry Potapov
2008-03-05 15:53 ` Pierre Habouzit
2008-03-05 15:59 ` Pierre Habouzit
2008-03-05 23:41 ` Dmitry Potapov
2008-03-06 22:54 ` Junio C Hamano [this message]
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=7vwsof8nv6.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=dpotapov@gmail.com \
--cc=git@vger.kernel.org \
--cc=madcoder@debian.org \
/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).