Re: [PATCH] git-clean: correct printing relative path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dmitry Potapov <dpotapov@xxxxxxxxx> 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@xxxxxxxxx>

    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) {
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux