diff mbox series

[GSoC,RFC/PATCH,1/1] userdiff - support shell script

Message ID 20190315150142.20672-2-jkapil.cs@gmail.com (mailing list archive)
State New, archived
Headers show
Series [GSoC,RFC/PATCH,1/1] userdiff - support shell script | expand

Commit Message

Kapil Jain March 15, 2019, 3:01 p.m. UTC
From: Kapil <jkapil.cs@gmail.com>

Made a minor change of adding regex for identifying functions in shell scripts.
This regex has been tested separately from git.
For testing with git, please let me know.

This is just to get familiar with whole workflow, regex for word_regex parameter will be added in next patch.

---
 t/t4018-diff-funcname.sh | 1 +
 t/t4034-diff-words.sh    | 1 +
 userdiff.c               | 5 +++++
 3 files changed, 7 insertions(+)

Comments

Thomas Gummerer March 15, 2019, 11:05 p.m. UTC | #1
> Subject: [GSoC][RFC/PATCH 1/1] userdiff - support shell script

We usually have the subject in the format "<area>: <short
explanation>", so in this case it could be "userdiff: support shell
script" (without the quotes of course).

On 03/15, jkapil.cs@gmail.com wrote:
> From: Kapil <jkapil.cs@gmail.com>

Ideally the name you are using for your contribution should be your
full name, including your last name.

> Made a minor change of adding regex for identifying functions in shell scripts.

The commit message should be in the imperative mood, see also
Documentation/SubmittingPatches.  In addition the "minor change" bit
should be omitted, as it doesn't add any actual value to the commit
message.

So the above should just be "Add regex for identifying functions in
shell scripts".

> This regex has been tested separately from git.
> For testing with git, please let me know.

For testing you could have a look how other userdiff drivers are
tested in t4034.  The easiest way is probably to have a look at a
patch for a userdiff pattern that was added previously.  For example
have a look at 0719f3eecd ("userdiff: add built-in pattern for CSS",
2016-06-03).  (I found this commit by looking at the git blame output
for t4034.)

Both the two lines above and the line below should go below the ---
line, as they should not be part of the history in the git project,
but serve only as additional commentary for reviewers looking at this
patch.

> This is just to get familiar with whole workflow, regex for word_regex parameter will be added in next patch.

There should be a Signed-off-by: line here.  For its significance
please see Documentation/SubmittingPatches.

Another thing you should consider is whether someone attempted to add
support for this before.  And indeed a quick search through
public-inbox turns up [*1*].  It's always worth having a look at
previous work, and things that can be learned from that.

*1*: https://public-inbox.org/git/20170329165331.17742-1-pickfire@riseup.net/#t

> ---
>  t/t4018-diff-funcname.sh | 1 +
>  t/t4034-diff-words.sh    | 1 +
>  userdiff.c               | 5 +++++
>  3 files changed, 7 insertions(+)
> 
> diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh
> index 22f9f88f0a..68092eaeaa 100755
> --- a/t/t4018-diff-funcname.sh
> +++ b/t/t4018-diff-funcname.sh
> @@ -44,6 +44,7 @@ diffpatterns="
>  	python
>  	ruby
>  	tex
> +	shell
>  	custom1
>  	custom2
>  	custom3
> diff --git a/t/t4034-diff-words.sh b/t/t4034-diff-words.sh
> index 912df91226..de21f36d97 100755
> --- a/t/t4034-diff-words.sh
> +++ b/t/t4034-diff-words.sh
> @@ -314,6 +314,7 @@ test_language_driver php
>  test_language_driver python
>  test_language_driver ruby
>  test_language_driver tex
> +test_language_driver shell
>  
>  test_expect_success 'word-diff with diff.sbe' '
>  	cat >expect <<-\EOF &&
> diff --git a/userdiff.c b/userdiff.c
> index 3a78fbf504..1743608da2 100644
> --- a/userdiff.c
> +++ b/userdiff.c
> @@ -170,6 +170,11 @@ IPATTERN("css",
>  	 "-?[_a-zA-Z][-_a-zA-Z0-9]*" /* identifiers */
>  	 "|-?[0-9]+|\\#[0-9a-fA-F]+" /* numbers */
>  ),
> +
> +PATTERNS("shell",
> +	"([A-Za-z_][A-Za-z0-9_]*)[[:space:]]*\\([[:space:]]*\\)[[:space:]]*\\{[[:space:]\\(\\)|\\[<>?`/~!:\'\"%^&*+A-Za-z0-9_$=@;#,.-]*\\}",
> +	".*"
> +),
>  { "default", NULL, -1, { NULL, 0 } },
>  };
>  #undef PATTERNS
> -- 
> 2.14.2
>
Thomas Gummerer March 16, 2019, 6:45 p.m. UTC | #2
[please keep everyone in Cc, especially the mailing list if you are
responding to review comments.  I added the Cc's back]

On 03/16, Kapil Jain wrote:
> On Sat, Mar 16, 2019 at 4:35 AM Thomas Gummerer <t.gummerer@gmail.com> wrote:
> >
> > For testing you could have a look how other userdiff drivers are
> > tested in t4034.  The easiest way is probably to have a look at a
> > patch for a userdiff pattern that was added previously.  For example
> > have a look at 0719f3eecd ("userdiff: add built-in pattern for CSS",
> > 2016-06-03).  (I found this commit by looking at the git blame output
> > for t4034.)
> > *1*: https://public-inbox.org/git/20170329165331.17742-1-pickfire@riseup.net/#t
> 
> Thanks, this helped in understanding testing process.
> 
> > Both the two lines above and the line below should go below the ---
> > line, as they should not be part of the history in the git project,
> > but serve only as additional commentary for reviewers looking at this
> > patch.
> 
> I looked at other patches like
> (https://public-inbox.org/git/CAC05386q2iGoiJ_fRgwoOTF23exEN2D1+oh4VjajEvYQ58O1TQ@mail.gmail.com/)
> The patch has the email body above --- line. did i missed to
> understanding something here ?

Right, what I was trying but failed to explain is that everything
above the --- line is part of the commit message, that gets recorded
in the history of the project.

However the lines I referred to, should not go in the commit message,
as they are just commentary that helps reviewers, but don't actually
explain the patch itself.  That additional commentary should go below
the --- line, similar to the

    Notes:
        Travis CI results: https://travis-ci.org/nbelakovski/git/builds/432320949

lines in the email you mentioned.
diff mbox series

Patch

diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh
index 22f9f88f0a..68092eaeaa 100755
--- a/t/t4018-diff-funcname.sh
+++ b/t/t4018-diff-funcname.sh
@@ -44,6 +44,7 @@  diffpatterns="
 	python
 	ruby
 	tex
+	shell
 	custom1
 	custom2
 	custom3
diff --git a/t/t4034-diff-words.sh b/t/t4034-diff-words.sh
index 912df91226..de21f36d97 100755
--- a/t/t4034-diff-words.sh
+++ b/t/t4034-diff-words.sh
@@ -314,6 +314,7 @@  test_language_driver php
 test_language_driver python
 test_language_driver ruby
 test_language_driver tex
+test_language_driver shell
 
 test_expect_success 'word-diff with diff.sbe' '
 	cat >expect <<-\EOF &&
diff --git a/userdiff.c b/userdiff.c
index 3a78fbf504..1743608da2 100644
--- a/userdiff.c
+++ b/userdiff.c
@@ -170,6 +170,11 @@  IPATTERN("css",
 	 "-?[_a-zA-Z][-_a-zA-Z0-9]*" /* identifiers */
 	 "|-?[0-9]+|\\#[0-9a-fA-F]+" /* numbers */
 ),
+
+PATTERNS("shell",
+	"([A-Za-z_][A-Za-z0-9_]*)[[:space:]]*\\([[:space:]]*\\)[[:space:]]*\\{[[:space:]\\(\\)|\\[<>?`/~!:\'\"%^&*+A-Za-z0-9_$=@;#,.-]*\\}",
+	".*"
+),
 { "default", NULL, -1, { NULL, 0 } },
 };
 #undef PATTERNS