From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: Rusty Russell <rusty@rustcorp.com.au>,
git@vger.kernel.org, Joel Stanley <joel@jms.id.au>
Subject: Re: `git status -u no` suppresses modified files too.
Date: Sun, 03 Mar 2019 10:22:27 +0900 [thread overview]
Message-ID: <xmqqfts44ur0.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: 20190208024800.GA11392@sigill.intra.peff.net
Jeff King <peff@peff.net> writes:
> This is a pretty horrible UI trap. Most of the time with pathspecs we
> require them to be on the right-hand side of a "--" unless the paths
> actually exist in the filesystem. But then, in most of those cases we're
> making sure they're not ambiguous between revisions and paths. So maybe
> it's overkill here. I dunno. But the patch below certainly makes what's
> going on in your case less subtle:
>
> $ git status -u no
> fatal: no: no such path in the working tree.
> Use 'git <command> -- <path>...' to specify paths that do not exist locally.
Yeah. It was a mistake that we gave a short-and-sweet "-u" too
hastily to a relatively useless form that does not take any argument
and ended up needing to resort to the optional-arg trick.
> You do still have to figure out why it wasn't stuck to "-u", though.
Sorry, but I am not sure what you mean by this comment.
Your illustration patch lets you say "no, 'no' is not a pathspec"
with
git status -u no --
and "I want the unadorned -u and am asking about stuff in the 'no'
subdirectory" with
git status -u -- no
but in the former, it would not make 'no' an arg to '-u' by saying
"'no' is not a pathspec", would it?
> ---
> diff --git a/builtin/commit.c b/builtin/commit.c
> index 2986553d5f..7177d7d82f 100644
> --- a/builtin/commit.c
> +++ b/builtin/commit.c
> @@ -1300,6 +1300,16 @@ static int git_status_config(const char *k, const char *v, void *cb)
> return git_diff_ui_config(k, v, NULL);
> }
>
> +static void verify_pathspec(const char *prefix, const char **argv)
> +{
> + while (*argv) {
> + const char *arg = *argv++;
> + if (!strcmp(arg, "--"))
> + return;
> + verify_filename(prefix, arg, 0);
> + }
> +}
> +
> int cmd_status(int argc, const char **argv, const char *prefix)
> {
> static int no_renames = -1;
> @@ -1351,7 +1361,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
> status_init_config(&s, git_status_config);
> argc = parse_options(argc, argv, prefix,
> builtin_status_options,
> - builtin_status_usage, 0);
> + builtin_status_usage, PARSE_OPT_KEEP_DASHDASH);
> finalize_colopts(&s.colopts, -1);
> finalize_deferred_config(&s);
>
> @@ -1362,6 +1372,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
> s.show_untracked_files == SHOW_NO_UNTRACKED_FILES)
> die(_("Unsupported combination of ignored and untracked-files arguments"));
>
> + verify_pathspec(prefix, argv);
> parse_pathspec(&s.pathspec, 0,
> PATHSPEC_PREFER_FULL,
> prefix, argv);
prev parent reply other threads:[~2019-03-03 1:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-08 1:48 `git status -u no` suppresses modified files too Rusty Russell
2019-02-08 2:48 ` Jeff King
2019-02-23 4:05 ` Rusty Russell
2019-02-25 8:59 ` Duy Nguyen
2019-03-03 1:22 ` 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=xmqqfts44ur0.fsf@gitster-ct.c.googlers.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=joel@jms.id.au \
--cc=peff@peff.net \
--cc=rusty@rustcorp.com.au \
/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).