git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v16 00/14] port tag.c to use ref-filter APIs

From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Date
Sep 6, 2015, 18:49 UTC
Message-ID
<vpqa8sz9ydh.fsf@anie.imag.fr>
In-Reply-To
<1441479135-5285-1-git-send-email-Karthik.188@gmail.com>
Karthik Nayak <karthik.188@gmail.com> writes:
Show 11 quoted lines
> @@ -705,9 +719,12 @@ static void grab_sub_body_contents(struct atom_value *val, int deref, struct obj
>  			v->s = xstrdup(subpos);
>  		else if (skip_prefix(name, "contents:lines=", &valp)) {
>  			struct strbuf s = STRBUF_INIT;
> +			const char *contents_end = bodylen + bodypos - siglen;
> +
>  			if (strtoul_ui(valp, 10, &v->u.contents.lines))
> -				die(_("positive width expected contents:lines=%s"), valp);
> -			append_lines(&s, subpos, sublen + bodylen - siglen, v->u.contents.lines);
> +				die(_("positive value expected contents:lines=%s"), valp);
> +			/*  Size is the length of the message after removing the signature */
Nit: double-space after /*.
Show 28 quoted lines
> -test_expect_success 'alignment with format quote' '
> -	cat >expect <<-EOF &&
> -	refname is ${sq}           ${sq}\\${sq}${sq}master${sq}\\${sq}${sq}           ${sq}|
> -	refname is ${sq}            ${sq}\\${sq}${sq}side${sq}\\${sq}${sq}            ${sq}|
> -	refname is ${sq}          ${sq}\\${sq}${sq}odd/spot${sq}\\${sq}${sq}          ${sq}|
> -	refname is ${sq}         ${sq}\\${sq}${sq}double-tag${sq}\\${sq}${sq}         ${sq}|
> -	refname is ${sq}            ${sq}\\${sq}${sq}four${sq}\\${sq}${sq}            ${sq}|
> -	refname is ${sq}            ${sq}\\${sq}${sq}one${sq}\\${sq}${sq}             ${sq}|
> -	refname is ${sq}         ${sq}\\${sq}${sq}signed-tag${sq}\\${sq}${sq}         ${sq}|
> -	refname is ${sq}           ${sq}\\${sq}${sq}three${sq}\\${sq}${sq}            ${sq}|
> -	refname is ${sq}            ${sq}\\${sq}${sq}two${sq}\\${sq}${sq}             ${sq}|
> +test_expect_success 'alignment with format quote' "
> +	cat >expect <<-\EOF &&
> +	|'       master| A U Thor       '|
> +	|'        side| A U Thor        '|
> +	|'      odd/spot| A U Thor      '|
> +	|'         double-tag|          '|
> +	|'        four| A U Thor        '|
> +	|'        one| A U Thor         '|
> +	|'         signed-tag|          '|
> +	|'       three| A U Thor        '|
> +	|'        two| A U Thor         '|
>  	EOF
> -	git for-each-ref --shell --format="refname is %(align:30,middle)${sq}%(refname:short)${sq}%(end)|" >actual &&
> +	git for-each-ref --shell --format='|%(align:30,middle)%(refname:short)| %(authorname)%(end)|' >actual &&
>  	test_cmp expect actual
> -'
> +"

The new test is indeed easier to read, but you're not testing anymore the consequence of a single-quote within the aligned string.

An implementation that just adds single-quotes around the string without turning ' into '\'' would be broken but still pass the test.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Previous: Karthik NayakNext: Karthik Nayak
Message 20 of 30 in “port tag.c to use ref-filter APIs”
  1. 00/14 port tag.c to use ref-filter APIsKarthik Nayak, Sep 5, 2015
  2. 01/14 ref-filter: move `struct atom_value` to ref-filter.cKarthik Nayak, Sep 5, 2015
  3. 02/14 ref-filter: introduce ref_formatting_state and ref_formatting_stackKarthik Nayak, Sep 5, 2015
  4. 03/14 utf8: add function to align a string into given strbufKarthik Nayak, Sep 5, 2015
  5. 04/14 ref-filter: introduce handler function for each atomKarthik Nayak, Sep 5, 2015
  6. 05/14 ref-filter: introduce match_atom_name()Karthik Nayak, Sep 5, 2015
  7. Eric SunshineSep 6, 2015
  8. Karthik NayakSep 7, 2015
  9. 06/14 ref-filter: implement an `align` atomKarthik Nayak, Sep 5, 2015
  10. Eric SunshineSep 6, 2015
  11. Karthik NayakSep 7, 2015
  12. 07/14 ref-filter: add option to filter out tags, branches and remotesKarthik Nayak, Sep 5, 2015
  13. 08/14 ref-filter: add support for %(contents:lines=X)Karthik Nayak, Sep 5, 2015
  14. 09/14 ref-filter: add support to sort by versionKarthik Nayak, Sep 5, 2015
  15. 10/14 ref-filter: add option to match literal patternKarthik Nayak, Sep 5, 2015
  16. 11/14 tag.c: use 'ref-filter' data structuresKarthik Nayak, Sep 5, 2015
  17. 12/14 tag.c: use 'ref-filter' APIsKarthik Nayak, Sep 5, 2015
  18. 13/14 tag.c: implement '--format' optionKarthik Nayak, Sep 5, 2015
  19. 14/14 tag.c: implement '--merged' and '--no-merged' optionsKarthik Nayak, Sep 5, 2015
  20. Matthieu MoySep 6, 2015
  21. Karthik NayakSep 6, 2015
  22. Junio C HamanoSep 7, 2015
  23. Matthieu MoySep 7, 2015
  24. Karthik NayakSep 7, 2015
  25. Matthieu MoySep 7, 2015
  26. Karthik NayakSep 8, 2015
  27. Junio C HamanoSep 8, 2015
  28. Karthik NayakSep 9, 2015
  29. Junio C HamanoSep 9, 2015
  30. Junio C HamanoSep 8, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.