print errno when reporting a system call error
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Wed, 3 May 2017 10:16:55 +0000 (17:16 +0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 26 May 2017 03:33:56 +0000 (12:33 +0900)
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/log.c
rerere.c
xdiff-interface.c
index b3b10cc1edba2f6d77fdf4b12c328a7968fb5499..26d6a3cf1415c632da6d416777302534c5c63ac3 100644 (file)
@@ -858,7 +858,8 @@ static int open_next_file(struct commit *commit, const char *subject,
                printf("%s\n", filename.buf + outdir_offset);
 
        if ((rev->diffopt.file = fopen(filename.buf, "w")) == NULL)
-               return error(_("Cannot open patch file %s"), filename.buf);
+               return error_errno(_("Cannot open patch file %s"),
+                                  filename.buf);
 
        strbuf_release(&filename);
        return 0;
index 971bfedfb214f4d99eca4a8de167625a9272c1e4..1351b0c3fbd47e9f6e913e586081a7317670f807 100644 (file)
--- a/rerere.c
+++ b/rerere.c
@@ -484,13 +484,13 @@ static int handle_file(const char *path, unsigned char *sha1, const char *output
        io.input = fopen(path, "r");
        io.io.wrerror = 0;
        if (!io.input)
-               return error("Could not open %s", path);
+               return error_errno("Could not open %s", path);
 
        if (output) {
                io.io.output = fopen(output, "w");
                if (!io.io.output) {
                        fclose(io.input);
-                       return error("Could not write %s", output);
+                       return error_errno("Could not write %s", output);
                }
        }
 
index 060038c2d6b92512e6625d0f5d94ed5439cd249c..d3f78ca2a718d3e4928aa90067e24d19988514c1 100644 (file)
@@ -164,9 +164,9 @@ int read_mmfile(mmfile_t *ptr, const char *filename)
        size_t sz;
 
        if (stat(filename, &st))
-               return error("Could not stat %s", filename);
+               return error_errno("Could not stat %s", filename);
        if ((f = fopen(filename, "rb")) == NULL)
-               return error("Could not open %s", filename);
+               return error_errno("Could not open %s", filename);
        sz = xsize_t(st.st_size);
        ptr->ptr = xmalloc(sz ? sz : 1);
        if (sz && fread(ptr->ptr, sz, 1, f) != 1) {