Skip to content

Commit 2c5942d

Browse files
committed
Merge branch 'ar/unlink-err' into maint
* ar/unlink-err: print unlink(2) errno in copy_or_link_directory replace direct calls to unlink(2) with unlink_or_warn Introduce an unlink(2) wrapper which gives warning if unlink failed
2 parents 43f8f56 + f6a5f1b commit 2c5942d

26 files changed

+68
-50
lines changed

builtin-apply.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2781,7 +2781,7 @@ static void remove_file(struct patch *patch, int rmdir_empty)
27812781
if (rmdir(patch->old_name))
27822782
warning("unable to remove submodule %s",
27832783
patch->old_name);
2784-
} else if (!unlink(patch->old_name) && rmdir_empty) {
2784+
} else if (!unlink_or_warn(patch->old_name) && rmdir_empty) {
27852785
remove_path(patch->old_name);
27862786
}
27872787
}
@@ -2891,7 +2891,7 @@ static void create_one_file(char *path, unsigned mode, const char *buf, unsigned
28912891
if (!try_create_file(newpath, mode, buf, size)) {
28922892
if (!rename(newpath, path))
28932893
return;
2894-
unlink(newpath);
2894+
unlink_or_warn(newpath);
28952895
break;
28962896
}
28972897
if (errno != EEXIST)

builtin-clone.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,8 @@ static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest)
228228
}
229229

230230
if (unlink(dest->buf) && errno != ENOENT)
231-
die("failed to unlink %s", dest->buf);
231+
die("failed to unlink %s: %s",
232+
dest->buf, strerror(errno));
232233
if (!option_no_hardlinks) {
233234
if (!link(src->buf, dest->buf))
234235
continue;

builtin-fetch-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ struct ref *fetch_pack(struct fetch_pack_args *my_args,
825825
fd = hold_lock_file_for_update(&lock, shallow,
826826
LOCK_DIE_ON_ERROR);
827827
if (!write_shallow_commits(fd, 0)) {
828-
unlink(shallow);
828+
unlink_or_warn(shallow);
829829
rollback_lock_file(&lock);
830830
} else {
831831
commit_lock_file(&lock);

builtin-prune-packed.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ static void prune_dir(int i, DIR *dir, char *pathname, int len, int opts)
2828
memcpy(pathname + len, de->d_name, 38);
2929
if (opts & DRY_RUN)
3030
printf("rm -f %s\n", pathname);
31-
else if (unlink(pathname) < 0)
32-
error("unable to unlink %s", pathname);
31+
else
32+
unlink_or_warn(pathname);
3333
display_progress(progress, i + 1);
3434
}
3535
pathname[len] = 0;

builtin-prune.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ static int prune_tmp_object(const char *path, const char *filename)
2727
}
2828
printf("Removing stale temporary file %s\n", fullpath);
2929
if (!show_only)
30-
unlink(fullpath);
30+
unlink_or_warn(fullpath);
3131
return 0;
3232
}
3333

@@ -47,7 +47,7 @@ static int prune_object(char *path, const char *filename, const unsigned char *s
4747
(type > 0) ? typename(type) : "unknown");
4848
}
4949
if (!show_only)
50-
unlink(fullpath);
50+
unlink_or_warn(fullpath);
5151
return 0;
5252
}
5353

builtin-receive-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
702702
unpack_status = unpack();
703703
execute_commands(unpack_status);
704704
if (pack_lockfile)
705-
unlink(pack_lockfile);
705+
unlink_or_warn(pack_lockfile);
706706
if (report_status)
707707
report(unpack_status);
708708
run_receive_hook(post_receive_hook);

builtin-remote.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,8 +525,8 @@ static int migrate_file(struct remote *remote)
525525
path = git_path("remotes/%s", remote->name);
526526
else if (remote->origin == REMOTE_BRANCHES)
527527
path = git_path("branches/%s", remote->name);
528-
if (path && unlink(path))
529-
warning("failed to remove '%s'", path);
528+
if (path)
529+
unlink_or_warn(path);
530530
return 0;
531531
}
532532

builtin-rerere.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ int cmd_rerere(int argc, const char **argv, const char *prefix)
116116
if (!has_rerere_resolution(name))
117117
unlink_rr_item(name);
118118
}
119-
unlink(git_path("rr-cache/MERGE_RR"));
119+
unlink_or_warn(git_path("rr-cache/MERGE_RR"));
120120
} else if (!strcmp(argv[1], "gc"))
121121
garbage_collect(&merge_rr);
122122
else if (!strcmp(argv[1], "status"))

builtin-tag.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ static void create_tag(const unsigned char *object, const char *tag,
338338
exit(128);
339339
}
340340
if (path) {
341-
unlink(path);
341+
unlink_or_warn(path);
342342
free(path);
343343
}
344344
}

builtin-verify-tag.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ static int run_gpg_verify(const char *buf, unsigned long size, int verbose)
5555
close(gpg.in);
5656
ret = finish_command(&gpg);
5757

58-
unlink(path);
58+
unlink_or_warn(path);
5959

6060
return ret;
6161
}

0 commit comments

Comments
 (0)