This feature was missing, and made it cumbersome for third-party tools to reset a lot of paths in one go. Support for --stdin has been added, following builtin/checkout-index.c's example. Changes since v1: - adjusted commit message to explain why we read everything before resetting - fixed synopsis (`--stdin` does not work with `-- <path>...`) - avoid handling patch_mode twice - use PATHSPEC_LITERAL_PATH to avoid interpreting input as wildcards Johannes Schindelin (1): reset: support the --stdin option Documentation/git-reset.txt | 9 ++++++++ builtin/reset.c | 54 ++++++++++++++++++++++++++++++++++++++++++++- t/t7107-reset-stdin.sh | 33 +++++++++++++++++++++++++++ 3 files changed, 95 insertions(+), 1 deletion(-) create mode 100755 t/t7107-reset-stdin.sh base-commit: 4e59582ff70d299f5a88449891e78d15b4b3fabe Published-As: https://github.com/dscho/git/releases/tag/reset-stdin-v2 Fetch-It-Via: git fetch https://github.com/dscho/git reset-stdin-v2 Interdiff vs v1: diff --git a/Documentation/git-reset.txt b/Documentation/git-reset.txt index 533ef69f91..abb71bb805 100644 --- a/Documentation/git-reset.txt +++ b/Documentation/git-reset.txt @@ -8,8 +8,9 @@ git-reset - Reset current HEAD to the specified state SYNOPSIS -------- [verse] -'git reset' [-q] [--stdin [-z]] [<tree-ish>] [--] <paths>... +'git reset' [-q] [<tree-ish>] [--] <paths>... 'git reset' (--patch | -p) [<tree-ish>] [--] [<paths>...] +'git reset' [-q] [--stdin [-z]] [<tree-ish>] 'git reset' [--soft | --mixed [-N] | --hard | --merge | --keep] [-q] [<commit>] DESCRIPTION diff --git a/builtin/reset.c b/builtin/reset.c index 6de3936aed..1d3075b7ee 100644 --- a/builtin/reset.c +++ b/builtin/reset.c @@ -26,7 +26,8 @@ static const char * const git_reset_usage[] = { N_("git reset [--mixed | --soft | --hard | --merge | --keep] [-q] [<commit>]"), - N_("git reset [-q] [--stdin [-z]] [<tree-ish>] [--] <paths>..."), + N_("git reset [-q] [<tree-ish>] [--] <paths>..."), + N_("git reset [-q] [--stdin [-z]] [<tree-ish>]"), N_("git reset --patch [<tree-ish>] [--] [<paths>...]"), NULL }; @@ -317,9 +318,6 @@ int cmd_reset(int argc, const char **argv, const char *prefix) if (pathspec.nr) die(_("--stdin is incompatible with path arguments")); - if (patch_mode) - flags |= PATHSPEC_PREFIX_ORIGIN; - while (getline_fn(&buf, stdin) != EOF) { if (!nul_term_line && buf.buf[0] == '"') { strbuf_reset(&unquoted); @@ -336,8 +334,10 @@ int cmd_reset(int argc, const char **argv, const char *prefix) ALLOC_GROW(stdin_paths, stdin_nr + 1, stdin_alloc); stdin_paths[stdin_nr++] = NULL; + flags |= PATHSPEC_LITERAL_PATH; parse_pathspec(&pathspec, 0, flags, prefix, (const char **)stdin_paths); + } else if (nul_term_line) die(_("-z requires --stdin")); -- 2.11.1.windows.prerelease.2.9.g3014b57