return git_default_config(var, value, cb);
}
-static int option_parse_stdin(const struct option *opt,
- const char *arg, int unset)
-{
- int *errs = opt->value;
-
- *errs |= apply_patch(0, "<stdin>", options);
- read_stdin = 0;
- return 0;
-}
-
static int option_parse_exclude(const struct option *opt,
const char *arg, int unset)
{
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 },
const char *arg = argv[i];
int fd;
- if (0 < prefix_length)
+ if (!strcmp(arg, "-")) {
+ errs |= apply_patch(0, "<stdin>", options);
+ read_stdin = 0;
+ continue;
+ } else if (0 < prefix_length)
arg = prefix_filename(prefix, prefix_length, arg);
fd = open(arg, O_RDONLY);
--- /dev/null
+#!/bin/sh
+
+test_description='git apply --numstat - <patch'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+ echo hello >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 - <patch >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