threads / patch / 54454

patcht0000: replace an instant of test -f with test_path_is_file functions.

Subject: [Outreachy-Microproject][PATCH 1/1] t0000: replace an instant of test -f with test_path_is_file functions.

## tl;dr

3 messages between Oct 18, 2020 and Oct 18, 2020. Diffs are folded; open one to read it.

replies: 2people: 3as markdown or json

Caleb Tillman· Oct 18, 2020, 00:55 UTC · lore
The test_path_is* functions provide debug-friendly messages upon failure.
Signed-off-by: Caleb Tillman <caleb.tillman@gmail.com>
--- Outrachy Microproject, revised submission
 t/t0000-basic.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Show changes to t/t0000-basic.sh +1 −1
diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index 923281af93..eb99892a87 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -1191,7 +1191,7 @@ test_expect_success 'writing this tree with --missing-ok' '
 test_expect_success 'git read-tree followed by write-tree should be idempotent' '
 	rm -f .git/index &&
 	git read-tree $tree &&
-	test -f .git/index &&
+	test_path_is_file .git/index &&
 	newtree=$(git write-tree) &&
 	test "$newtree" = "$tree"
 '
-- 
2.25.1
Taylor Blau· Oct 18, 2020, 03:55 UTC · re: Caleb Tillman · lore

Re: [Outreachy-Microproject][PATCH 1/1] t0000: replace an instant of test -f with test_path_is_file functions.

Hi Caleb,
On Sun, Oct 18, 2020 at 12:55:22AM +0000, Caleb Tillman wrote:
> The test_path_is* functions provide debug-friendly messages upon failure.

The body looks fine to me. Your subject is getting a little long, however. Typical guidance would be somewhere around 50 (at least in my opinion, I thought we had something in Documentation/CodingGuidelines, but I couldn't find anything).

Maybe something instead like:
  t0000: replace 'test -f' with helpers
or:
  t0000: modernize test style

If you're looking for inspiration, you can use `git log`'s `-S` flag to look for anything that mentions 'test_path_is_file' to see how similar patches have been written in the past. (When I was recommending alternatives, I ran "git log --oneline -Stest_path_is_file -- t").

> Signed-off-by: Caleb Tillman <caleb.tillman@gmail.com>
> --- Outrachy Microproject, revised submission

I think that you meant to put this "Outrachy ..." _below_ the triple-dash line. Incidentally, Git still applies this patch just fine, but it is easier for reviewers to pick it up if the "---" line is left alone.

Show 13 quoted lines
>  t/t0000-basic.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
> index 923281af93..eb99892a87 100755
> --- a/t/t0000-basic.sh
> +++ b/t/t0000-basic.sh
> @@ -1191,7 +1191,7 @@ test_expect_success 'writing this tree with --missing-ok' '
>  test_expect_success 'git read-tree followed by write-tree should be idempotent' '
>  	rm -f .git/index &&
>  	git read-tree $tree &&
> -	test -f .git/index &&
> +	test_path_is_file .git/index &&
This looks totally correct to me.

Thanks, Taylor

Junio C Hamano· Oct 18, 2020, 20:11 UTC · re: Taylor Blau · lore

Re: [Outreachy-Microproject][PATCH 1/1] t0000: replace an instant of test -f with test_path_is_file functions.

Taylor Blau <me@ttaylorr.com> writes:
Show 22 quoted lines
> Hi Caleb,
>
> On Sun, Oct 18, 2020 at 12:55:22AM +0000, Caleb Tillman wrote:
>> The test_path_is* functions provide debug-friendly messages upon failure.
>
> The body looks fine to me. Your subject is getting a little long,
> however. Typical guidance would be somewhere around 50 (at least in my
> opinion, I thought we had something in Documentation/CodingGuidelines,
> but I couldn't find anything).
>
> Maybe something instead like:
>
>   t0000: replace 'test -f' with helpers
>
> or:
>
>   t0000: modernize test style
>
> If you're looking for inspiration, you can use `git log`'s `-S` flag to
> look for anything that mentions 'test_path_is_file' to see how similar
> patches have been written in the past. (When I was recommending
> alternatives, I ran "git log --oneline -Stest_path_is_file -- t").
Thanks for a great educational input.
Show 12 quoted lines
>> diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
>> index 923281af93..eb99892a87 100755
>> --- a/t/t0000-basic.sh
>> +++ b/t/t0000-basic.sh
>> @@ -1191,7 +1191,7 @@ test_expect_success 'writing this tree with --missing-ok' '
>>  test_expect_success 'git read-tree followed by write-tree should be idempotent' '
>>  	rm -f .git/index &&
>>  	git read-tree $tree &&
>> -	test -f .git/index &&
>> +	test_path_is_file .git/index &&
>
> This looks totally correct to me.

By nature of "microproject" exchange, it is almost trivial to get the patch text right after an exchange. The problems are typically so easy that there is only one way to write the code part correctly.

Polishing proposed log message is much harder ;-)
Thanks.

← back to recent threads