apply: use error_errno() where possible

To avoid possible mistakes and to uniformly show the errno related messages, let's use error_errno() where possible. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Christian Couder committed Sep 4, 2016 at 22:18 UTC 90875eca5a0b227e6a1be3ccece0a3da5e72017f
1 file changed +8 -8
apply.c
+8 -8
@@ -3497,7 +3497,7 @@ static int load_current(struct apply_state *state,
3497 ce = active_cache[pos];
3498 if (lstat(name, &st)) {
3499 if (errno != ENOENT)
3500 - return error(_("%s: %s"), name, strerror(errno));
3500 + return error_errno("%s", name);
3501 if (checkout_target(&the_index, ce, &st))
3502 return -1;
3503 }
@@ -3647,7 +3647,7 @@ static int check_preimage(struct apply_state *state,
3647 } else if (!state->cached) {
3648 stat_ret = lstat(old_name, st);
3649 if (stat_ret && errno != ENOENT)
3650 - return error(_("%s: %s"), old_name, strerror(errno));
3650 + return error_errno("%s", old_name);
3651 }
3652
3653 if (state->check_index && !previous) {
@@ -3669,7 +3669,7 @@ static int check_preimage(struct apply_state *state,
3669 } else if (stat_ret < 0) {
3670 if (patch->is_new < 0)
3671 goto is_new;
3672 - return error(_("%s: %s"), old_name, strerror(errno));
3672 + return error_errno("%s", old_name);
3673 }
3674
3675 if (!state->cached && !previous)
@@ -3728,7 +3728,7 @@ static int check_to_create(struct apply_state *state,
3728
3729 return EXISTS_IN_WORKTREE;
3730 } else if ((errno != ENOENT) && (errno != ENOTDIR)) {
3731 - return error("%s: %s", new_name, strerror(errno));
3731 + return error_errno("%s", new_name);
3732 }
3733 return 0;
3734 }
@@ -4247,9 +4247,9 @@ static int add_index_file(struct apply_state *state,
4247 if (!state->cached) {
4248 if (lstat(path, &st) < 0) {
4249 free(ce);
4250 - return error(_("unable to stat newly "
4251 - "created file '%s': %s"),
4252 - path, strerror(errno));
4250 + return error_errno(_("unable to stat newly "
4251 + "created file '%s'"),
4252 + path);
4253 }
4254 fill_stat_cache_info(ce, &st);
4255 }
@@ -4503,7 +4503,7 @@ static int write_out_one_reject(struct apply_state *state, struct patch *patch)
4503
4504 rej = fopen(namebuf, "w");
4505 if (!rej)
4506 - return error(_("cannot open %s: %s"), namebuf, strerror(errno));
4506 + return error_errno(_("cannot open %s"), namebuf);
4507
4508 /* Normal git tools never deal with .rej, so do not pretend
4509 * this is a git patch by saying --git or giving extended