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

Re: [PATCH v2] userdiff: funcname and word patterns for sh

From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Date
Mar 14, 2015, 17:19 UTC
Message-ID
<vpqoanvjy3k.fsf@anie.imag.fr>
In-Reply-To
<1425944432-23642-1-git-send-email-adrien+dev@schischi.me>

On overall, the patch looks good. Some suggestions to improve the tests and a minor nitpick below.

Adrien Schildknecht <adrien+dev@schischi.me> writes:
> +++ b/t/t4034/sh/post
> @@ -0,0 +1,36 @@
> +foo() {ls&echo}
This part is unchanged here and in the pre file. What does it test?
Show 15 quoted lines
> +$((x++))
> +$((x--))
> +$((--x))
> +$((++x))
> +$((x*y))
> +$((x&y))
> +$((x**y))
> +$((x/y))
> +$((x%y))
> +$((x+y))
> +$((x-y))
> +[ x<=y ]
> +[ x>=y ]
> +[ x==y ]
> +[ x!=y ]

Not sure what the last ones are testing. If it's "[" as "the test command, spelled as [", then spaces are mandatory around the operators (and equality should be written =, not == in POSIX).

Show 16 quoted lines
> +x<<y x>>y x<<-y x<y x>y x>|y x<&y x>&y x<>y
> +x&y
> +x&&y
> +x|y
> +x||y
> +x=y
> +$((x+=y))
> +$((x-=y))
> +$((x*=y))
> +$((x/=y))
> +$((x%=y))
> +$((x<<=y))
> +$((x>>=y))
> +$((x&=y))
> +$((x^=y))
> +$((x|=y))

I think you should test the case of multiple-letters identifiers. One of the benefit of having a proper word-diff pattern is that e.g.

- pre=foo
+ post=bar

will consider the change "pre" -> "post", and not an unmodified "p" with the change "re" -> "ost" (otherwise, --color-words=. just works).

> +PATTERNS("sh",
> +	"^([ \t]*(function[ \t]+)?[a-zA-Z_][a-zA-Z0-9_]*[ \t]*\\([ \t]*\\).*)$",
> +	/* -- */
> +	 "[a-zA-Z0-9_]+"
Nitpick: the indentation is not homogeneous. You should add a space
after the tab on the first two lines to get a correct alignment.
-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Previous: Junio C HamanoNext: Junio C Hamano
Message 6 of 7 in “userdiff: funcname and word patterns for sh”
  1. Adrien SchildknechtMar 9, 2015
  2. userdiff: funcname and word patterns for shAdrien Schildknecht, Mar 9, 2015
  3. Matthieu MoyMar 9, 2015
  4. userdiff: funcname and word patterns for shAdrien Schildknecht, Mar 9, 2015
  5. Junio C HamanoMar 14, 2015
  6. Matthieu MoyMar 14, 2015
  7. Junio C HamanoMar 25, 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.