@matheusbsbs / matheus-bagliano / commits / c34d24b8a4
Fork 0

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 <gitster@pobox.com>

Junio C Hamano committed Sep 10, 2020 at 10:01 UTC c34d24b8a4d776a0046261b7fc6d0900ea94cc52
5 files changed +14 -18
builtin/clean.c
+11 -11
@@ -162,7 +162,7 @@ static int remove_dirs(struct strbuf *path, const char *prefix, int force_flag,
162 if ((force_flag & REMOVE_DIR_KEEP_NESTED_GIT) &&
163 is_nonbare_repository_dir(path)) {
164 if (!quiet) {
165 - quote_path_relative(path->buf, prefix, &quoted);
165 + quote_path(path->buf, prefix, &quoted);
166 printf(dry_run ? _(msg_would_skip_git_dir) : _(msg_skip_git_dir),
167 quoted.buf);
168 }
@@ -177,7 +177,7 @@ static int remove_dirs(struct strbuf *path, const char *prefix, int force_flag,
177 res = dry_run ? 0 : rmdir(path->buf);
178 if (res) {
179 int saved_errno = errno;
180 - quote_path_relative(path->buf, prefix, &quoted);
180 + quote_path(path->buf, prefix, &quoted);
181 errno = saved_errno;
182 warning_errno(_(msg_warn_remove_failed), quoted.buf);
183 *dir_gone = 0;
@@ -202,7 +202,7 @@ static int remove_dirs(struct strbuf *path, const char *prefix, int force_flag,
202 if (remove_dirs(path, prefix, force_flag, dry_run, quiet, &gone))
203 ret = 1;
204 if (gone) {
205 - quote_path_relative(path->buf, prefix, &quoted);
205 + quote_path(path->buf, prefix, &quoted);
206 string_list_append(&dels, quoted.buf);
207 } else
208 *dir_gone = 0;
@@ -210,11 +210,11 @@ static int remove_dirs(struct strbuf *path, const char *prefix, int force_flag,
210 } else {
211 res = dry_run ? 0 : unlink(path->buf);
212 if (!res) {
213 - quote_path_relative(path->buf, prefix, &quoted);
213 + quote_path(path->buf, prefix, &quoted);
214 string_list_append(&dels, quoted.buf);
215 } else {
216 int saved_errno = errno;
217 - quote_path_relative(path->buf, prefix, &quoted);
217 + quote_path(path->buf, prefix, &quoted);
218 errno = saved_errno;
219 warning_errno(_(msg_warn_remove_failed), quoted.buf);
220 *dir_gone = 0;
@@ -238,7 +238,7 @@ static int remove_dirs(struct strbuf *path, const char *prefix, int force_flag,
238 *dir_gone = 1;
239 else {
240 int saved_errno = errno;
241 - quote_path_relative(path->buf, prefix, &quoted);
241 + quote_path(path->buf, prefix, &quoted);
242 errno = saved_errno;
243 warning_errno(_(msg_warn_remove_failed), quoted.buf);
244 *dir_gone = 0;
@@ -266,7 +266,7 @@ static void pretty_print_dels(void)
266 struct column_options copts;
267
268 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);
270 string_list_append(&list, qname);
271 }
272
@@ -753,7 +753,7 @@ static int ask_each_cmd(void)
753 for_each_string_list_item(item, &del_list) {
754 /* Ctrl-D should stop removing files */
755 if (!eof) {
756 - qname = quote_path_relative(item->string, NULL, &buf);
756 + qname = quote_path(item->string, NULL, &buf);
757 /* TRANSLATORS: Make sure to keep [y/N] as is */
758 printf(_("Remove %s [y/N]? "), qname);
759 if (git_read_line_interactively(&confirm) == EOF) {
@@ -1047,19 +1047,19 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
1047 if (remove_dirs(&abs_path, prefix, rm_flags, dry_run, quiet, &gone))
1048 errors++;
1049 if (gone && !quiet) {
1050 - qname = quote_path_relative(item->string, NULL, &buf);
1050 + qname = quote_path(item->string, NULL, &buf);
1051 printf(dry_run ? _(msg_would_remove) : _(msg_remove), qname);
1052 }
1053 } else {
1054 res = dry_run ? 0 : unlink(abs_path.buf);
1055 if (res) {
1056 int saved_errno = errno;
1057 - qname = quote_path_relative(item->string, NULL, &buf);
1057 + qname = quote_path(item->string, NULL, &buf);
1058 errno = saved_errno;
1059 warning_errno(_(msg_warn_remove_failed), qname);
1060 errors++;
1061 } else if (!quiet) {
1062 - qname = quote_path_relative(item->string, NULL, &buf);
1062 + qname = quote_path(item->string, NULL, &buf);
1063 printf(dry_run ? _(msg_would_remove) : _(msg_remove), qname);
1064 }
1065 }
builtin/grep.c
+1 -1
@@ -319,7 +319,7 @@ static void grep_source_name(struct grep_opt *opt, const char *filename,
319 }
320
321 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);
323 else
324 quote_c_style(filename + tree_name_len, out, NULL, 0);
325
quote.c
+1 -2
@@ -352,8 +352,7 @@ void write_name_quoted_relative(const char *name, const char *prefix,
352 }
353
354 /* 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)
356 {
357 struct strbuf sb = STRBUF_INIT;
358 const char *rel = relative_path(in, prefix, &sb);
quote.h
+1 -2
@@ -72,8 +72,7 @@ void write_name_quoted_relative(const char *name, const char *prefix,
72 FILE *fp, int terminator);
73
74 /* 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);
76
77 /* quoting as a string literal for other languages */
78 void perl_quote_buf(struct strbuf *sb, const char *src);
wt-status.c
-2
@@ -259,8 +259,6 @@ static void wt_longstatus_print_trailer(struct wt_status *s)
259 status_printf_ln(s, color(WT_STATUS_HEADER, s), "%s", "");
260 }
261
262 -#define quote_path quote_path_relative
263 -
262 static const char *wt_status_unmerged_status_string(int stagemask)
263 {
264 switch (stagemask) {