Skip to content

Commit 4e61e0f

Browse files
phillipwoodgitster
authored andcommitted
diff --no-index: die on error reading stdin
If there is an error when reading from stdin then "diff --no-index" prints an error message but continues to try and diff a file named "-" resulting in an error message that looks like error: error while reading from stdin: Invalid argument fatal: stat '-': No such file or directory assuming that no file named "-" exists. If such a file exists it prints the first error message and generates the diff from that file which is not what the user wanted. Instead just die() straight away if we cannot read from stdin. Signed-off-by: Phillip Wood <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4981984 commit 4e61e0f

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

diff-no-index.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,19 @@ static int get_mode(const char *path, int *mode)
6060
return 0;
6161
}
6262

63-
static int populate_from_stdin(struct diff_filespec *s)
63+
static void populate_from_stdin(struct diff_filespec *s)
6464
{
6565
struct strbuf buf = STRBUF_INIT;
6666
size_t size = 0;
6767

6868
if (strbuf_read(&buf, 0, 0) < 0)
69-
return error_errno("error while reading from stdin");
69+
die_errno("error while reading from stdin");
7070

7171
s->should_munmap = 0;
7272
s->data = strbuf_detach(&buf, &size);
7373
s->size = size;
7474
s->should_free = 1;
7575
s->is_stdin = 1;
76-
return 0;
7776
}
7877

7978
static struct diff_filespec *noindex_filespec(const char *name, int mode)

0 commit comments

Comments
 (0)