[PATCH v3 0/1] quote: handle null and empty strings in sq_quote_buf_pretty()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hey,

The sq_quote_buf_pretty() function does not emit anything when the incoming
string is empty, but the function is to accumulate command line arguments,
properly quoted as necessary, and the right way to add an argument that is
an empty string is to show it quoted, i.e. ''.

Looking forward to your review. Cheers! Garima Singh

Reported by: Junio Hamano gitster@xxxxxxxxx [gitster@xxxxxxxxx] in
https://public-inbox.org/git/pull.298.git.gitgitgadget@xxxxxxxxx/T/#m9e33936067ec2066f675aa63133a2486efd415fd

Garima Singh (1):
  quote: handle numm and empty strings in sq_quote_buf_pretty

 quote.c          | 10 ++++++++++
 t/t0014-alias.sh |  7 +++++++
 2 files changed, 17 insertions(+)


base-commit: 5fa0f5238b0cd46cfe7f6fa76c3f526ea98148d9
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-314%2Fgarimasi514%2FcoreGit-fixQuote-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-314/garimasi514/coreGit-fixQuote-v3
Pull-Request: https://github.com/gitgitgadget/git/pull/314

Range-diff vs v2:

 1:  b9a68598d7 ! 1:  399fe02cb1 quote: handle null and empty strings in sq_quote_buf_pretty()
     @@ -1,13 +1,13 @@
      Author: Garima Singh <garima.singh@xxxxxxxxxxxxx>
      
     -    quote: handle null and empty strings in sq_quote_buf_pretty()
     +    quote: handle numm and empty strings in sq_quote_buf_pretty
      
     -    The sq_quote_buf_pretty() function does not emit anything when
     -    the incoming string is empty, but the function is to accumulate
     -    command line arguments, properly quoted as necessary, and the
     -    right way to add an argument that is an empty string is to show
     -    it quoted, i.e. ''. We warn the caller with the BUG macro if they
     -    pass in a NULL.
     +    The sq_quote_buf_pretty() function does not emit anything
     +    when the incoming string is empty, but the function is to
     +    accumulate command line arguments, properly quoted as
     +    necessary, and the right way to add an argument that is an
     +    empty string is to show it quoted, i.e. ''. We warn the caller
     +    with the BUG macro is they pass in a NULL.
      
          Reported by: Junio Hamano <gitster@xxxxxxxxx>
          Signed-off-by: Garima Singh <garima.singh@xxxxxxxxxxxxx>
     @@ -21,11 +21,9 @@
       
      +	/* In case of null tokens, warn the user of the BUG in their call. */
      +	if (!src) 
     -+		BUG("BUG can't append a NULL token to the buffer");
     ++		BUG("Cannot append a NULL token to the buffer");
      +	
     -+	/* In case of empty tokens, add a '' to ensure they 
     -+	 * don't get inadvertently dropped. 
     -+	 */
     ++	/* Avoid dropping a zero-length token by adding '' */
      +	if (!*src) {
      +		strbuf_addstr(dst, "''");
      +		return;
     @@ -43,11 +41,10 @@
       #'
       
      +test_expect_success 'run-command parses empty args properly, using sq_quote_buf_pretty' '
     -+	cat >expect <<-EOF &&
     -+	fatal: cannot change to '\''alias.foo=frotz foo '\'''\'' bar'\'': No such file or directory
     -+	EOF
     -+	test_expect_code 128 git -C "alias.foo=frotz foo '\'''\'' bar" foo 2>actual &&
     -+	test_cmp expect actual
     ++    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

-- 
gitgitgadget



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux