MCPcopy Index your code
hub / github.com/git/git / quote_path

Function quote_path

quote.c:350–372  ·  view source on GitHub ↗

quote path as relative to the given prefix */

Source from the content-addressed store, hash-verified

348
349/* quote path as relative to the given prefix */
350char *quote_path(const char *in, const char *prefix, struct strbuf *out, unsigned flags)
351{
352 struct strbuf sb = STRBUF_INIT;
353 const char *rel = relative_path(in, prefix, &sb);
354 int force_dq = ((flags & QUOTE_PATH_QUOTE_SP) && strchr(rel, ' '));
355
356 strbuf_reset(out);
357
358 /*
359 * If the caller wants us to enclose the output in a dq-pair
360 * whether quote_c_style_counted() needs to, we do it ourselves
361 * and tell quote_c_style_counted() not to.
362 */
363 if (force_dq)
364 strbuf_addch(out, '"');
365 quote_c_style_counted(rel, strlen(rel), out, NULL,
366 force_dq ? CQUOTE_NODQ : 0);
367 if (force_dq)
368 strbuf_addch(out, '"');
369 strbuf_release(&sb);
370
371 return out->buf;
372}
373
374/*
375 * C-style name unquoting.

Callers 15

wt_shortstatus_unmergedFunction · 0.85
wt_shortstatus_statusFunction · 0.85
wt_shortstatus_otherFunction · 0.85
grep_source_nameFunction · 0.85
measure_widthsFunction · 0.85
remove_dirsFunction · 0.85

Calls 4

relative_pathFunction · 0.85
strbuf_addchFunction · 0.85
quote_c_style_countedFunction · 0.85
strbuf_releaseFunction · 0.85

Tested by

no test coverage detected