Skip to content

Commit 90875ec

Browse files
chriscoolgitster
authored andcommitted
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>
1 parent 9123d5d commit 90875ec

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

apply.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3497,7 +3497,7 @@ static int load_current(struct apply_state *state,
34973497
ce = active_cache[pos];
34983498
if (lstat(name, &st)) {
34993499
if (errno != ENOENT)
3500-
return error(_("%s: %s"), name, strerror(errno));
3500+
return error_errno("%s", name);
35013501
if (checkout_target(&the_index, ce, &st))
35023502
return -1;
35033503
}
@@ -3647,7 +3647,7 @@ static int check_preimage(struct apply_state *state,
36473647
} else if (!state->cached) {
36483648
stat_ret = lstat(old_name, st);
36493649
if (stat_ret && errno != ENOENT)
3650-
return error(_("%s: %s"), old_name, strerror(errno));
3650+
return error_errno("%s", old_name);
36513651
}
36523652

36533653
if (state->check_index && !previous) {
@@ -3669,7 +3669,7 @@ static int check_preimage(struct apply_state *state,
36693669
} else if (stat_ret < 0) {
36703670
if (patch->is_new < 0)
36713671
goto is_new;
3672-
return error(_("%s: %s"), old_name, strerror(errno));
3672+
return error_errno("%s", old_name);
36733673
}
36743674

36753675
if (!state->cached && !previous)
@@ -3728,7 +3728,7 @@ static int check_to_create(struct apply_state *state,
37283728

37293729
return EXISTS_IN_WORKTREE;
37303730
} else if ((errno != ENOENT) && (errno != ENOTDIR)) {
3731-
return error("%s: %s", new_name, strerror(errno));
3731+
return error_errno("%s", new_name);
37323732
}
37333733
return 0;
37343734
}
@@ -4247,9 +4247,9 @@ static int add_index_file(struct apply_state *state,
42474247
if (!state->cached) {
42484248
if (lstat(path, &st) < 0) {
42494249
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);
42534253
}
42544254
fill_stat_cache_info(ce, &st);
42554255
}
@@ -4503,7 +4503,7 @@ static int write_out_one_reject(struct apply_state *state, struct patch *patch)
45034503

45044504
rej = fopen(namebuf, "w");
45054505
if (!rej)
4506-
return error(_("cannot open %s: %s"), namebuf, strerror(errno));
4506+
return error_errno(_("cannot open %s"), namebuf);
45074507

45084508
/* Normal git tools never deal with .rej, so do not pretend
45094509
* this is a git patch by saying --git or giving extended

0 commit comments

Comments
 (0)