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

Re: [PATCHv9 4/4] pathspec: allow querying for attributes

From
Junio C Hamano <gitster@pobox.com>
Date
May 19, 2016, 23:32 UTC
Message-ID
<xmqqbn41hbeq.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20160519232323.12775-5-sbeller@google.com>
Stefan Beller <sbeller@google.com> writes:
> +attr;;
> +After `attr:` comes a space separated list of "attribute
> +...
> ++
The text looks OK, but does it format well?
> +		attr_len = strcspn(attr, "=");

Scanning for '=' here retains the same bug from the previous iteration where you take !VAR=VAL and silently ignore =VAL part without diagnosing the error, doesn't it?

Perhaps strlen(attr) here, and...
Show 22 quoted lines
> +		switch (*attr) {
> +		case '!':
> +			am->match_mode = MATCH_UNSPECIFIED;
> +			attr++;
> +			attr_len--;
> +			break;
> +		case '-':
> +			am->match_mode = MATCH_UNSET;
> +			attr++;
> +			attr_len--;
> +			break;
> +		default:
> +			if (attr[attr_len] != '=')
> +				am->match_mode = MATCH_SET;
> +			else {
> +				am->match_mode = MATCH_VALUE;
> +				am->value = xstrdup(&attr[attr_len + 1]);
> +				if (strchr(am->value, '\\'))
> +					die(_("attr spec values must not contain backslashes"));
> +			}
> +			break;
> +		}
... doing strcspn() only in default: part would be a quick fix.
Previous: Stefan BellerNext: Junio C Hamano
Message 6 of 9 in “[PATCHv9 0/4] pathspec magic extension to search for attributes”
  1. Stefan BellerMay 19, 2016
  2. 1/4 Documentation: fix a typoStefan Beller, May 19, 2016
  3. 2/4 pathspec: move long magic parsing out of prefix_pathspecStefan Beller, May 19, 2016
  4. 3/4 pathspec: move prefix check out of the inner loopStefan Beller, May 19, 2016
  5. 4/4 pathspec: allow querying for attributesStefan Beller, May 19, 2016
  6. Junio C HamanoMay 19, 2016
  7. Junio C HamanoMay 20, 2016
  8. Stefan BellerMay 20, 2016
  9. Junio C HamanoMay 20, 2016

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.