From: Junio C Hamano Date: Sat, 10 Jan 2009 06:15:59 GMT Subject: Re: What's cooking in git.git (Jan 2009, #01; Mon, 05) Message-ID: <7vr63by9cw.fsf@gitster.siamese.dyndns.org> In-Reply-To: <2c6b72b30901092015l2405627aqf928e43c12eabc3c@mail.gmail.com> "Jonas Fonseca" writes: > On Tue, Jan 6, 2009 at 01:33, Junio C Hamano wrote: >> ---------------------------------------------------------------- >> * mv/apply-parse-opt (Sun Dec 28 00:03:57 2008 +0100) 1 commit >> + parse-opt: migrate builtin-apply. > > This broke apply for me after updating to the current "next" earlier > today. When requesting that the patch be read from stdin I get the > following error message: > > > git diff | git apply -R - > fatal: can't open patch '-': No such file or directory Thanks. I think this patch would fix it. Because the original option parser was incremental and immediate with respect to "-", we used to be able to say: $ git apply -p - --stat patch2.txt value; - - *errs |= apply_patch(0, "", options); - read_stdin = 0; - return 0; -} - static int option_parse_exclude(const struct option *opt, const char *arg, int unset) { @@ -3218,9 +3208,6 @@ int cmd_apply(int argc, const char **argv, const char *unused_prefix) const char *whitespace_option = NULL; struct option builtin_apply_options[] = { - { OPTION_CALLBACK, '-', NULL, &errs, NULL, - "read the patch from the standard input", - PARSE_OPT_NOARG, option_parse_stdin }, { OPTION_CALLBACK, 0, "exclude", NULL, "path", "don“t apply changes matching the given path", 0, option_parse_exclude }, @@ -3302,7 +3289,11 @@ int cmd_apply(int argc, const char **argv, const char *unused_prefix) const char *arg = argv[i]; int fd; - if (0 < prefix_length) + if (!strcmp(arg, "-")) { + errs |= apply_patch(0, "", options); + read_stdin = 0; + continue; + } else if (0 < prefix_length) arg = prefix_filename(prefix, prefix_length, arg); fd = open(arg, O_RDONLY); diff --git c/t/t4106-apply-stdin.sh w/t/t4106-apply-stdin.sh new file mode 100755 index 0000000..72467a1 --- /dev/null +++ w/t/t4106-apply-stdin.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +test_description='git apply --numstat - text && + git add text && + echo goodbye >text && + git diff >patch +' + +test_expect_success 'git apply --numstat - < patch' ' + echo "1 1 text" >expect && + git apply --numstat - actual && + test_cmp expect actual +' + +test_expect_success 'git apply --numstat - < patch patch' ' + for i in 1 2; do echo "1 1 text"; done >expect && + git apply --numstat - < patch patch >actual && + test_cmp expect actual +' + +test_done