Skip to content

Commit 033e011

Browse files
pcloudsgitster
authored andcommitted
rerere.c: use error_errno() and warning_errno()
Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9a3acba commit 033e011

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

rerere.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,7 @@ static int handle_file(const char *path, unsigned char *sha1, const char *output
351351
error("There were errors while writing %s (%s)",
352352
path, strerror(io.io.wrerror));
353353
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);
356355

357356
if (hunk_no < 0) {
358357
if (output)
@@ -614,20 +613,17 @@ static int merge(const struct rerere_id *id, const char *path)
614613
* Mark that "postimage" was used to help gc.
615614
*/
616615
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"));
620618

621619
/* Update "path" with the resolution */
622620
f = fopen(path, "w");
623621
if (!f)
624-
return error("Could not open %s: %s", path,
625-
strerror(errno));
622+
return error_errno("Could not open %s", path);
626623
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);
628625
if (fclose(f))
629-
return error("Writing %s failed: %s", path,
630-
strerror(errno));
626+
return error_errno("Writing %s failed", path);
631627

632628
out:
633629
free(cur.ptr);
@@ -842,7 +838,7 @@ static int rerere_forget_one_path(const char *path, struct string_list *rr)
842838
if (unlink(filename))
843839
return (errno == ENOENT
844840
? error("no remembered resolution for %s", path)
845-
: error("cannot unlink %s: %s", filename, strerror(errno)));
841+
: error_errno("cannot unlink %s", filename));
846842

847843
/*
848844
* Update the preimage so that the user can resolve the

0 commit comments

Comments
 (0)