From: Junio C Hamano <gitster@pobox.com>
To: Johannes Schindelin <johannes.schindelin@gmx.de>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 2/2] reset: support the --stdin option
Date: Tue, 11 Oct 2016 10:53:52 -0700 [thread overview]
Message-ID: <xmqqeg3mai1b.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <2c7a52e43be710c7f37c4886629bda38df183c21.1476202100.git.johannes.schindelin@gmx.de> (Johannes Schindelin's message of "Tue, 11 Oct 2016 18:09:11 +0200 (CEST)")
Johannes Schindelin <johannes.schindelin@gmx.de> writes:
> + if (read_from_stdin) {
> + strbuf_getline_fn getline_fn = nul_term_line ?
> + strbuf_getline_nul : strbuf_getline_lf;
> + int flags = PATHSPEC_PREFER_FULL |
> + PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP;
> + struct strbuf buf = STRBUF_INIT;
> + struct strbuf unquoted = STRBUF_INIT;
> +
> + if (patch_mode)
> + die(_("--stdin is incompatible with --patch"));
> +
> + if (pathspec.nr)
> + die(_("--stdin is incompatible with path arguments"));
> +
> + if (patch_mode)
> + flags |= PATHSPEC_PREFIX_ORIGIN;
Didn't we already die above under that mode?
> + while (getline_fn(&buf, stdin) != EOF) {
> + if (!nul_term_line && buf.buf[0] == '"') {
> + strbuf_reset(&unquoted);
> + if (unquote_c_style(&unquoted, buf.buf, NULL))
> + die(_("line is badly quoted"));
> + strbuf_swap(&buf, &unquoted);
> + }
> + ALLOC_GROW(stdin_paths, stdin_nr + 1, stdin_alloc);
> + stdin_paths[stdin_nr++] = xstrdup(buf.buf);
> + strbuf_reset(&buf);
> + }
> + strbuf_release(&unquoted);
> + strbuf_release(&buf);
> +
> + ALLOC_GROW(stdin_paths, stdin_nr + 1, stdin_alloc);
> + stdin_paths[stdin_nr++] = NULL;
It makes sense to collect, but...
> + parse_pathspec(&pathspec, 0, flags, prefix,
> + (const char **)stdin_paths);
...letting them be used as if they are pathspec is wrong when
stdin_paths[] contain wildcard, isn't it?
I think flags |= PATHSPEC_LITERAL_PATH can help fixing it. 0/2 said
this mimicks checkout-index and I think it should by not treating
the input as wildcarded patterns (i.e. "echo '*.c' | reset --stdin"
shouldn't be the way to reset all .c files --- that's something we
would want to add to the test, I guess).
Thanks.
next prev parent reply other threads:[~2016-10-11 17:56 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-11 16:08 [PATCH 0/2] Support `git reset --stdin` Johannes Schindelin
2016-10-11 16:09 ` [PATCH 1/2] reset: fix usage Johannes Schindelin
2016-10-11 16:09 ` [PATCH 2/2] reset: support the --stdin option Johannes Schindelin
2016-10-11 17:53 ` Junio C Hamano [this message]
2016-10-12 12:57 ` Johannes Schindelin
2016-10-11 20:49 ` Jakub Narębski
2016-10-12 12:39 ` Johannes Schindelin
2016-10-11 18:34 ` [PATCH 0/2] Support `git reset --stdin` Jeff King
2016-10-11 19:27 ` Junio C Hamano
2016-10-11 21:26 ` Jeff King
2016-10-11 21:36 ` Junio C Hamano
2016-10-11 21:47 ` Jeff King
2016-10-11 21:49 ` Junio C Hamano
2017-01-27 12:38 ` [PATCH v2 0/1] " Johannes Schindelin
2017-01-27 12:38 ` [PATCH v2 1/1] reset: support the --stdin option Johannes Schindelin
2017-01-27 17:04 ` Jeff King
2017-01-27 17:34 ` Johannes Schindelin
2017-01-27 17:54 ` Jeff King
2017-01-27 18:30 ` Junio C Hamano
2017-01-27 22:12 ` Jeff King
2017-01-28 0:20 ` Junio C Hamano
2017-01-27 17:30 ` [PATCH v3 0/1] Support `git reset --stdin` Johannes Schindelin
2017-01-27 17:30 ` [PATCH v3 1/1] reset: support the --stdin option Johannes Schindelin
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqeg3mai1b.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=johannes.schindelin@gmx.de \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).