diff options
author | Junio C Hamano <gitster@pobox.com> | 2012-07-22 13:01:22 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2012-07-22 13:01:23 -0700 |
commit | 106ef55f3a303435519ac60a043755286f9e47f8 (patch) | |
tree | b73df4ebbb14d4e5e3ed311748865118213e8749 /diff.c | |
parent | 07873ca7b02a06d3f5a9db47333062aff6f18047 (diff) | |
parent | 4682d8521c3ce9d722bd214fd7d5fc92063fdacb (diff) | |
download | git-106ef55f3a303435519ac60a043755286f9e47f8.tar.gz |
Merge branch 'jc/refactor-diff-stdin' into maint
"git diff", "git status" and anything that internally uses the
comparison machinery was utterly broken when the difference
involved a file with "-" as its name. This was due to the way "git
diff --no-index" was incorrectly bolted on to the system, making
any comparison that involves a file "-" at the root level
incorrectly read from the standard input.
* jc/refactor-diff-stdin:
diff-index.c: "git diff" has no need to read blob from the standard input
diff-index.c: unify handling of command line paths
diff-index.c: do not pretend paths are pathspecs
Diffstat (limited to 'diff.c')
-rw-r--r-- | diff.c | 21 |
1 files changed, 1 insertions, 20 deletions
@@ -2619,22 +2619,6 @@ static int reuse_worktree_file(const char *name, const unsigned char *sha1, int return 0; } -static int populate_from_stdin(struct diff_filespec *s) -{ - struct strbuf buf = STRBUF_INIT; - size_t size = 0; - - if (strbuf_read(&buf, 0, 0) < 0) - return error("error while reading from stdin %s", - strerror(errno)); - - s->should_munmap = 0; - s->data = strbuf_detach(&buf, &size); - s->size = size; - s->should_free = 1; - return 0; -} - static int diff_populate_gitlink(struct diff_filespec *s, int size_only) { int len; @@ -2684,9 +2668,6 @@ int diff_populate_filespec(struct diff_filespec *s, int size_only) struct stat st; int fd; - if (!strcmp(s->path, "-")) - return populate_from_stdin(s); - if (lstat(s->path, &st) < 0) { if (errno == ENOENT) { err_empty: @@ -3048,7 +3029,7 @@ static void diff_fill_sha1_info(struct diff_filespec *one) if (DIFF_FILE_VALID(one)) { if (!one->sha1_valid) { struct stat st; - if (!strcmp(one->path, "-")) { + if (one->is_stdin) { hashcpy(one->sha1, null_sha1); return; } |