Skip to content

Commit 7745887

Browse files
committed
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
2 parents 5efabc7 + ce2d7ed commit 7745887

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

quote.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ void sq_quote_buf_pretty(struct strbuf *dst, const char *src)
4848
static const char ok_punct[] = "+,-./:=@_^";
4949
const char *p;
5050

51+
/* Avoid losing a zero-length string by adding '' */
52+
if (!*src) {
53+
strbuf_addstr(dst, "''");
54+
return;
55+
}
56+
5157
for (p = src; *p; p++) {
5258
if (!isalpha(*p) && !isdigit(*p) && !strchr(ok_punct, *p)) {
5359
sq_quote_buf(dst, src);

t/t0014-alias.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,11 @@ test_expect_success 'looping aliases - internal execution' '
3737
# test_i18ngrep "^fatal: alias loop detected: expansion of" output
3838
#'
3939

40+
test_expect_success 'run-command formats empty args properly' '
41+
GIT_TRACE=1 git frotz a "" b " " c 2>&1 |
42+
sed -ne "/run_command:/s/.*trace: run_command: //p" >actual &&
43+
echo "git-frotz a '\'''\'' b '\'' '\'' c" >expect &&
44+
test_cmp expect actual
45+
'
46+
4047
test_done

0 commit comments

Comments
 (0)