Skip to content

Commit c34d24b

Browse files
committed
quote_path: rename quote_path_relative() to quote_path()
There is no quote_path_absolute() or anything that causes confusion, and one of the two large consumers already rename the long name locally with a preprocessor macro. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3a238e5 commit c34d24b

File tree

5 files changed

+14
-18
lines changed

5 files changed

+14
-18
lines changed

builtin/clean.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ static int remove_dirs(struct strbuf *path, const char *prefix, int force_flag,
162162
if ((force_flag & REMOVE_DIR_KEEP_NESTED_GIT) &&
163163
is_nonbare_repository_dir(path)) {
164164
if (!quiet) {
165-
quote_path_relative(path->buf, prefix, &quoted);
165+
quote_path(path->buf, prefix, &quoted);
166166
printf(dry_run ? _(msg_would_skip_git_dir) : _(msg_skip_git_dir),
167167
quoted.buf);
168168
}
@@ -177,7 +177,7 @@ static int remove_dirs(struct strbuf *path, const char *prefix, int force_flag,
177177
res = dry_run ? 0 : rmdir(path->buf);
178178
if (res) {
179179
int saved_errno = errno;
180-
quote_path_relative(path->buf, prefix, &quoted);
180+
quote_path(path->buf, prefix, &quoted);
181181
errno = saved_errno;
182182
warning_errno(_(msg_warn_remove_failed), quoted.buf);
183183
*dir_gone = 0;
@@ -202,19 +202,19 @@ static int remove_dirs(struct strbuf *path, const char *prefix, int force_flag,
202202
if (remove_dirs(path, prefix, force_flag, dry_run, quiet, &gone))
203203
ret = 1;
204204
if (gone) {
205-
quote_path_relative(path->buf, prefix, &quoted);
205+
quote_path(path->buf, prefix, &quoted);
206206
string_list_append(&dels, quoted.buf);
207207
} else
208208
*dir_gone = 0;
209209
continue;
210210
} else {
211211
res = dry_run ? 0 : unlink(path->buf);
212212
if (!res) {
213-
quote_path_relative(path->buf, prefix, &quoted);
213+
quote_path(path->buf, prefix, &quoted);
214214
string_list_append(&dels, quoted.buf);
215215
} else {
216216
int saved_errno = errno;
217-
quote_path_relative(path->buf, prefix, &quoted);
217+
quote_path(path->buf, prefix, &quoted);
218218
errno = saved_errno;
219219
warning_errno(_(msg_warn_remove_failed), quoted.buf);
220220
*dir_gone = 0;
@@ -238,7 +238,7 @@ static int remove_dirs(struct strbuf *path, const char *prefix, int force_flag,
238238
*dir_gone = 1;
239239
else {
240240
int saved_errno = errno;
241-
quote_path_relative(path->buf, prefix, &quoted);
241+
quote_path(path->buf, prefix, &quoted);
242242
errno = saved_errno;
243243
warning_errno(_(msg_warn_remove_failed), quoted.buf);
244244
*dir_gone = 0;
@@ -266,7 +266,7 @@ static void pretty_print_dels(void)
266266
struct column_options copts;
267267

268268
for_each_string_list_item(item, &del_list) {
269-
qname = quote_path_relative(item->string, NULL, &buf);
269+
qname = quote_path(item->string, NULL, &buf);
270270
string_list_append(&list, qname);
271271
}
272272

@@ -753,7 +753,7 @@ static int ask_each_cmd(void)
753753
for_each_string_list_item(item, &del_list) {
754754
/* Ctrl-D should stop removing files */
755755
if (!eof) {
756-
qname = quote_path_relative(item->string, NULL, &buf);
756+
qname = quote_path(item->string, NULL, &buf);
757757
/* TRANSLATORS: Make sure to keep [y/N] as is */
758758
printf(_("Remove %s [y/N]? "), qname);
759759
if (git_read_line_interactively(&confirm) == EOF) {
@@ -1047,19 +1047,19 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
10471047
if (remove_dirs(&abs_path, prefix, rm_flags, dry_run, quiet, &gone))
10481048
errors++;
10491049
if (gone && !quiet) {
1050-
qname = quote_path_relative(item->string, NULL, &buf);
1050+
qname = quote_path(item->string, NULL, &buf);
10511051
printf(dry_run ? _(msg_would_remove) : _(msg_remove), qname);
10521052
}
10531053
} else {
10541054
res = dry_run ? 0 : unlink(abs_path.buf);
10551055
if (res) {
10561056
int saved_errno = errno;
1057-
qname = quote_path_relative(item->string, NULL, &buf);
1057+
qname = quote_path(item->string, NULL, &buf);
10581058
errno = saved_errno;
10591059
warning_errno(_(msg_warn_remove_failed), qname);
10601060
errors++;
10611061
} else if (!quiet) {
1062-
qname = quote_path_relative(item->string, NULL, &buf);
1062+
qname = quote_path(item->string, NULL, &buf);
10631063
printf(dry_run ? _(msg_would_remove) : _(msg_remove), qname);
10641064
}
10651065
}

builtin/grep.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ static void grep_source_name(struct grep_opt *opt, const char *filename,
319319
}
320320

321321
if (opt->relative && opt->prefix_length)
322-
quote_path_relative(filename + tree_name_len, opt->prefix, out);
322+
quote_path(filename + tree_name_len, opt->prefix, out);
323323
else
324324
quote_c_style(filename + tree_name_len, out, NULL, 0);
325325

quote.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,7 @@ void write_name_quoted_relative(const char *name, const char *prefix,
352352
}
353353

354354
/* quote path as relative to the given prefix */
355-
char *quote_path_relative(const char *in, const char *prefix,
356-
struct strbuf *out)
355+
char *quote_path(const char *in, const char *prefix, struct strbuf *out)
357356
{
358357
struct strbuf sb = STRBUF_INIT;
359358
const char *rel = relative_path(in, prefix, &sb);

quote.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ void write_name_quoted_relative(const char *name, const char *prefix,
7272
FILE *fp, int terminator);
7373

7474
/* quote path as relative to the given prefix */
75-
char *quote_path_relative(const char *in, const char *prefix,
76-
struct strbuf *out);
75+
char *quote_path(const char *in, const char *prefix, struct strbuf *out);
7776

7877
/* quoting as a string literal for other languages */
7978
void perl_quote_buf(struct strbuf *sb, const char *src);

wt-status.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,6 @@ static void wt_longstatus_print_trailer(struct wt_status *s)
259259
status_printf_ln(s, color(WT_STATUS_HEADER, s), "%s", "");
260260
}
261261

262-
#define quote_path quote_path_relative
263-
264262
static const char *wt_status_unmerged_status_string(int stagemask)
265263
{
266264
switch (stagemask) {

0 commit comments

Comments
 (0)