THIS IS A TEST INSTANCE ONLY! REPOSITORIES CAN BE DELETED AT ANY TIME!

Browse Source

Merge branch 'gs/sq-quote-buf-pretty'

Pretty-printed command line formatter (used in e.g. reporting the
command being run by the tracing API) had a bug that lost an
argument that is an empty string, which has been corrected.

* gs/sq-quote-buf-pretty:
  sq_quote_buf_pretty: don't drop empty arguments
tags/v2.24.0-rc0
Junio C Hamano 1 month ago
parent
commit
77458870a5
2 changed files with 13 additions and 0 deletions
  1. +6
    -0
      quote.c
  2. +7
    -0
      t/t0014-alias.sh

+ 6
- 0
quote.c View File

@@ -48,6 +48,12 @@ void sq_quote_buf_pretty(struct strbuf *dst, const char *src)
static const char ok_punct[] = "+,-./:=@_^";
const char *p;

/* Avoid losing a zero-length string by adding '' */
if (!*src) {
strbuf_addstr(dst, "''");
return;
}

for (p = src; *p; p++) {
if (!isalpha(*p) && !isdigit(*p) && !strchr(ok_punct, *p)) {
sq_quote_buf(dst, src);


+ 7
- 0
t/t0014-alias.sh View File

@@ -37,4 +37,11 @@ test_expect_success 'looping aliases - internal execution' '
# test_i18ngrep "^fatal: alias loop detected: expansion of" output
#'

test_expect_success 'run-command formats empty args properly' '
GIT_TRACE=1 git frotz a "" b " " c 2>&1 |
sed -ne "/run_command:/s/.*trace: run_command: //p" >actual &&
echo "git-frotz a '\'''\'' b '\'' '\'' c" >expect &&
test_cmp expect actual
'

test_done

Loading…
Cancel
Save