76
ssize_t read_result;
77
78
if (!is_directory(git_path("worktrees/%s", id))) {
79
- strbuf_addf(reason, _("Removing worktrees/%s: not a valid directory"), id);
79
+ strbuf_addstr(reason, _("not a valid directory"));
80
return 1;
81
}
82
if (file_exists(git_path("worktrees/%s/locked", id)))
83
return 0;
84
if (stat(git_path("worktrees/%s/gitdir", id), &st)) {
85
- strbuf_addf(reason, _("Removing worktrees/%s: gitdir file does not exist"), id);
85
+ strbuf_addstr(reason, _("gitdir file does not exist"));
86
return 1;
87
}
88
fd = open(git_path("worktrees/%s/gitdir", id), O_RDONLY);
89
if (fd < 0) {
90
- strbuf_addf(reason, _("Removing worktrees/%s: unable to read gitdir file (%s)"),
91
- id, strerror(errno));
90
+ strbuf_addf(reason, _("unable to read gitdir file (%s)"),
91
+ strerror(errno));
92
return 1;
93
}
94
len = xsize_t(st.st_size);
96
97
read_result = read_in_full(fd, path, len);
98
if (read_result < 0) {
99
- strbuf_addf(reason, _("Removing worktrees/%s: unable to read gitdir file (%s)"),
100
- id, strerror(errno));
99
+ strbuf_addf(reason, _("unable to read gitdir file (%s)"),
100
+ strerror(errno));
101
close(fd);
102
free(path);
103
return 1;
106
107
if (read_result != len) {
108
strbuf_addf(reason,
109
- _("Removing worktrees/%s: short read (expected %"PRIuMAX" bytes, read %"PRIuMAX")"),
110
- id, (uintmax_t)len, (uintmax_t)read_result);
109
+ _("short read (expected %"PRIuMAX" bytes, read %"PRIuMAX")"),
110
+ (uintmax_t)len, (uintmax_t)read_result);
111
free(path);
112
return 1;
113
}
114
while (len && (path[len - 1] == '\n' || path[len - 1] == '\r'))
115
len--;
116
if (!len) {
117
- strbuf_addf(reason, _("Removing worktrees/%s: invalid gitdir file"), id);
117
+ strbuf_addstr(reason, _("invalid gitdir file"));
118
free(path);
119
return 1;
120
}
123
free(path);
124
if (stat(git_path("worktrees/%s/index", id), &st) ||
125
st.st_mtime <= expire) {
126
- strbuf_addf(reason, _("Removing worktrees/%s: gitdir file points to non-existent location"), id);
126
+ strbuf_addstr(reason, _("gitdir file points to non-existent location"));
127
return 1;
128
} else {
129
return 0;
147
if (!prune_worktree(d->d_name, &reason))
148
continue;
149
if (show_only || verbose)
150
- printf("%s\n", reason.buf);
150
+ printf_ln(_("Removing %s/%s: %s"),
151
+ "worktrees", d->d_name, reason.buf);
152
if (show_only)
153
continue;
154
delete_git_dir(d->d_name);