quote path as relative to the given prefix */
| 348 | |
| 349 | /* quote path as relative to the given prefix */ |
| 350 | char *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. |
no test coverage detected