Skip to contentSkip to conversation

t4131: update test script

PATCH In review Harshit Jain 4 participants 17 messages Mar 19, 2020 – Mar 20, 2020

lore
Share & tools
lore
#0 lore raw

cover t4131: update test script

Greetings!

Here is my very first contribution to the open-source community. I have always been a great admirer of the open-source developments and am really excited to begin my journey in the open source development.

In this patch, I have:
- modernized the script code to adhere to the CodingGuidelines
- replaced 'test -f' with the helper function 'test_path_is_file' as it make the code more readable and also gives better error messages

Just to add, I have done this as a microproject for my GSoC application, and am hoping to contribute more to the git during the coming summers.

Thanks,
Harshit Jain

#1 lore raw

PATCH 1/2 t4131: modernize style

The tests in 't4131-apply-fake-ancestor.sh' were written a long time ago, and have a few style violations. Update it to adhere to the CodingGuidelines.

---
 t/t4131-apply-fake-ancestor.sh | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
t/t4131-apply-fake-ancestor.sh +4 -4
index b1361ce546..828d1a355b 100755
@@ -17,8 +17,8 @@ test_expect_success 'setup' '
 
 test_expect_success 'apply --build-fake-ancestor' '
 	git checkout 2 &&
-	echo "A" > 1.t &&
-	git diff > 1.patch &&
+	echo "A" >1.t &&
+	git diff >1.patch &&
 	git reset --hard &&
 	git checkout 1 &&
 	git apply --build-fake-ancestor 1.ancestor 1.patch
@@ -26,8 +26,8 @@ test_expect_success 'apply --build-fake-ancestor' '
 
 test_expect_success 'apply --build-fake-ancestor in a subdirectory' '
 	git checkout 3 &&
-	echo "C" > sub/3.t &&
-	git diff > 3.patch &&
+	echo "C" >sub/3.t &&
+	git diff >3.patch &&
 	git reset --hard &&
 	git checkout 4 &&
 	(
Signature · 1 line
2.26.0.rc2
#2 lore raw

Re: [GSoC][PATCH 1/2] t4131: modernize style

Hello Harshit,

Quoted 1 line

The tests in 't4131-apply-fake-ancestor.sh' were written a long time ago, and have a few style violations. Update it to adhere to the CodingGuidelines.

Maybe add a commit title and then have a body? To do so, do a 'git commit' instead of 'git commit -m "message"'. This will open a text editor in which you can edit your commit message. You may refer to this answer I gave on StackOverflow on commit messages:

https://stackoverflow.com/a/60755299/10751129

Also, commit messages are generally around 72 characters per line. What are the style violations you are talking about BTW?

The commit title can be of the form:

t4131: modernise style

<<commit description>>

Regards,
Shourya Shukla

#3 lore raw

Re: [GSoC][PATCH 1/2] t4131: modernize style

Hi Shourya,

Quoted 6 lines
Quoted 1 line

The tests in 't4131-apply-fake-ancestor.sh' were written a long time ago, and have a few style violations. Update it to adhere to the CodingGuidelines.

Maybe add a commit title and then have a body? To do so, do a 'git commit' instead of 'git commit -m "message"'. This will open a text editor in which you can edit your commit message. You may refer to this answer I gave on StackOverflow on commit messages:

https://stackoverflow.com/a/60755299/10751129

I used 'git commit' only and not 'git commit -m "message". But apparently, the git format-patch tool takes the first line of commit message i.e. the
commit title as the file name and the lines after that as the text for the body. And hence, the patch emails, just start with the commit description
and not the commit title.

So, should I explicitly add the commit title in the patch files generated or else how to handle this?

Quoted 2 lines

Also, commit messages are generally around 72 characters per line. What are the style violations you are talking about BTW?

The git coding guidelines says that we shouldn't have a space after the redirection operators, hence I corrected this in the test file.

Regards,
Harshit Jain

#4 lore raw

Re: [GSoC][PATCH 1/2] t4131: modernize style

Quoted 5 lines · Harshit Jain
Quoted 4 lines
Quoted 3 lines

The tests in 't4131-apply-fake-ancestor.sh' were written a long time ago, and have a few style violations. Update it to adhere to the CodingGuidelines.

...

I used 'git commit' only and not 'git commit -m "message". But

I'd suggest developers, especially the new ones, to stay away from using '-m "message"' form, too.

In your editor, you would probably have written something like

	-- -- -- -- -- the contents of editor window -- -- -- -- --
	t4131: modernize style

	The tests in 't4131-apply-fake-ancestor.sh' were written ...
	...

	-- -- -- -- -- the contents of editor window -- -- -- -- --

As you observed, the first paragraph of the log message text is taken as the title of the commit, and "git format-patch" places the title on the "Subject:" line (if you had more than one line in the first paragraph, since the payload on the "Subject: " line has to be a logically single line, you'd end up getting a single long line that has the contents on all lines in the first paragraph).

The second and subsequent paragraphs become the body of the message.

Your title looks reasonable; there is nothing that needs to be "fixed" or "improved" there.

Your second paragraph is not so good---it should wrap the lines at a reasonable length (say 65-70 columns).

Your last paragraph, which consists of a single "Signed-off-by:" line in this case, is good. It matches the identity recorded on the "From:" line of the message.

Quoted 5 lines
Quoted 2 lines

Also, commit messages are generally around 72 characters per line. What are the style violations you are talking about BTW?

The git coding guidelines says that we shouldn't have a space after the redirection operators, hence I corrected this in the test file.

That is a good thing to write in the commit log message.

"written a long time ago" does not have much value by itself (it does serve as a backstory to explain a half of why it does not use the more modern style, though). "have a few style violations." is almost meaningless (otherwise, you would not be doing a "modernize style" patch in the first place ;-).

t4131: modernize style.

The tests in t4131 leaves a SP between a redirection operator and the file that is the redirection target, which does not conform to the modern coding style.

Fix them.

Signed-off-by ...

perhaps.

#5 lore raw

PATCH 2/2 t4131: use helper function to replace test -f <path>

In reply to Harshit Jain

Replace 'test -f' with the helper function 'test_path_is_file' as the helper function improves the code readability and also gives better error messages.

---
 t/t4131-apply-fake-ancestor.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
t/t4131-apply-fake-ancestor.sh +1 -1
index 828d1a355b..21ee359632 100755
@@ -33,7 +33,7 @@ test_expect_success 'apply --build-fake-ancestor in a subdirectory' '
 	(
 		cd sub &&
 		git apply --build-fake-ancestor 3.ancestor ../3.patch &&
-		test -f 3.ancestor
+		test_path_is_file 3.ancestor
 	) &&
 	git apply --build-fake-ancestor 3.ancestor 3.patch &&
 	test_cmp sub/3.ancestor 3.ancestor
Signature · 1 line
2.26.0.rc2
#6 lore raw

Re: [GSoC][PATCH 2/2] t4131: use helper function to replace test -f <path>

Hello Harshit,

Quoted 1 line

Replace 'test -f' with the helper function 'test_path_is_file' as the helper function improves the code readability and also gives better error messages.

Again the same thing, you may follow what I stated before regarding commit messages.

The commit title can be of the form:

t4131: use helpers to replace test -f <path>

<<commit description>>

If you still face any problem, feel free to drop a message :)

Regards,
Shourya Shukla

#7 lore raw

Re: [GSoC][PATCH 2/2] t4131: use helper function to replace test -f <path>

Quoted 4 lines · Shourya Shukla

Hello Harshit,

Quoted 1 line

Replace 'test -f' with the helper function 'test_path_is_file' as the helper function improves the code readability and also gives better error messages.

Quoted 8 lines

Again the same thing, you may follow what I stated before regarding commit messages.

The commit title can be of the form:

t4131: use helpers to replace test -f <path>

<<commit description>>

Just curious, isn't the commit title already like that in this patch? The subject does read:

[GSoC][PATCH 2/2] t4131: use helper function to replace test -f <path>"

What am I missing?

Signature · 1 line
Sivaraam
#8 lore raw

Re: [GSoC][PATCH 2/2] t4131: use helper function to replace test -f <path>

Quoted 15 lines · Kaartic Sivaraam
Quoted 4 lines · Shourya Shukla

Hello Harshit,

Quoted 1 line

Replace 'test -f' with the helper function 'test_path_is_file' as the helper function improves the code readability and also gives better error messages.

Quoted 8 lines

Again the same thing, you may follow what I stated before regarding commit messages.

The commit title can be of the form:

t4131: use helpers to replace test -f <path>

<<commit description>>

Quoted 7 lines

Just curious, isn't the commit title already like that in this patch? The subject does read:

[GSoC][PATCH 2/2] t4131: use helper function to replace test -f <path>"

What am I missing?

Hey Shourya,
Can you please clarify, I am also a bit confused.

Regards,
Harshit Jain

#10 lore raw

Re: [GSoC][PATCH 2/2] t4131: use helper function to replace test -f <path>

In reply to Shourya Shukla
Quoted 11 lines · Shourya Shukla

Hello Harshit,

Quoted 1 line

Replace 'test -f' with the helper function 'test_path_is_file' as the helper function improves the code readability and also gives better error messages.

Again the same thing, you may follow what I stated before regarding commit messages.

The commit title can be of the form:

t4131: use helpers to replace test -f <path>

<<commit description>>

I think Harshit is writing the title of the commit in the right place. Format-wise, the only thing that is wrong is that each paragraph is too long without line wrapping.

What is wrong in these two e-mail thread is that you are not reading the log message correctly. When made into a piece of e-mail, the title goes to the "Subject:" field in the header and there is no need to repeat it in the body of the e-mail.

#11 lore raw

cover made the changes as per community suggestions

Greetings!

Thank you for suggesting the changes in my patches. I have made the changes as advised by Junio C Hamano in the following patch emails. Please look into those patch mails and suggest any further changes if needed.

Thank you once again.

Harshit Jain

#12 lore raw

PATCH 1/2 t4131: modernize style

The tests in t4131 leave a space character between the redirection operator and the file i.e. the redirection target which does not conform to the modern coding style.

Fix them.

---
 t/t4131-apply-fake-ancestor.sh | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
t/t4131-apply-fake-ancestor.sh +4 -4
index b1361ce546..828d1a355b 100755
@@ -17,8 +17,8 @@ test_expect_success 'setup' '
 
 test_expect_success 'apply --build-fake-ancestor' '
 	git checkout 2 &&
-	echo "A" > 1.t &&
-	git diff > 1.patch &&
+	echo "A" >1.t &&
+	git diff >1.patch &&
 	git reset --hard &&
 	git checkout 1 &&
 	git apply --build-fake-ancestor 1.ancestor 1.patch
@@ -26,8 +26,8 @@ test_expect_success 'apply --build-fake-ancestor' '
 
 test_expect_success 'apply --build-fake-ancestor in a subdirectory' '
 	git checkout 3 &&
-	echo "C" > sub/3.t &&
-	git diff > 3.patch &&
+	echo "C" >sub/3.t &&
+	git diff >3.patch &&
 	git reset --hard &&
 	git checkout 4 &&
 	(
Signature · 1 line
2.26.0.rc2
#13 lore raw

Re: Re: [GSoC][Patch]

Hello Harshit,

Quoted 5 lines

The tests in t4131 leave a space character between the redirection operator and the file i.e. the redirection target which does not conform to the modern coding style.

Fix them.

I think something like,

The tests in t4131 were written a long time ago and hence contain style violations such as an extra space between the redirection operator(>) and the redirection target. Update it to match the latest CodingGuidelines.

may be better.

Also, when you deliver a newer version of the patch, i.e., version 2 in your case, you have a [PATCH v2 1/n] as the subject, so that people know that it is the v2 and hence avoid confusion.

If you are using 'git format-patch' to formulate your mails, you can do:

'git format-patch -v2 <..>' to get a v2 based mail.

Regards,
Shourya Shukla

#14 lore raw

Re: Re: [GSoC][Patch]

Hi Shourya,

Quoted 9 lines · Shourya Shukla

Hello Harshit,

Quoted 5 lines

The tests in t4131 leave a space character between the redirection operator and the file i.e. the redirection target which does not conform to the modern coding style.

Fix them.

Quoted 8 lines

I think something like,

The tests in t4131 were written a long time ago and hence contain style violations such as an extra space between the redirection operator(>) and the redirection target. Update it to match the latest CodingGuidelines.

may be better.

Please see the comment made by Junio Hamano, pasted below:

"written a long time ago" does not have much value by itself (it does serve as a backstory to explain a half of why it does not use the more modern style, though). "have a few style violations." is almost meaningless (otherwise, you would not be doing a "modernize style" patch in the first place ;-).

I myself also agree with the above comment and hence, wrote the commit message accordingly. What do you think?

Quoted 8 lines

Also, when you deliver a newer version of the patch, i.e., version 2 in your case, you have a [PATCH v2 1/n] as the subject, so that people know that it is the v2 and hence avoid confusion.

If you are using 'git format-patch' to formulate your mails, you can do:

'git format-patch -v2 <..>' to get a v2 based mail.

Oh nice, didn't know about this. I will keep this in mind for future patch submissions.
Should I do this for the current patch as well?

Regards,
Harshit Jain

#15 lore raw

PATCH 2/2 t4131: use helper function to replace 'test -f'

In reply to Harshit Jain

Replace 'test -f' with the helper function 'test_path_is_file' as the helper function improves the code readability and also gives better error messages.

---
 t/t4131-apply-fake-ancestor.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
t/t4131-apply-fake-ancestor.sh +1 -1
index 828d1a355b..21ee359632 100755
@@ -33,7 +33,7 @@ test_expect_success 'apply --build-fake-ancestor in a subdirectory' '
 	(
 		cd sub &&
 		git apply --build-fake-ancestor 3.ancestor ../3.patch &&
-		test -f 3.ancestor
+		test_path_is_file 3.ancestor
 	) &&
 	git apply --build-fake-ancestor 3.ancestor 3.patch &&
 	test_cmp sub/3.ancestor 3.ancestor
Signature · 1 line
2.26.0.rc2