rerere.c: use error_errno() and warning_errno()
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
May 8, 2016 at 16:47 UTC
033e011e64052e61e03b4d4cec06c7445ed36e7f
1 file changed
+7
-11
rerere.c
+7
-11
@@ -351,8 +351,7 @@ static int handle_file(const char *path, unsigned char *sha1, const char *output
351
error("There were errors while writing %s (%s)",
352
path, strerror(io.io.wrerror));
353
if (io.io.output && fclose(io.io.output))
354
- io.io.wrerror = error("Failed to flush %s: %s",
355
- path, strerror(errno));
354
+ io.io.wrerror = error_errno("Failed to flush %s", path);
355
356
if (hunk_no < 0) {
357
if (output)
@@ -614,20 +613,17 @@ static int merge(const struct rerere_id *id, const char *path)
613
* Mark that "postimage" was used to help gc.
614
*/
615
if (utime(rerere_path(id, "postimage"), NULL) < 0)
617
- warning("failed utime() on %s: %s",
618
- rerere_path(id, "postimage"),
619
- strerror(errno));
616
+ warning_errno("failed utime() on %s",
617
+ rerere_path(id, "postimage"));
618
619
/* Update "path" with the resolution */
620
f = fopen(path, "w");
621
if (!f)
624
- return error("Could not open %s: %s", path,
625
- strerror(errno));
622
+ return error_errno("Could not open %s", path);
623
if (fwrite(result.ptr, result.size, 1, f) != 1)
627
- error("Could not write %s: %s", path, strerror(errno));
624
+ error_errno("Could not write %s", path);
625
if (fclose(f))
629
- return error("Writing %s failed: %s", path,
630
- strerror(errno));
626
+ return error_errno("Writing %s failed", path);
627
628
out:
629
free(cur.ptr);
@@ -842,7 +838,7 @@ static int rerere_forget_one_path(const char *path, struct string_list *rr)
838
if (unlink(filename))
839
return (errno == ENOENT
840
? error("no remembered resolution for %s", path)
845
- : error("cannot unlink %s: %s", filename, strerror(errno)));
841
+ : error_errno("cannot unlink %s", filename));
842
843
/*
844
* Update the preimage so that the user can resolve the