* [PATCH 0/3] C99: declare bool experiment a success
@ 2025-07-14 13:26 Phillip Wood
  2025-07-14 13:27 ` [PATCH 1/3] CodingGuildlines: allow the use of bool Phillip Wood
                   ` (4 more replies)
  0 siblings, 5 replies; 33+ messages in thread
From: Phillip Wood @ 2025-07-14 13:26 UTC (permalink / raw)
  To: git; +Cc: René Scharfe
From: Phillip Wood <phillip.wood@dunelm.org.uk>
We've had a test balloon for C99's bool type since 8277dbe987
(git-compat-util: convert skip_{prefix,suffix}{,_mem} to bool,
2023-12-16). As it has been over 18 months since this was added and
there have been no complaints let's declare it a success and convert
the return type our other string predicates to match.
Base-Commit: a30f80fde927d70950b3b4d1820813480968fb0d
Published-As: https://github.com/phillipwood/git/releases/tag/pw%2Fuse-c99-bool%2Fv1
View-Changes-At: https://github.com/phillipwood/git/compare/a30f80fde...7eaf80420
Fetch-It-Via: git fetch https://github.com/phillipwood/git pw/use-c99-bool/v1
Phillip Wood (3):
  CodingGuildlines: allow the use of bool
  git-compat-util: convert string predicates to return bool
  strbuf: convert predicates to return bool
 Documentation/CodingGuidelines |  3 +++
 git-compat-util.h              | 12 ++++++------
 strbuf.c                       | 28 ++++++++++++++--------------
 strbuf.h                       | 12 ++++++------
 4 files changed, 29 insertions(+), 26 deletions(-)
-- 
2.49.0.897.gfad3eb7d210
^ permalink raw reply	[flat|nested] 33+ messages in thread
* [PATCH 1/3] CodingGuildlines: allow the use of bool
  2025-07-14 13:26 [PATCH 0/3] C99: declare bool experiment a success Phillip Wood
@ 2025-07-14 13:27 ` Phillip Wood
  2025-07-14 16:37   ` Junio C Hamano
  2025-07-14 13:27 ` [PATCH 2/3] git-compat-util: convert string predicates to return bool Phillip Wood
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 33+ messages in thread
From: Phillip Wood @ 2025-07-14 13:27 UTC (permalink / raw)
  To: git; +Cc: René Scharfe, Phillip Wood
From: Phillip Wood <phillip.wood@dunelm.org.uk>
We have had a test balloon for C99's bool type since 8277dbe987
(git-compat-util: convert skip_{prefix,suffix}{,_mem} to bool,
2023-12-16). As we've had it over 18 months without any complaints
let's declare it a success.
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
---
 Documentation/CodingGuidelines | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
index 6350949f2ef..528b42d1dd1 100644
--- a/Documentation/CodingGuidelines
+++ b/Documentation/CodingGuidelines
@@ -298,6 +298,9 @@ For C programs:
    . since late 2021 with 44ba10d6, we have had variables declared in
      the for loop "for (int i = 0; i < 10; i++)".
 
+   . since late 2023 with 8277dbe987 we have been using the bool type
+     from <stdbool.h>.
+
    New C99 features that we cannot use yet:
 
    . %z and %zu as a printf() argument for a size_t (the %z being for
-- 
2.49.0.897.gfad3eb7d210
^ permalink raw reply related	[flat|nested] 33+ messages in thread
* [PATCH 2/3] git-compat-util: convert string predicates to return bool
  2025-07-14 13:26 [PATCH 0/3] C99: declare bool experiment a success Phillip Wood
  2025-07-14 13:27 ` [PATCH 1/3] CodingGuildlines: allow the use of bool Phillip Wood
@ 2025-07-14 13:27 ` Phillip Wood
  2025-07-14 16:46   ` Eric Sunshine
  2025-07-14 17:20   ` Elijah Newren
  2025-07-14 13:27 ` [PATCH 3/3] strbuf: convert " Phillip Wood
                   ` (2 subsequent siblings)
  4 siblings, 2 replies; 33+ messages in thread
From: Phillip Wood @ 2025-07-14 13:27 UTC (permalink / raw)
  To: git; +Cc: René Scharfe, Phillip Wood
From: Phillip Wood <phillip.wood@dunelm.org.uk>
Since 8277dbe987 (git-compat-util: convert skip_{prefix,suffix}{,_mem}
to bool, 2023-12-16) a number of our sting predicates have been
returning bool instead of int. Now we've declared that experiment
a success lets convert the return type the case independent
skip_iprefix() and skip_iprefix_mem() functions to match the return
type of their case dependent equivalents. Returning bool instead of
int makes it clear that these functions are predicates.
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
---
 git-compat-util.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/git-compat-util.h b/git-compat-util.h
index 5bd69ec0403..9408f463e31 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -897,35 +897,35 @@ static inline size_t xsize_t(off_t len)
  * is done via tolower(), so it is strictly ASCII (no multi-byte characters or
  * locale-specific conversions).
  */
-static inline int skip_iprefix(const char *str, const char *prefix,
+static inline bool skip_iprefix(const char *str, const char *prefix,
 			       const char **out)
 {
 	do {
 		if (!*prefix) {
 			*out = str;
-			return 1;
+			return true;
 		}
 	} while (tolower(*str++) == tolower(*prefix++));
-	return 0;
+	return false;
 }
 
 /*
  * Like skip_prefix_mem, but compare case-insensitively. Note that the
  * comparison is done via tolower(), so it is strictly ASCII (no multi-byte
  * characters or locale-specific conversions).
  */
-static inline int skip_iprefix_mem(const char *buf, size_t len,
+static inline bool skip_iprefix_mem(const char *buf, size_t len,
 				   const char *prefix,
 				   const char **out, size_t *outlen)
 {
 	do {
 		if (!*prefix) {
 			*out = buf;
 			*outlen = len;
-			return 1;
+			return true;
 		}
 	} while (len-- > 0 && tolower(*buf++) == tolower(*prefix++));
-	return 0;
+	return false;
 }
 
 static inline int strtoul_ui(char const *s, int base, unsigned int *result)
-- 
2.49.0.897.gfad3eb7d210
^ permalink raw reply related	[flat|nested] 33+ messages in thread
* [PATCH 3/3] strbuf: convert predicates to return bool
  2025-07-14 13:26 [PATCH 0/3] C99: declare bool experiment a success Phillip Wood
  2025-07-14 13:27 ` [PATCH 1/3] CodingGuildlines: allow the use of bool Phillip Wood
  2025-07-14 13:27 ` [PATCH 2/3] git-compat-util: convert string predicates to return bool Phillip Wood
@ 2025-07-14 13:27 ` Phillip Wood
  2025-07-15 13:52 ` [PATCH v2 0/3] C99: declare bool experiment a success Phillip Wood
  2025-07-16  9:38 ` [PATCH v3 " Phillip Wood
  4 siblings, 0 replies; 33+ messages in thread
From: Phillip Wood @ 2025-07-14 13:27 UTC (permalink / raw)
  To: git; +Cc: René Scharfe, Phillip Wood
From: Phillip Wood <phillip.wood@dunelm.org.uk>
Now that the string predicates defined in git-compat-util.h all
return bool let's convert the return type of the string predicates
in strbuf.{c,h} to match them.
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
---
 strbuf.c | 28 ++++++++++++++--------------
 strbuf.h | 12 ++++++------
 2 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/strbuf.c b/strbuf.c
index f30fdc69843..6c3851a7f84 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -8,55 +8,55 @@
 #include "utf8.h"
 #include "date.h"
 
-int starts_with(const char *str, const char *prefix)
+bool starts_with(const char *str, const char *prefix)
 {
 	for (; ; str++, prefix++)
 		if (!*prefix)
-			return 1;
+			return true;
 		else if (*str != *prefix)
-			return 0;
+			return false;
 }
 
-int istarts_with(const char *str, const char *prefix)
+bool istarts_with(const char *str, const char *prefix)
 {
 	for (; ; str++, prefix++)
 		if (!*prefix)
-			return 1;
+			return true;
 		else if (tolower(*str) != tolower(*prefix))
-			return 0;
+			return false;
 }
 
-int starts_with_mem(const char *str, size_t len, const char *prefix)
+bool starts_with_mem(const char *str, size_t len, const char *prefix)
 {
 	const char *end = str + len;
 	for (; ; str++, prefix++) {
 		if (!*prefix)
-			return 1;
+			return true;
 		else if (str == end || *str != *prefix)
-			return 0;
+			return false;
 	}
 }
 
-int skip_to_optional_arg_default(const char *str, const char *prefix,
+bool skip_to_optional_arg_default(const char *str, const char *prefix,
 				 const char **arg, const char *def)
 {
 	const char *p;
 
 	if (!skip_prefix(str, prefix, &p))
-		return 0;
+		return false;
 
 	if (!*p) {
 		if (arg)
 			*arg = def;
-		return 1;
+		return true;
 	}
 
 	if (*p != '=')
-		return 0;
+		return false;
 
 	if (arg)
 		*arg = p + 1;
-	return 1;
+	return true;
 }
 
 /*
diff --git a/strbuf.h b/strbuf.h
index 6362777c0a0..a580ac6084b 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -660,9 +660,9 @@ char *xstrvfmt(const char *fmt, va_list ap);
 __attribute__((format (printf, 1, 2)))
 char *xstrfmt(const char *fmt, ...);
 
-int starts_with(const char *str, const char *prefix);
-int istarts_with(const char *str, const char *prefix);
-int starts_with_mem(const char *str, size_t len, const char *prefix);
+bool starts_with(const char *str, const char *prefix);
+bool istarts_with(const char *str, const char *prefix);
+bool starts_with_mem(const char *str, size_t len, const char *prefix);
 
 /*
  * If the string "str" is the same as the string in "prefix", then the "arg"
@@ -678,16 +678,16 @@ int starts_with_mem(const char *str, size_t len, const char *prefix);
  * can be used instead of !strcmp(arg, "--key") and then
  * skip_prefix(arg, "--key=", &arg) to parse such an option.
  */
-int skip_to_optional_arg_default(const char *str, const char *prefix,
+bool skip_to_optional_arg_default(const char *str, const char *prefix,
 				 const char **arg, const char *def);
 
-static inline int skip_to_optional_arg(const char *str, const char *prefix,
+static inline bool skip_to_optional_arg(const char *str, const char *prefix,
 				       const char **arg)
 {
 	return skip_to_optional_arg_default(str, prefix, arg, "");
 }
 
-static inline int ends_with(const char *str, const char *suffix)
+static inline bool ends_with(const char *str, const char *suffix)
 {
 	size_t len;
 	return strip_suffix(str, suffix, &len);
-- 
2.49.0.897.gfad3eb7d210
^ permalink raw reply related	[flat|nested] 33+ messages in thread
* Re: [PATCH 1/3] CodingGuildlines: allow the use of bool
  2025-07-14 13:27 ` [PATCH 1/3] CodingGuildlines: allow the use of bool Phillip Wood
@ 2025-07-14 16:37   ` Junio C Hamano
  0 siblings, 0 replies; 33+ messages in thread
From: Junio C Hamano @ 2025-07-14 16:37 UTC (permalink / raw)
  To: Phillip Wood; +Cc: git, René Scharfe
Phillip Wood <phillip.wood123@gmail.com> writes:
> From: Phillip Wood <phillip.wood@dunelm.org.uk>
>
> We have had a test balloon for C99's bool type since 8277dbe987
> (git-compat-util: convert skip_{prefix,suffix}{,_mem} to bool,
> 2023-12-16). As we've had it over 18 months without any complaints
> let's declare it a success.
>
> Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
> ---
>  Documentation/CodingGuidelines | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
> index 6350949f2ef..528b42d1dd1 100644
> --- a/Documentation/CodingGuidelines
> +++ b/Documentation/CodingGuidelines
> @@ -298,6 +298,9 @@ For C programs:
>     . since late 2021 with 44ba10d6, we have had variables declared in
>       the for loop "for (int i = 0; i < 10; i++)".
>  
> +   . since late 2023 with 8277dbe987 we have been using the bool type
> +     from <stdbool.h>.
Let's see the other ones in the same list.
 * initializer elements that are not static (used since 2b6854c8
   (Cleanup variables in cat-file, 2007-04-21), declared official
   with 442c27dd (CodingGuidelines: mention dynamic C99 initializer
   elements, 2022-10-10).
 * trailing comma in enum definition (used since e1327023 (grep:
   refactor the concept of "grep source" into an object,
   2012-02-02), declared official with cc0c4297 (CodingGuidelines:
   spell out post-C89 rules, 2019-07-16).
 * designated initialiers for struct and arrays (used since cbc0f81d
   (strbuf: use designated initializers in STRBUF_INIT, 2017-07-10)
   and 512f41cf (clean.c: use designated initializer, 2017-07-14),
   declared official with cc0c4297 (CodingGuidelines: spell out
   post-C89 rules, 2019-07-16).
 * variadic macros (used since 765dc168 (git-compat-util: always
   enable variadic macros, 2021-01-28), declared official with
   56a29d2c (C99: remove hardcoded-out !HAVE_VARIADIC_MACROS code,
   2022-02-21).
 * declaring a control variable in for(;;) loop (used since 44ba10d6
   (revision: use C99 declaration of variable in for() loop,
   2021-11-14), declared official with 82dd01d8 (CodingGuidelines:
   allow declaring variables in for loops, 2022-10-10).
A year and a half sounds roughly the average timespan.
Will queue.  Thanks.
^ permalink raw reply	[flat|nested] 33+ messages in thread
* Re: [PATCH 2/3] git-compat-util: convert string predicates to return bool
  2025-07-14 13:27 ` [PATCH 2/3] git-compat-util: convert string predicates to return bool Phillip Wood
@ 2025-07-14 16:46   ` Eric Sunshine
  2025-07-14 17:20   ` Elijah Newren
  1 sibling, 0 replies; 33+ messages in thread
From: Eric Sunshine @ 2025-07-14 16:46 UTC (permalink / raw)
  To: Phillip Wood; +Cc: git, René Scharfe, Phillip Wood
On Mon, Jul 14, 2025 at 9:31 AM Phillip Wood <phillip.wood123@gmail.com> wrote:
> Since 8277dbe987 (git-compat-util: convert skip_{prefix,suffix}{,_mem}
> to bool, 2023-12-16) a number of our sting predicates have been
s/sting/string/
> returning bool instead of int. Now we've declared that experiment
> a success lets convert the return type the case independent
s/lets/let's/
/type/& of/
> skip_iprefix() and skip_iprefix_mem() functions to match the return
> type of their case dependent equivalents. Returning bool instead of
> int makes it clear that these functions are predicates.
>
> Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
^ permalink raw reply	[flat|nested] 33+ messages in thread
* Re: [PATCH 2/3] git-compat-util: convert string predicates to return bool
  2025-07-14 13:27 ` [PATCH 2/3] git-compat-util: convert string predicates to return bool Phillip Wood
  2025-07-14 16:46   ` Eric Sunshine
@ 2025-07-14 17:20   ` Elijah Newren
  2025-07-14 21:14     ` brian m. carlson
  1 sibling, 1 reply; 33+ messages in thread
From: Elijah Newren @ 2025-07-14 17:20 UTC (permalink / raw)
  To: Phillip Wood; +Cc: git, René Scharfe, Phillip Wood
On Mon, Jul 14, 2025 at 6:32 AM Phillip Wood <phillip.wood123@gmail.com> wrote:
>
> From: Phillip Wood <phillip.wood@dunelm.org.uk>
>
> Since 8277dbe987 (git-compat-util: convert skip_{prefix,suffix}{,_mem}
> to bool, 2023-12-16) a number of our sting predicates have been
> returning bool instead of int. Now we've declared that experiment
Now we've -> Now that we've
> a success lets convert the return type the case independent
success lets -> success, let's
type the -> type of the
> skip_iprefix() and skip_iprefix_mem() functions to match the return
> type of their case dependent equivalents. Returning bool instead of
I wonder if case-independent and case-dependent should be hyphenated,
or as separate words as you had them.  Anyone know?
> int makes it clear that these functions are predicates.
>
> Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
> ---
>  git-compat-util.h | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/git-compat-util.h b/git-compat-util.h
> index 5bd69ec0403..9408f463e31 100644
> --- a/git-compat-util.h
> +++ b/git-compat-util.h
> @@ -897,35 +897,35 @@ static inline size_t xsize_t(off_t len)
>   * is done via tolower(), so it is strictly ASCII (no multi-byte characters or
>   * locale-specific conversions).
>   */
> -static inline int skip_iprefix(const char *str, const char *prefix,
> +static inline bool skip_iprefix(const char *str, const char *prefix,
>                                const char **out)
>  {
>         do {
>                 if (!*prefix) {
>                         *out = str;
> -                       return 1;
> +                       return true;
>                 }
>         } while (tolower(*str++) == tolower(*prefix++));
> -       return 0;
> +       return false;
>  }
>
>  /*
>   * Like skip_prefix_mem, but compare case-insensitively. Note that the
>   * comparison is done via tolower(), so it is strictly ASCII (no multi-byte
>   * characters or locale-specific conversions).
>   */
> -static inline int skip_iprefix_mem(const char *buf, size_t len,
> +static inline bool skip_iprefix_mem(const char *buf, size_t len,
>                                    const char *prefix,
>                                    const char **out, size_t *outlen)
>  {
>         do {
>                 if (!*prefix) {
>                         *out = buf;
>                         *outlen = len;
> -                       return 1;
> +                       return true;
>                 }
>         } while (len-- > 0 && tolower(*buf++) == tolower(*prefix++));
> -       return 0;
> +       return false;
>  }
>
>  static inline int strtoul_ui(char const *s, int base, unsigned int *result)
> --
> 2.49.0.897.gfad3eb7d210
Patch looks good.
^ permalink raw reply	[flat|nested] 33+ messages in thread
* Re: [PATCH 2/3] git-compat-util: convert string predicates to return bool
  2025-07-14 17:20   ` Elijah Newren
@ 2025-07-14 21:14     ` brian m. carlson
  2025-07-15  9:36       ` Phillip Wood
  0 siblings, 1 reply; 33+ messages in thread
From: brian m. carlson @ 2025-07-14 21:14 UTC (permalink / raw)
  To: Elijah Newren; +Cc: Phillip Wood, git, René Scharfe, Phillip Wood
[-- Attachment #1: Type: text/plain, Size: 1593 bytes --]
On 2025-07-14 at 17:20:08, Elijah Newren wrote:
> On Mon, Jul 14, 2025 at 6:32 AM Phillip Wood <phillip.wood123@gmail.com> wrote:
> >
> > From: Phillip Wood <phillip.wood@dunelm.org.uk>
> >
> > Since 8277dbe987 (git-compat-util: convert skip_{prefix,suffix}{,_mem}
> > to bool, 2023-12-16) a number of our sting predicates have been
> > returning bool instead of int. Now we've declared that experiment
> 
> Now we've -> Now that we've
> 
> > a success lets convert the return type the case independent
> 
> success lets -> success, let's
> type the -> type of the
> 
> > skip_iprefix() and skip_iprefix_mem() functions to match the return
> > type of their case dependent equivalents. Returning bool instead of
> 
> I wonder if case-independent and case-dependent should be hyphenated,
> or as separate words as you had them.  Anyone know?
I would hyphenate them.  The Chicago Manual of Style, 18th Edition, says
in § 7.91, “When compound modifiers (also called phrasal adjectives)
such as _high-profile_ or _book-length_ precede a noun, hyphenation
usually lends clarity.  With the exception of proper nouns (such as
_United States_) and compounds formed by an adverb ending in _-ly_ plus
an adjective…, it is never incorrect to hyphenate adjectival compounds
before a noun.”
They go on to state that hyphenation is usually omitted _after_ a noun.
I usually follow this rule in my writing and commit messages and I
haven't gotten any complaints or comments about it, for what it's worth.
-- 
brian m. carlson (they/them)
Toronto, Ontario, CA
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 262 bytes --]
^ permalink raw reply	[flat|nested] 33+ messages in thread
* Re: [PATCH 2/3] git-compat-util: convert string predicates to return bool
  2025-07-14 21:14     ` brian m. carlson
@ 2025-07-15  9:36       ` Phillip Wood
  0 siblings, 0 replies; 33+ messages in thread
From: Phillip Wood @ 2025-07-15  9:36 UTC (permalink / raw)
  To: brian m. carlson, Elijah Newren, Phillip Wood, git,
	René Scharfe
  Cc: Eric Sunshine
On 14/07/2025 22:14, brian m. carlson wrote:
> On 2025-07-14 at 17:20:08, Elijah Newren wrote:
>> On Mon, Jul 14, 2025 at 6:32 AM Phillip Wood <phillip.wood123@gmail.com> wrote:
>>>
>> I wonder if case-independent and case-dependent should be hyphenated,
>> or as separate words as you had them.  Anyone know?
> 
> I would hyphenate them.  The Chicago Manual of Style, 18th Edition, says
> in § 7.91, “When compound modifiers (also called phrasal adjectives)
> such as _high-profile_ or _book-length_ precede a noun, hyphenation
> usually lends clarity.  With the exception of proper nouns (such as
> _United States_) and compounds formed by an adverb ending in _-ly_ plus
> an adjective…, it is never incorrect to hyphenate adjectival compounds
> before a noun.”
> 
> They go on to state that hyphenation is usually omitted _after_ a noun.
> 
> I usually follow this rule in my writing and commit messages and I
> haven't gotten any complaints or comments about it, for what it's worth.
Thanks for that - I'll hyphenate them then.
Thank you also to Elijah and Eric for the typo fixes - I seem to have 
had my brain turned off when I proofread this message.
Phillip
^ permalink raw reply	[flat|nested] 33+ messages in thread
* [PATCH v2 0/3] C99: declare bool experiment a success
  2025-07-14 13:26 [PATCH 0/3] C99: declare bool experiment a success Phillip Wood
                   ` (2 preceding siblings ...)
  2025-07-14 13:27 ` [PATCH 3/3] strbuf: convert " Phillip Wood
@ 2025-07-15 13:52 ` Phillip Wood
  2025-07-15 13:52   ` [PATCH v2 1/3] CodingGuildlines: allow the use of bool Phillip Wood
                     ` (4 more replies)
  2025-07-16  9:38 ` [PATCH v3 " Phillip Wood
  4 siblings, 5 replies; 33+ messages in thread
From: Phillip Wood @ 2025-07-15 13:52 UTC (permalink / raw)
  To: git; +Cc: René Scharfe, Brian M . Carlson, Elijah Newren,
	Eric Sunshine
From: Phillip Wood <phillip.wood@dunelm.org.uk>
We've had a test balloon for C99's bool type since 8277dbe987
(git-compat-util: convert skip_{prefix,suffix}{,_mem} to bool,
2023-12-16). As it has been over 18 months since this was added and
there have been no complaints let's declare it a success and convert
the return type our other string predicates to match.
Thank you to everyone who commented on V1, the only change here is
to fix the typos in the commit message for patch 2.
Base-Commit: a30f80fde927d70950b3b4d1820813480968fb0d
Published-As: https://github.com/phillipwood/git/releases/tag/pw%2Fuse-c99-bool%2Fv2
View-Changes-At: https://github.com/phillipwood/git/compare/a30f80fde...669687147
Fetch-It-Via: git fetch https://github.com/phillipwood/git pw/use-c99-bool/v2
Phillip Wood (3):
  CodingGuildlines: allow the use of bool
  git-compat-util: convert string predicates to return bool
  strbuf: convert predicates to return bool
 Documentation/CodingGuidelines |  3 +++
 git-compat-util.h              | 12 ++++++------
 strbuf.c                       | 28 ++++++++++++++--------------
 strbuf.h                       | 12 ++++++------
 4 files changed, 29 insertions(+), 26 deletions(-)
Range-diff against v1:
1:  352f80c49b7 = 1:  352f80c49b7 CodingGuildlines: allow the use of bool
2:  a0f9182aa20 ! 2:  0b2402e11cc git-compat-util: convert string predicates to return bool
    @@ Commit message
         git-compat-util: convert string predicates to return bool
     
         Since 8277dbe987 (git-compat-util: convert skip_{prefix,suffix}{,_mem}
    -    to bool, 2023-12-16) a number of our sting predicates have been
    -    returning bool instead of int. Now we've declared that experiment
    -    a success lets convert the return type the case independent
    +    to bool, 2023-12-16) a number of our string predicates have been
    +    returning bool instead of int. Now that we've declared that experiment
    +    a success, let's convert the return type of the case-independent
         skip_iprefix() and skip_iprefix_mem() functions to match the return
    -    type of their case dependent equivalents. Returning bool instead of
    +    type of their case-dependent equivalents. Returning bool instead of
         int makes it clear that these functions are predicates.
     
         Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
3:  7eaf8042061 = 3:  66968714739 strbuf: convert predicates to return bool
-- 
2.49.0.897.gfad3eb7d210
^ permalink raw reply	[flat|nested] 33+ messages in thread
* [PATCH v2 1/3] CodingGuildlines: allow the use of bool
  2025-07-15 13:52 ` [PATCH v2 0/3] C99: declare bool experiment a success Phillip Wood
@ 2025-07-15 13:52   ` Phillip Wood
  2025-07-16  4:38     ` Jeff King
  2025-07-15 13:52   ` [PATCH v2 2/3] git-compat-util: convert string predicates to return bool Phillip Wood
                     ` (3 subsequent siblings)
  4 siblings, 1 reply; 33+ messages in thread
From: Phillip Wood @ 2025-07-15 13:52 UTC (permalink / raw)
  To: git
  Cc: René Scharfe, Brian M . Carlson, Elijah Newren,
	Eric Sunshine, Phillip Wood
From: Phillip Wood <phillip.wood@dunelm.org.uk>
We have had a test balloon for C99's bool type since 8277dbe987
(git-compat-util: convert skip_{prefix,suffix}{,_mem} to bool,
2023-12-16). As we've had it over 18 months without any complaints
let's declare it a success.
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
---
 Documentation/CodingGuidelines | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
index 6350949f2ef..528b42d1dd1 100644
--- a/Documentation/CodingGuidelines
+++ b/Documentation/CodingGuidelines
@@ -298,6 +298,9 @@ For C programs:
    . since late 2021 with 44ba10d6, we have had variables declared in
      the for loop "for (int i = 0; i < 10; i++)".
 
+   . since late 2023 with 8277dbe987 we have been using the bool type
+     from <stdbool.h>.
+
    New C99 features that we cannot use yet:
 
    . %z and %zu as a printf() argument for a size_t (the %z being for
-- 
2.49.0.897.gfad3eb7d210
^ permalink raw reply related	[flat|nested] 33+ messages in thread
* [PATCH v2 2/3] git-compat-util: convert string predicates to return bool
  2025-07-15 13:52 ` [PATCH v2 0/3] C99: declare bool experiment a success Phillip Wood
  2025-07-15 13:52   ` [PATCH v2 1/3] CodingGuildlines: allow the use of bool Phillip Wood
@ 2025-07-15 13:52   ` Phillip Wood
  2025-07-15 13:52   ` [PATCH v2 3/3] strbuf: convert " Phillip Wood
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 33+ messages in thread
From: Phillip Wood @ 2025-07-15 13:52 UTC (permalink / raw)
  To: git
  Cc: René Scharfe, Brian M . Carlson, Elijah Newren,
	Eric Sunshine, Phillip Wood
From: Phillip Wood <phillip.wood@dunelm.org.uk>
Since 8277dbe987 (git-compat-util: convert skip_{prefix,suffix}{,_mem}
to bool, 2023-12-16) a number of our string predicates have been
returning bool instead of int. Now that we've declared that experiment
a success, let's convert the return type of the case-independent
skip_iprefix() and skip_iprefix_mem() functions to match the return
type of their case-dependent equivalents. Returning bool instead of
int makes it clear that these functions are predicates.
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
---
 git-compat-util.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/git-compat-util.h b/git-compat-util.h
index 5bd69ec0403..9408f463e31 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -897,35 +897,35 @@ static inline size_t xsize_t(off_t len)
  * is done via tolower(), so it is strictly ASCII (no multi-byte characters or
  * locale-specific conversions).
  */
-static inline int skip_iprefix(const char *str, const char *prefix,
+static inline bool skip_iprefix(const char *str, const char *prefix,
 			       const char **out)
 {
 	do {
 		if (!*prefix) {
 			*out = str;
-			return 1;
+			return true;
 		}
 	} while (tolower(*str++) == tolower(*prefix++));
-	return 0;
+	return false;
 }
 
 /*
  * Like skip_prefix_mem, but compare case-insensitively. Note that the
  * comparison is done via tolower(), so it is strictly ASCII (no multi-byte
  * characters or locale-specific conversions).
  */
-static inline int skip_iprefix_mem(const char *buf, size_t len,
+static inline bool skip_iprefix_mem(const char *buf, size_t len,
 				   const char *prefix,
 				   const char **out, size_t *outlen)
 {
 	do {
 		if (!*prefix) {
 			*out = buf;
 			*outlen = len;
-			return 1;
+			return true;
 		}
 	} while (len-- > 0 && tolower(*buf++) == tolower(*prefix++));
-	return 0;
+	return false;
 }
 
 static inline int strtoul_ui(char const *s, int base, unsigned int *result)
-- 
2.49.0.897.gfad3eb7d210
^ permalink raw reply related	[flat|nested] 33+ messages in thread
* [PATCH v2 3/3] strbuf: convert predicates to return bool
  2025-07-15 13:52 ` [PATCH v2 0/3] C99: declare bool experiment a success Phillip Wood
  2025-07-15 13:52   ` [PATCH v2 1/3] CodingGuildlines: allow the use of bool Phillip Wood
  2025-07-15 13:52   ` [PATCH v2 2/3] git-compat-util: convert string predicates to return bool Phillip Wood
@ 2025-07-15 13:52   ` Phillip Wood
  2025-07-15 17:19   ` [PATCH v2 0/3] C99: declare bool experiment a success Elijah Newren
  2025-07-15 21:48   ` brian m. carlson
  4 siblings, 0 replies; 33+ messages in thread
From: Phillip Wood @ 2025-07-15 13:52 UTC (permalink / raw)
  To: git
  Cc: René Scharfe, Brian M . Carlson, Elijah Newren,
	Eric Sunshine, Phillip Wood
From: Phillip Wood <phillip.wood@dunelm.org.uk>
Now that the string predicates defined in git-compat-util.h all
return bool let's convert the return type of the string predicates
in strbuf.{c,h} to match them.
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
---
 strbuf.c | 28 ++++++++++++++--------------
 strbuf.h | 12 ++++++------
 2 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/strbuf.c b/strbuf.c
index f30fdc69843..6c3851a7f84 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -8,55 +8,55 @@
 #include "utf8.h"
 #include "date.h"
 
-int starts_with(const char *str, const char *prefix)
+bool starts_with(const char *str, const char *prefix)
 {
 	for (; ; str++, prefix++)
 		if (!*prefix)
-			return 1;
+			return true;
 		else if (*str != *prefix)
-			return 0;
+			return false;
 }
 
-int istarts_with(const char *str, const char *prefix)
+bool istarts_with(const char *str, const char *prefix)
 {
 	for (; ; str++, prefix++)
 		if (!*prefix)
-			return 1;
+			return true;
 		else if (tolower(*str) != tolower(*prefix))
-			return 0;
+			return false;
 }
 
-int starts_with_mem(const char *str, size_t len, const char *prefix)
+bool starts_with_mem(const char *str, size_t len, const char *prefix)
 {
 	const char *end = str + len;
 	for (; ; str++, prefix++) {
 		if (!*prefix)
-			return 1;
+			return true;
 		else if (str == end || *str != *prefix)
-			return 0;
+			return false;
 	}
 }
 
-int skip_to_optional_arg_default(const char *str, const char *prefix,
+bool skip_to_optional_arg_default(const char *str, const char *prefix,
 				 const char **arg, const char *def)
 {
 	const char *p;
 
 	if (!skip_prefix(str, prefix, &p))
-		return 0;
+		return false;
 
 	if (!*p) {
 		if (arg)
 			*arg = def;
-		return 1;
+		return true;
 	}
 
 	if (*p != '=')
-		return 0;
+		return false;
 
 	if (arg)
 		*arg = p + 1;
-	return 1;
+	return true;
 }
 
 /*
diff --git a/strbuf.h b/strbuf.h
index 6362777c0a0..a580ac6084b 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -660,9 +660,9 @@ char *xstrvfmt(const char *fmt, va_list ap);
 __attribute__((format (printf, 1, 2)))
 char *xstrfmt(const char *fmt, ...);
 
-int starts_with(const char *str, const char *prefix);
-int istarts_with(const char *str, const char *prefix);
-int starts_with_mem(const char *str, size_t len, const char *prefix);
+bool starts_with(const char *str, const char *prefix);
+bool istarts_with(const char *str, const char *prefix);
+bool starts_with_mem(const char *str, size_t len, const char *prefix);
 
 /*
  * If the string "str" is the same as the string in "prefix", then the "arg"
@@ -678,16 +678,16 @@ int starts_with_mem(const char *str, size_t len, const char *prefix);
  * can be used instead of !strcmp(arg, "--key") and then
  * skip_prefix(arg, "--key=", &arg) to parse such an option.
  */
-int skip_to_optional_arg_default(const char *str, const char *prefix,
+bool skip_to_optional_arg_default(const char *str, const char *prefix,
 				 const char **arg, const char *def);
 
-static inline int skip_to_optional_arg(const char *str, const char *prefix,
+static inline bool skip_to_optional_arg(const char *str, const char *prefix,
 				       const char **arg)
 {
 	return skip_to_optional_arg_default(str, prefix, arg, "");
 }
 
-static inline int ends_with(const char *str, const char *suffix)
+static inline bool ends_with(const char *str, const char *suffix)
 {
 	size_t len;
 	return strip_suffix(str, suffix, &len);
-- 
2.49.0.897.gfad3eb7d210
^ permalink raw reply related	[flat|nested] 33+ messages in thread
* Re: [PATCH v2 0/3] C99: declare bool experiment a success
  2025-07-15 13:52 ` [PATCH v2 0/3] C99: declare bool experiment a success Phillip Wood
                     ` (2 preceding siblings ...)
  2025-07-15 13:52   ` [PATCH v2 3/3] strbuf: convert " Phillip Wood
@ 2025-07-15 17:19   ` Elijah Newren
  2025-07-15 18:23     ` rsbecker
  2025-07-15 18:53     ` Junio C Hamano
  2025-07-15 21:48   ` brian m. carlson
  4 siblings, 2 replies; 33+ messages in thread
From: Elijah Newren @ 2025-07-15 17:19 UTC (permalink / raw)
  To: Phillip Wood; +Cc: git, René Scharfe, Brian M . Carlson, Eric Sunshine
On Tue, Jul 15, 2025 at 6:53 AM Phillip Wood <phillip.wood123@gmail.com> wrote:
>
> From: Phillip Wood <phillip.wood@dunelm.org.uk>
>
> We've had a test balloon for C99's bool type since 8277dbe987
> (git-compat-util: convert skip_{prefix,suffix}{,_mem} to bool,
> 2023-12-16). As it has been over 18 months since this was added and
> there have been no complaints let's declare it a success and convert
> the return type our other string predicates to match.
>
> Thank you to everyone who commented on V1, the only change here is
> to fix the typos in the commit message for patch 2.
>
> Base-Commit: a30f80fde927d70950b3b4d1820813480968fb0d
> Published-As: https://github.com/phillipwood/git/releases/tag/pw%2Fuse-c99-bool%2Fv2
> View-Changes-At: https://github.com/phillipwood/git/compare/a30f80fde...669687147
> Fetch-It-Via: git fetch https://github.com/phillipwood/git pw/use-c99-bool/v2
>
>
> Phillip Wood (3):
>   CodingGuildlines: allow the use of bool
>   git-compat-util: convert string predicates to return bool
>   strbuf: convert predicates to return bool
>
>  Documentation/CodingGuidelines |  3 +++
>  git-compat-util.h              | 12 ++++++------
>  strbuf.c                       | 28 ++++++++++++++--------------
>  strbuf.h                       | 12 ++++++------
>  4 files changed, 29 insertions(+), 26 deletions(-)
>
> Range-diff against v1:
> 1:  352f80c49b7 = 1:  352f80c49b7 CodingGuildlines: allow the use of bool
> 2:  a0f9182aa20 ! 2:  0b2402e11cc git-compat-util: convert string predicates to return bool
>     @@ Commit message
>          git-compat-util: convert string predicates to return bool
>
>          Since 8277dbe987 (git-compat-util: convert skip_{prefix,suffix}{,_mem}
>     -    to bool, 2023-12-16) a number of our sting predicates have been
>     -    returning bool instead of int. Now we've declared that experiment
>     -    a success lets convert the return type the case independent
>     +    to bool, 2023-12-16) a number of our string predicates have been
>     +    returning bool instead of int. Now that we've declared that experiment
>     +    a success, let's convert the return type of the case-independent
>          skip_iprefix() and skip_iprefix_mem() functions to match the return
>     -    type of their case dependent equivalents. Returning bool instead of
>     +    type of their case-dependent equivalents. Returning bool instead of
>          int makes it clear that these functions are predicates.
>
>          Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
> 3:  7eaf8042061 = 3:  66968714739 strbuf: convert predicates to return bool
> --
> 2.49.0.897.gfad3eb7d210
This version looks good to me, thanks!
^ permalink raw reply	[flat|nested] 33+ messages in thread
* RE: [PATCH v2 0/3] C99: declare bool experiment a success
  2025-07-15 17:19   ` [PATCH v2 0/3] C99: declare bool experiment a success Elijah Newren
@ 2025-07-15 18:23     ` rsbecker
  2025-07-15 19:35       ` Elijah Newren
  2025-07-15 21:06       ` Junio C Hamano
  2025-07-15 18:53     ` Junio C Hamano
  1 sibling, 2 replies; 33+ messages in thread
From: rsbecker @ 2025-07-15 18:23 UTC (permalink / raw)
  To: 'Elijah Newren', 'Phillip Wood'
  Cc: git, 'René Scharfe', 'Brian M . Carlson',
	'Eric Sunshine'
On July 15, 2025 1:19 PM Elijah Newren wrote:
>On Tue, Jul 15, 2025 at 6:53 AM Phillip Wood <phillip.wood123@gmail.com>
>wrote:
>>
>> From: Phillip Wood <phillip.wood@dunelm.org.uk>
>>
>> We've had a test balloon for C99's bool type since 8277dbe987
>> (git-compat-util: convert skip_{prefix,suffix}{,_mem} to bool,
>> 2023-12-16). As it has been over 18 months since this was added and
>> there have been no complaints let's declare it a success and convert
>> the return type our other string predicates to match.
>>
>> Thank you to everyone who commented on V1, the only change here is to
>> fix the typos in the commit message for patch 2.
>>
>> Base-Commit: a30f80fde927d70950b3b4d1820813480968fb0d
>> Published-As:
>> https://github.com/phillipwood/git/releases/tag/pw%2Fuse-c99-bool%2Fv2
>> View-Changes-At:
>> https://github.com/phillipwood/git/compare/a30f80fde...669687147
>> Fetch-It-Via: git fetch https://github.com/phillipwood/git
>> pw/use-c99-bool/v2
>>
>>
>> Phillip Wood (3):
>>   CodingGuildlines: allow the use of bool
>>   git-compat-util: convert string predicates to return bool
>>   strbuf: convert predicates to return bool
>>
>>  Documentation/CodingGuidelines |  3 +++
>>  git-compat-util.h              | 12 ++++++------
>>  strbuf.c                       | 28 ++++++++++++++--------------
>>  strbuf.h                       | 12 ++++++------
>>  4 files changed, 29 insertions(+), 26 deletions(-)
>>
>> Range-diff against v1:
>> 1:  352f80c49b7 = 1:  352f80c49b7 CodingGuildlines: allow the use of
>> bool
>> 2:  a0f9182aa20 ! 2:  0b2402e11cc git-compat-util: convert string predicates to
>return bool
>>     @@ Commit message
>>          git-compat-util: convert string predicates to return bool
>>
>>          Since 8277dbe987 (git-compat-util: convert skip_{prefix,suffix}{,_mem}
>>     -    to bool, 2023-12-16) a number of our sting predicates have been
>>     -    returning bool instead of int. Now we've declared that experiment
>>     -    a success lets convert the return type the case independent
>>     +    to bool, 2023-12-16) a number of our string predicates have been
>>     +    returning bool instead of int. Now that we've declared that experiment
>>     +    a success, let's convert the return type of the case-independent
>>          skip_iprefix() and skip_iprefix_mem() functions to match the return
>>     -    type of their case dependent equivalents. Returning bool instead of
>>     +    type of their case-dependent equivalents. Returning bool instead of
>>          int makes it clear that these functions are predicates.
>>
>>          Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
>> 3:  7eaf8042061 = 3:  66968714739 strbuf: convert predicates to return
>> bool
bool is not standard in all c99 implementations. I have to #include <stdbool.h> in order to
use this type. Please make sure there is a mechanism for that.
^ permalink raw reply	[flat|nested] 33+ messages in thread
* Re: [PATCH v2 0/3] C99: declare bool experiment a success
  2025-07-15 17:19   ` [PATCH v2 0/3] C99: declare bool experiment a success Elijah Newren
  2025-07-15 18:23     ` rsbecker
@ 2025-07-15 18:53     ` Junio C Hamano
  1 sibling, 0 replies; 33+ messages in thread
From: Junio C Hamano @ 2025-07-15 18:53 UTC (permalink / raw)
  To: Elijah Newren
  Cc: Phillip Wood, git, René Scharfe, Brian M . Carlson,
	Eric Sunshine
Elijah Newren <newren@gmail.com> writes:
>>          Since 8277dbe987 (git-compat-util: convert skip_{prefix,suffix}{,_mem}
>>     -    to bool, 2023-12-16) a number of our sting predicates have been
>>     -    returning bool instead of int. Now we've declared that experiment
>>     -    a success lets convert the return type the case independent
>>     +    to bool, 2023-12-16) a number of our string predicates have been
>>     +    returning bool instead of int. Now that we've declared that experiment
>>     +    a success, let's convert the return type of the case-independent
>>          skip_iprefix() and skip_iprefix_mem() functions to match the return
>>     -    type of their case dependent equivalents. Returning bool instead of
>>     +    type of their case-dependent equivalents. Returning bool instead of
>>          int makes it clear that these functions are predicates.
>>
>>          Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
>> 3:  7eaf8042061 = 3:  66968714739 strbuf: convert predicates to return bool
>> --
>> 2.49.0.897.gfad3eb7d210
>
> This version looks good to me, thanks!
Thanks, looking good.
^ permalink raw reply	[flat|nested] 33+ messages in thread
* Re: [PATCH v2 0/3] C99: declare bool experiment a success
  2025-07-15 18:23     ` rsbecker
@ 2025-07-15 19:35       ` Elijah Newren
  2025-07-15 20:47         ` rsbecker
  2025-07-15 21:06       ` Junio C Hamano
  1 sibling, 1 reply; 33+ messages in thread
From: Elijah Newren @ 2025-07-15 19:35 UTC (permalink / raw)
  To: rsbecker
  Cc: Phillip Wood, git, René Scharfe, Brian M . Carlson,
	Eric Sunshine
On Tue, Jul 15, 2025 at 11:23 AM <rsbecker@nexbridge.com> wrote:
>
> On July 15, 2025 1:19 PM Elijah Newren wrote:
> >On Tue, Jul 15, 2025 at 6:53 AM Phillip Wood <phillip.wood123@gmail.com>
> >wrote:
> >>
> >> From: Phillip Wood <phillip.wood@dunelm.org.uk>
> >>
> >> We've had a test balloon for C99's bool type since 8277dbe987
> >> (git-compat-util: convert skip_{prefix,suffix}{,_mem} to bool,
> >> 2023-12-16). As it has been over 18 months since this was added and
> >> there have been no complaints let's declare it a success and convert
> >> the return type our other string predicates to match.
> >>
[...]
>
> bool is not standard in all c99 implementations. I have to #include <stdbool.h> in order to
> use this type. Please make sure there is a mechanism for that.
From the referenced commit in the commit message:
$ git log --oneline -1 -p 8277dbe987 | head -n 13
8277dbe9872 git-compat-util: convert skip_{prefix,suffix}{,_mem} to bool
diff --git a/git-compat-util.h b/git-compat-util.h
index 3e7a59b5ff1..603c97e3b3f 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -225,6 +225,7 @@ struct strbuf;
 #include <stddef.h>
 #include <stdlib.h>
 #include <stdarg.h>
+#include <stdbool.h>
 #include <string.h>
 #ifdef HAVE_STRINGS_H
 #include <strings.h> /* for strcasecmp() */
So, there's not only a mechanism for that, it has already been done
for you 1.5 years ago.  No extra work on your or anyone else's part
needed.  :-)
^ permalink raw reply related	[flat|nested] 33+ messages in thread
* RE: [PATCH v2 0/3] C99: declare bool experiment a success
  2025-07-15 19:35       ` Elijah Newren
@ 2025-07-15 20:47         ` rsbecker
  0 siblings, 0 replies; 33+ messages in thread
From: rsbecker @ 2025-07-15 20:47 UTC (permalink / raw)
  To: 'Elijah Newren'
  Cc: 'Phillip Wood', git, 'René Scharfe',
	'Brian M . Carlson', 'Eric Sunshine'
On July 15, 2025 3:35 PM, Elijah Newren wrote:
>On Tue, Jul 15, 2025 at 11:23 AM <rsbecker@nexbridge.com> wrote:
>>
>> On July 15, 2025 1:19 PM Elijah Newren wrote:
>> >On Tue, Jul 15, 2025 at 6:53 AM Phillip Wood
>> ><phillip.wood123@gmail.com>
>> >wrote:
>> >>
>> >> From: Phillip Wood <phillip.wood@dunelm.org.uk>
>> >>
>> >> We've had a test balloon for C99's bool type since 8277dbe987
>> >> (git-compat-util: convert skip_{prefix,suffix}{,_mem} to bool,
>> >> 2023-12-16). As it has been over 18 months since this was added and
>> >> there have been no complaints let's declare it a success and
>> >> convert the return type our other string predicates to match.
>> >>
>[...]
>>
>> bool is not standard in all c99 implementations. I have to #include
>> <stdbool.h> in order to use this type. Please make sure there is a mechanism for
>that.
>
>>From the referenced commit in the commit message:
>
>$ git log --oneline -1 -p 8277dbe987 | head -n 13
>8277dbe9872 git-compat-util: convert skip_{prefix,suffix}{,_mem} to bool diff --git
>a/git-compat-util.h b/git-compat-util.h index 3e7a59b5ff1..603c97e3b3f 100644
>--- a/git-compat-util.h
>+++ b/git-compat-util.h
>@@ -225,6 +225,7 @@ struct strbuf;
> #include <stddef.h>
> #include <stdlib.h>
> #include <stdarg.h>
>+#include <stdbool.h>
> #include <string.h>
> #ifdef HAVE_STRINGS_H
> #include <strings.h> /* for strcasecmp() */
>
>
>So, there's not only a mechanism for that, it has already been done for you 1.5
>years ago.  No extra work on your or anyone else's part needed.  :-)
Many thanks.
^ permalink raw reply	[flat|nested] 33+ messages in thread
* Re: [PATCH v2 0/3] C99: declare bool experiment a success
  2025-07-15 18:23     ` rsbecker
  2025-07-15 19:35       ` Elijah Newren
@ 2025-07-15 21:06       ` Junio C Hamano
  1 sibling, 0 replies; 33+ messages in thread
From: Junio C Hamano @ 2025-07-15 21:06 UTC (permalink / raw)
  To: rsbecker
  Cc: 'Elijah Newren', 'Phillip Wood', git,
	'René Scharfe', 'Brian M . Carlson',
	'Eric Sunshine'
<rsbecker@nexbridge.com> writes:
> bool is not standard in all c99 implementations. I have to #include <stdbool.h> in order to
> use this type. Please make sure there is a mechanism for that.
Given that <git-compat-util.h> unconditionally includes
<compat/posix.h> and <compat/posix.h> unconditionally includes
<stdbool.h> even in today's code, that should be OK.
^ permalink raw reply	[flat|nested] 33+ messages in thread
* Re: [PATCH v2 0/3] C99: declare bool experiment a success
  2025-07-15 13:52 ` [PATCH v2 0/3] C99: declare bool experiment a success Phillip Wood
                     ` (3 preceding siblings ...)
  2025-07-15 17:19   ` [PATCH v2 0/3] C99: declare bool experiment a success Elijah Newren
@ 2025-07-15 21:48   ` brian m. carlson
  2025-07-15 22:09     ` Junio C Hamano
  4 siblings, 1 reply; 33+ messages in thread
From: brian m. carlson @ 2025-07-15 21:48 UTC (permalink / raw)
  To: Phillip Wood; +Cc: git, René Scharfe, Elijah Newren, Eric Sunshine
[-- Attachment #1: Type: text/plain, Size: 901 bytes --]
On 2025-07-15 at 13:52:49, Phillip Wood wrote:
> From: Phillip Wood <phillip.wood@dunelm.org.uk>
> 
> We've had a test balloon for C99's bool type since 8277dbe987
> (git-compat-util: convert skip_{prefix,suffix}{,_mem} to bool,
> 2023-12-16). As it has been over 18 months since this was added and
> there have been no complaints let's declare it a success and convert
> the return type our other string predicates to match.
> 
> Thank you to everyone who commented on V1, the only change here is
> to fix the typos in the commit message for patch 2.
This series looked good to me.  I especially like the fact that we've
made it easier for me to figure out whether starts_with and friends are
booleans (that is, true if it starts with the value) or our standard
zero/negative-one (that is, false if it starts with the value).
-- 
brian m. carlson (they/them)
Toronto, Ontario, CA
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 262 bytes --]
^ permalink raw reply	[flat|nested] 33+ messages in thread
* Re: [PATCH v2 0/3] C99: declare bool experiment a success
  2025-07-15 21:48   ` brian m. carlson
@ 2025-07-15 22:09     ` Junio C Hamano
  0 siblings, 0 replies; 33+ messages in thread
From: Junio C Hamano @ 2025-07-15 22:09 UTC (permalink / raw)
  To: brian m. carlson
  Cc: Phillip Wood, git, René Scharfe, Elijah Newren,
	Eric Sunshine
"brian m. carlson" <sandals@crustytoothpaste.net> writes:
> This series looked good to me.  I especially like the fact that we've
> made it easier for me to figure out whether starts_with and friends are
> booleans (that is, true if it starts with the value) or our standard
> zero/negative-one (that is, false if it starts with the value).
Hmph, this is a tangent, I've never thought of it that way.
The "0 is success and negative is failure" is exactly about success
and failure.  We expect such a call to succeed most of the time and
failure is a note-worthy event.
Functions like starts_with() and friends, those that Lispers might
name with q suffix, are quite different.  A predicate is asking "is
it, or isn't it?" question and returning "false" from it does not
imply a failure in any way.
I wouldn't dream of making them return -1 for "failure", because
starts_with(buf.buf, "#") that finds buf.buf does not begin with "#"
is no way failing.
Anyway, we may start rewriting our old-fashioned idiom to normalize
a "true if non-zero" integers, i.e.
	return !!some_true_if_non_zero_integer_variable;
into 
	return (bool)some_true_if_non_zero_integer_variable;
perhaps ;-).
^ permalink raw reply	[flat|nested] 33+ messages in thread
* Re: [PATCH v2 1/3] CodingGuildlines: allow the use of bool
  2025-07-15 13:52   ` [PATCH v2 1/3] CodingGuildlines: allow the use of bool Phillip Wood
@ 2025-07-16  4:38     ` Jeff King
  2025-07-16  4:46       ` Jeff King
  0 siblings, 1 reply; 33+ messages in thread
From: Jeff King @ 2025-07-16  4:38 UTC (permalink / raw)
  To: Phillip Wood
  Cc: git, René Scharfe, Brian M . Carlson, Elijah Newren,
	Eric Sunshine, Phillip Wood
On Tue, Jul 15, 2025 at 02:52:50PM +0100, Phillip Wood wrote:
> Subject: Re: [PATCH v2 1/3] CodingGuildlines: allow the use of bool
I was lots of discussion about grammar elsewhere, but nobody seems to
have mentioned "Guildlines" instead of "Guidelines". :)
-Peff
^ permalink raw reply	[flat|nested] 33+ messages in thread
* Re: [PATCH v2 1/3] CodingGuildlines: allow the use of bool
  2025-07-16  4:38     ` Jeff King
@ 2025-07-16  4:46       ` Jeff King
  2025-07-16  5:06         ` Elijah Newren
  0 siblings, 1 reply; 33+ messages in thread
From: Jeff King @ 2025-07-16  4:46 UTC (permalink / raw)
  To: Phillip Wood
  Cc: git, René Scharfe, Brian M . Carlson, Elijah Newren,
	Eric Sunshine, Phillip Wood
On Wed, Jul 16, 2025 at 12:38:27AM -0400, Jeff King wrote:
> On Tue, Jul 15, 2025 at 02:52:50PM +0100, Phillip Wood wrote:
> 
> > Subject: Re: [PATCH v2 1/3] CodingGuildlines: allow the use of bool
> 
> I was lots of discussion about grammar elsewhere, but nobody seems to
> have mentioned "Guildlines" instead of "Guidelines". :)
s/was/saw/, obviously.
Surely somebody has coined a name for the law that any statement
pointing out a typo or grammatical issue is vastly more likely to
contain one itself.
-Peff
^ permalink raw reply	[flat|nested] 33+ messages in thread
* Re: [PATCH v2 1/3] CodingGuildlines: allow the use of bool
  2025-07-16  4:46       ` Jeff King
@ 2025-07-16  5:06         ` Elijah Newren
  0 siblings, 0 replies; 33+ messages in thread
From: Elijah Newren @ 2025-07-16  5:06 UTC (permalink / raw)
  To: Jeff King
  Cc: Phillip Wood, git, René Scharfe, Brian M . Carlson,
	Eric Sunshine, Phillip Wood
On Tue, Jul 15, 2025 at 9:46 PM Jeff King <peff@peff.net> wrote:
>
> On Wed, Jul 16, 2025 at 12:38:27AM -0400, Jeff King wrote:
>
> > On Tue, Jul 15, 2025 at 02:52:50PM +0100, Phillip Wood wrote:
> >
> > > Subject: Re: [PATCH v2 1/3] CodingGuildlines: allow the use of bool
> >
> > I was lots of discussion about grammar elsewhere, but nobody seems to
> > have mentioned "Guildlines" instead of "Guidelines". :)
>
> s/was/saw/, obviously.
hehe
> Surely somebody has coined a name for the law that any statement
> pointing out a typo or grammatical issue is vastly more likely to
> contain one itself.
https://en.wikipedia.org/wiki/Muphry%27s_law
^ permalink raw reply	[flat|nested] 33+ messages in thread
* [PATCH v3 0/3] C99: declare bool experiment a success
  2025-07-14 13:26 [PATCH 0/3] C99: declare bool experiment a success Phillip Wood
                   ` (3 preceding siblings ...)
  2025-07-15 13:52 ` [PATCH v2 0/3] C99: declare bool experiment a success Phillip Wood
@ 2025-07-16  9:38 ` Phillip Wood
  2025-07-16  9:38   ` [PATCH v3 1/3] CodingGuidelines: allow the use of bool Phillip Wood
                     ` (3 more replies)
  4 siblings, 4 replies; 33+ messages in thread
From: Phillip Wood @ 2025-07-16  9:38 UTC (permalink / raw)
  To: git
  Cc: René Scharfe, Brian M . Carlson, Elijah Newren,
	Eric Sunshine, Jeff King
From: Phillip Wood <phillip.wood@dunelm.org.uk>
We've had a test balloon for C99's bool type since 8277dbe987
(git-compat-util: convert skip_{prefix,suffix}{,_mem} to bool,
2023-12-16). As it has been over 18 months since this was added and
there have been no complaints let's declare it a success and convert
the return type our other string predicates to match.
Thanks to peff for spotting yet another typo - I've updated the commit
message for patch 1 accordingly.
Base-Commit: a30f80fde927d70950b3b4d1820813480968fb0d
Published-As: https://github.com/phillipwood/git/releases/tag/pw%2Fuse-c99-bool%2Fv3
View-Changes-At: https://github.com/phillipwood/git/compare/a30f80fde...80e5cd3b9
Fetch-It-Via: git fetch https://github.com/phillipwood/git pw/use-c99-bool/v3
Phillip Wood (3):
  CodingGuidelines: allow the use of bool
  git-compat-util: convert string predicates to return bool
  strbuf: convert predicates to return bool
 Documentation/CodingGuidelines |  3 +++
 git-compat-util.h              | 12 ++++++------
 strbuf.c                       | 28 ++++++++++++++--------------
 strbuf.h                       | 12 ++++++------
 4 files changed, 29 insertions(+), 26 deletions(-)
Range-diff against v2:
1:  352f80c49b7 ! 1:  3ff7ae61f45 CodingGuildlines: allow the use of bool
    @@ Metadata
     Author: Phillip Wood <phillip.wood@dunelm.org.uk>
     
      ## Commit message ##
    -    CodingGuildlines: allow the use of bool
    +    CodingGuidelines: allow the use of bool
     
         We have had a test balloon for C99's bool type since 8277dbe987
         (git-compat-util: convert skip_{prefix,suffix}{,_mem} to bool,
2:  0b2402e11cc = 2:  26c3f48ac6c git-compat-util: convert string predicates to return bool
3:  66968714739 = 3:  80e5cd3b9df strbuf: convert predicates to return bool
-- 
2.49.0.897.gfad3eb7d210
^ permalink raw reply	[flat|nested] 33+ messages in thread
* [PATCH v3 1/3] CodingGuidelines: allow the use of bool
  2025-07-16  9:38 ` [PATCH v3 " Phillip Wood
@ 2025-07-16  9:38   ` Phillip Wood
  2025-07-16  9:38   ` [PATCH v3 2/3] git-compat-util: convert string predicates to return bool Phillip Wood
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 33+ messages in thread
From: Phillip Wood @ 2025-07-16  9:38 UTC (permalink / raw)
  To: git
  Cc: René Scharfe, Brian M . Carlson, Elijah Newren,
	Eric Sunshine, Jeff King, Phillip Wood
From: Phillip Wood <phillip.wood@dunelm.org.uk>
We have had a test balloon for C99's bool type since 8277dbe987
(git-compat-util: convert skip_{prefix,suffix}{,_mem} to bool,
2023-12-16). As we've had it over 18 months without any complaints
let's declare it a success.
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
---
 Documentation/CodingGuidelines | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
index 6350949f2ef..528b42d1dd1 100644
--- a/Documentation/CodingGuidelines
+++ b/Documentation/CodingGuidelines
@@ -298,6 +298,9 @@ For C programs:
    . since late 2021 with 44ba10d6, we have had variables declared in
      the for loop "for (int i = 0; i < 10; i++)".
 
+   . since late 2023 with 8277dbe987 we have been using the bool type
+     from <stdbool.h>.
+
    New C99 features that we cannot use yet:
 
    . %z and %zu as a printf() argument for a size_t (the %z being for
-- 
2.49.0.897.gfad3eb7d210
^ permalink raw reply related	[flat|nested] 33+ messages in thread
* [PATCH v3 2/3] git-compat-util: convert string predicates to return bool
  2025-07-16  9:38 ` [PATCH v3 " Phillip Wood
  2025-07-16  9:38   ` [PATCH v3 1/3] CodingGuidelines: allow the use of bool Phillip Wood
@ 2025-07-16  9:38   ` Phillip Wood
  2025-07-16 10:26     ` Karthik Nayak
  2025-07-16  9:38   ` [PATCH v3 3/3] strbuf: convert " Phillip Wood
  2025-07-16 10:29   ` [PATCH v3 0/3] C99: declare bool experiment a success Karthik Nayak
  3 siblings, 1 reply; 33+ messages in thread
From: Phillip Wood @ 2025-07-16  9:38 UTC (permalink / raw)
  To: git
  Cc: René Scharfe, Brian M . Carlson, Elijah Newren,
	Eric Sunshine, Jeff King, Phillip Wood
From: Phillip Wood <phillip.wood@dunelm.org.uk>
Since 8277dbe987 (git-compat-util: convert skip_{prefix,suffix}{,_mem}
to bool, 2023-12-16) a number of our string predicates have been
returning bool instead of int. Now that we've declared that experiment
a success, let's convert the return type of the case-independent
skip_iprefix() and skip_iprefix_mem() functions to match the return
type of their case-dependent equivalents. Returning bool instead of
int makes it clear that these functions are predicates.
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
---
 git-compat-util.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/git-compat-util.h b/git-compat-util.h
index 5bd69ec0403..9408f463e31 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -897,35 +897,35 @@ static inline size_t xsize_t(off_t len)
  * is done via tolower(), so it is strictly ASCII (no multi-byte characters or
  * locale-specific conversions).
  */
-static inline int skip_iprefix(const char *str, const char *prefix,
+static inline bool skip_iprefix(const char *str, const char *prefix,
 			       const char **out)
 {
 	do {
 		if (!*prefix) {
 			*out = str;
-			return 1;
+			return true;
 		}
 	} while (tolower(*str++) == tolower(*prefix++));
-	return 0;
+	return false;
 }
 
 /*
  * Like skip_prefix_mem, but compare case-insensitively. Note that the
  * comparison is done via tolower(), so it is strictly ASCII (no multi-byte
  * characters or locale-specific conversions).
  */
-static inline int skip_iprefix_mem(const char *buf, size_t len,
+static inline bool skip_iprefix_mem(const char *buf, size_t len,
 				   const char *prefix,
 				   const char **out, size_t *outlen)
 {
 	do {
 		if (!*prefix) {
 			*out = buf;
 			*outlen = len;
-			return 1;
+			return true;
 		}
 	} while (len-- > 0 && tolower(*buf++) == tolower(*prefix++));
-	return 0;
+	return false;
 }
 
 static inline int strtoul_ui(char const *s, int base, unsigned int *result)
-- 
2.49.0.897.gfad3eb7d210
^ permalink raw reply related	[flat|nested] 33+ messages in thread
* [PATCH v3 3/3] strbuf: convert predicates to return bool
  2025-07-16  9:38 ` [PATCH v3 " Phillip Wood
  2025-07-16  9:38   ` [PATCH v3 1/3] CodingGuidelines: allow the use of bool Phillip Wood
  2025-07-16  9:38   ` [PATCH v3 2/3] git-compat-util: convert string predicates to return bool Phillip Wood
@ 2025-07-16  9:38   ` Phillip Wood
  2025-07-16 10:28     ` Karthik Nayak
  2025-07-16 10:29   ` [PATCH v3 0/3] C99: declare bool experiment a success Karthik Nayak
  3 siblings, 1 reply; 33+ messages in thread
From: Phillip Wood @ 2025-07-16  9:38 UTC (permalink / raw)
  To: git
  Cc: René Scharfe, Brian M . Carlson, Elijah Newren,
	Eric Sunshine, Jeff King, Phillip Wood
From: Phillip Wood <phillip.wood@dunelm.org.uk>
Now that the string predicates defined in git-compat-util.h all
return bool let's convert the return type of the string predicates
in strbuf.{c,h} to match them.
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
---
 strbuf.c | 28 ++++++++++++++--------------
 strbuf.h | 12 ++++++------
 2 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/strbuf.c b/strbuf.c
index f30fdc69843..6c3851a7f84 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -8,55 +8,55 @@
 #include "utf8.h"
 #include "date.h"
 
-int starts_with(const char *str, const char *prefix)
+bool starts_with(const char *str, const char *prefix)
 {
 	for (; ; str++, prefix++)
 		if (!*prefix)
-			return 1;
+			return true;
 		else if (*str != *prefix)
-			return 0;
+			return false;
 }
 
-int istarts_with(const char *str, const char *prefix)
+bool istarts_with(const char *str, const char *prefix)
 {
 	for (; ; str++, prefix++)
 		if (!*prefix)
-			return 1;
+			return true;
 		else if (tolower(*str) != tolower(*prefix))
-			return 0;
+			return false;
 }
 
-int starts_with_mem(const char *str, size_t len, const char *prefix)
+bool starts_with_mem(const char *str, size_t len, const char *prefix)
 {
 	const char *end = str + len;
 	for (; ; str++, prefix++) {
 		if (!*prefix)
-			return 1;
+			return true;
 		else if (str == end || *str != *prefix)
-			return 0;
+			return false;
 	}
 }
 
-int skip_to_optional_arg_default(const char *str, const char *prefix,
+bool skip_to_optional_arg_default(const char *str, const char *prefix,
 				 const char **arg, const char *def)
 {
 	const char *p;
 
 	if (!skip_prefix(str, prefix, &p))
-		return 0;
+		return false;
 
 	if (!*p) {
 		if (arg)
 			*arg = def;
-		return 1;
+		return true;
 	}
 
 	if (*p != '=')
-		return 0;
+		return false;
 
 	if (arg)
 		*arg = p + 1;
-	return 1;
+	return true;
 }
 
 /*
diff --git a/strbuf.h b/strbuf.h
index 6362777c0a0..a580ac6084b 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -660,9 +660,9 @@ char *xstrvfmt(const char *fmt, va_list ap);
 __attribute__((format (printf, 1, 2)))
 char *xstrfmt(const char *fmt, ...);
 
-int starts_with(const char *str, const char *prefix);
-int istarts_with(const char *str, const char *prefix);
-int starts_with_mem(const char *str, size_t len, const char *prefix);
+bool starts_with(const char *str, const char *prefix);
+bool istarts_with(const char *str, const char *prefix);
+bool starts_with_mem(const char *str, size_t len, const char *prefix);
 
 /*
  * If the string "str" is the same as the string in "prefix", then the "arg"
@@ -678,16 +678,16 @@ int starts_with_mem(const char *str, size_t len, const char *prefix);
  * can be used instead of !strcmp(arg, "--key") and then
  * skip_prefix(arg, "--key=", &arg) to parse such an option.
  */
-int skip_to_optional_arg_default(const char *str, const char *prefix,
+bool skip_to_optional_arg_default(const char *str, const char *prefix,
 				 const char **arg, const char *def);
 
-static inline int skip_to_optional_arg(const char *str, const char *prefix,
+static inline bool skip_to_optional_arg(const char *str, const char *prefix,
 				       const char **arg)
 {
 	return skip_to_optional_arg_default(str, prefix, arg, "");
 }
 
-static inline int ends_with(const char *str, const char *suffix)
+static inline bool ends_with(const char *str, const char *suffix)
 {
 	size_t len;
 	return strip_suffix(str, suffix, &len);
-- 
2.49.0.897.gfad3eb7d210
^ permalink raw reply related	[flat|nested] 33+ messages in thread
* Re: [PATCH v3 2/3] git-compat-util: convert string predicates to return bool
  2025-07-16  9:38   ` [PATCH v3 2/3] git-compat-util: convert string predicates to return bool Phillip Wood
@ 2025-07-16 10:26     ` Karthik Nayak
  0 siblings, 0 replies; 33+ messages in thread
From: Karthik Nayak @ 2025-07-16 10:26 UTC (permalink / raw)
  To: Phillip Wood, git
  Cc: René Scharfe, Brian M . Carlson, Elijah Newren,
	Eric Sunshine, Jeff King, Phillip Wood
[-- Attachment #1: Type: text/plain, Size: 2775 bytes --]
Phillip Wood <phillip.wood123@gmail.com> writes:
> From: Phillip Wood <phillip.wood@dunelm.org.uk>
>
> Since 8277dbe987 (git-compat-util: convert skip_{prefix,suffix}{,_mem}
> to bool, 2023-12-16) a number of our string predicates have been
> returning bool instead of int. Now that we've declared that experiment
> a success, let's convert the return type of the case-independent
> skip_iprefix() and skip_iprefix_mem() functions to match the return
> type of their case-dependent equivalents. Returning bool instead of
> int makes it clear that these functions are predicates.
>
> Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
> ---
>  git-compat-util.h | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/git-compat-util.h b/git-compat-util.h
> index 5bd69ec0403..9408f463e31 100644
> --- a/git-compat-util.h
> +++ b/git-compat-util.h
> @@ -897,35 +897,35 @@ static inline size_t xsize_t(off_t len)
>   * is done via tolower(), so it is strictly ASCII (no multi-byte characters or
>   * locale-specific conversions).
>   */
> -static inline int skip_iprefix(const char *str, const char *prefix,
> +static inline bool skip_iprefix(const char *str, const char *prefix,
>  			       const char **out)
>  {
>  	do {
>  		if (!*prefix) {
>  			*out = str;
> -			return 1;
> +			return true;
>  		}
>  	} while (tolower(*str++) == tolower(*prefix++));
> -	return 0;
> +	return false;
>  }
>
>  /*
>   * Like skip_prefix_mem, but compare case-insensitively. Note that the
>   * comparison is done via tolower(), so it is strictly ASCII (no multi-byte
>   * characters or locale-specific conversions).
>   */
> -static inline int skip_iprefix_mem(const char *buf, size_t len,
> +static inline bool skip_iprefix_mem(const char *buf, size_t len,
>  				   const char *prefix,
>  				   const char **out, size_t *outlen)
>
Nit: clang-format complains that we should also format the arguments now
that the first line's length changes
$ ./ci/run-style-check.sh @~1
diff --git a/git-compat-util.h b/git-compat-util.h
index 9408f463e3..e01abf6eb6 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -898,7 +898,7 @@ static inline size_t xsize_t(off_t len)
  * locale-specific conversions).
  */
 static inline bool skip_iprefix(const char *str, const char *prefix,
-			       const char **out)
+				const char **out)
 {
 	do {
 		if (!*prefix) {
@@ -915,8 +915,8 @@ static inline bool skip_iprefix(const char *str,
const char *prefix,
  * characters or locale-specific conversions).
  */
 static inline bool skip_iprefix_mem(const char *buf, size_t len,
-				   const char *prefix,
-				   const char **out, size_t *outlen)
+				    const char *prefix,
+				    const char **out, size_t *outlen)
 {
 	do {
 		if (!*prefix) {
[snip]
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 690 bytes --]
^ permalink raw reply related	[flat|nested] 33+ messages in thread
* Re: [PATCH v3 3/3] strbuf: convert predicates to return bool
  2025-07-16  9:38   ` [PATCH v3 3/3] strbuf: convert " Phillip Wood
@ 2025-07-16 10:28     ` Karthik Nayak
  0 siblings, 0 replies; 33+ messages in thread
From: Karthik Nayak @ 2025-07-16 10:28 UTC (permalink / raw)
  To: Phillip Wood, git
  Cc: René Scharfe, Brian M . Carlson, Elijah Newren,
	Eric Sunshine, Jeff King, Phillip Wood
[-- Attachment #1: Type: text/plain, Size: 1529 bytes --]
Phillip Wood <phillip.wood123@gmail.com> writes:
> From: Phillip Wood <phillip.wood@dunelm.org.uk>
>
> Now that the string predicates defined in git-compat-util.h all
> return bool let's convert the return type of the string predicates
> in strbuf.{c,h} to match them.
>
> Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
> ---
>  strbuf.c | 28 ++++++++++++++--------------
>  strbuf.h | 12 ++++++------
>  2 files changed, 20 insertions(+), 20 deletions(-)
>
Nit: same here as the previous patch
$ ./ci/run-style-check.sh @~1
diff --git a/strbuf.c b/strbuf.c
index 6c3851a7f8..d9e040c13b 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -38,7 +38,7 @@ bool starts_with_mem(const char *str, size_t len,
const char *prefix)
 }
 bool skip_to_optional_arg_default(const char *str, const char *prefix,
-				 const char **arg, const char *def)
+				  const char **arg, const char *def)
 {
 	const char *p;
diff --git a/strbuf.h b/strbuf.h
index a580ac6084..d2ff9839a9 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -679,10 +679,10 @@ bool starts_with_mem(const char *str, size_t
len, const char *prefix);
  * skip_prefix(arg, "--key=", &arg) to parse such an option.
  */
 bool skip_to_optional_arg_default(const char *str, const char *prefix,
-				 const char **arg, const char *def);
+				  const char **arg, const char *def);
 static inline bool skip_to_optional_arg(const char *str, const char *prefix,
-				       const char **arg)
+					const char **arg)
 {
 	return skip_to_optional_arg_default(str, prefix, arg, "");
 }
[snip]
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 690 bytes --]
^ permalink raw reply related	[flat|nested] 33+ messages in thread
* Re: [PATCH v3 0/3] C99: declare bool experiment a success
  2025-07-16  9:38 ` [PATCH v3 " Phillip Wood
                     ` (2 preceding siblings ...)
  2025-07-16  9:38   ` [PATCH v3 3/3] strbuf: convert " Phillip Wood
@ 2025-07-16 10:29   ` Karthik Nayak
  2025-07-17 15:21     ` Phillip Wood
  3 siblings, 1 reply; 33+ messages in thread
From: Karthik Nayak @ 2025-07-16 10:29 UTC (permalink / raw)
  To: Phillip Wood, git
  Cc: René Scharfe, Brian M . Carlson, Elijah Newren,
	Eric Sunshine, Jeff King
[-- Attachment #1: Type: text/plain, Size: 646 bytes --]
Phillip Wood <phillip.wood123@gmail.com> writes:
> From: Phillip Wood <phillip.wood@dunelm.org.uk>
>
> We've had a test balloon for C99's bool type since 8277dbe987
> (git-compat-util: convert skip_{prefix,suffix}{,_mem} to bool,
> 2023-12-16). As it has been over 18 months since this was added and
> there have been no complaints let's declare it a success and convert
> the return type our other string predicates to match.
>
Neat, I didn't even know we were running such an experiment. Thanks for
getting around to it, I think the patches look great, added some
complaints from 'clang-format', feel free to ignore.
Thanks,
Karthik
[snip]
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 690 bytes --]
^ permalink raw reply	[flat|nested] 33+ messages in thread
* Re: [PATCH v3 0/3] C99: declare bool experiment a success
  2025-07-16 10:29   ` [PATCH v3 0/3] C99: declare bool experiment a success Karthik Nayak
@ 2025-07-17 15:21     ` Phillip Wood
  2025-07-22  8:09       ` Karthik Nayak
  0 siblings, 1 reply; 33+ messages in thread
From: Phillip Wood @ 2025-07-17 15:21 UTC (permalink / raw)
  To: Karthik Nayak, Phillip Wood, git
  Cc: René Scharfe, Brian M . Carlson, Elijah Newren,
	Eric Sunshine, Jeff King
Hi Karthik
On 16/07/2025 11:29, Karthik Nayak wrote:
> Phillip Wood <phillip.wood123@gmail.com> writes:
> 
>> From: Phillip Wood <phillip.wood@dunelm.org.uk>
>>
>> We've had a test balloon for C99's bool type since 8277dbe987
>> (git-compat-util: convert skip_{prefix,suffix}{,_mem} to bool,
>> 2023-12-16). As it has been over 18 months since this was added and
>> there have been no complaints let's declare it a success and convert
>> the return type our other string predicates to match.
>>
> 
> Neat, I didn't even know we were running such an experiment. Thanks for
> getting around to it, I think the patches look great, added some
> complaints from 'clang-format', feel free to ignore.
Thanks for taking a look. I would have fixed the formatting but this is 
in next already so I'll leave it as it is if that's ok with you.
Thanks
Phillip
^ permalink raw reply	[flat|nested] 33+ messages in thread
* Re: [PATCH v3 0/3] C99: declare bool experiment a success
  2025-07-17 15:21     ` Phillip Wood
@ 2025-07-22  8:09       ` Karthik Nayak
  0 siblings, 0 replies; 33+ messages in thread
From: Karthik Nayak @ 2025-07-22  8:09 UTC (permalink / raw)
  To: Phillip Wood, Phillip Wood, git
  Cc: René Scharfe, Brian M . Carlson, Elijah Newren,
	Eric Sunshine, Jeff King
[-- Attachment #1: Type: text/plain, Size: 1130 bytes --]
Phillip Wood <phillip.wood123@gmail.com> writes:
> Hi Karthik
>
> On 16/07/2025 11:29, Karthik Nayak wrote:
>> Phillip Wood <phillip.wood123@gmail.com> writes:
>>
>>> From: Phillip Wood <phillip.wood@dunelm.org.uk>
>>>
>>> We've had a test balloon for C99's bool type since 8277dbe987
>>> (git-compat-util: convert skip_{prefix,suffix}{,_mem} to bool,
>>> 2023-12-16). As it has been over 18 months since this was added and
>>> there have been no complaints let's declare it a success and convert
>>> the return type our other string predicates to match.
>>>
>>
>> Neat, I didn't even know we were running such an experiment. Thanks for
>> getting around to it, I think the patches look great, added some
>> complaints from 'clang-format', feel free to ignore.
>
> Thanks for taking a look. I would have fixed the formatting but this is
> in next already so I'll leave it as it is if that's ok with you.
>
Of course :) These are small nits. I'm mostly interested in getting
clang-format to work without any/many false positives, so I'm trying to
test it with different patches that I read and report back!
> Thanks
>
> Phillip
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 690 bytes --]
^ permalink raw reply	[flat|nested] 33+ messages in thread
end of thread, other threads:[~2025-07-22  8:09 UTC | newest]
Thread overview: 33+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-14 13:26 [PATCH 0/3] C99: declare bool experiment a success Phillip Wood
2025-07-14 13:27 ` [PATCH 1/3] CodingGuildlines: allow the use of bool Phillip Wood
2025-07-14 16:37   ` Junio C Hamano
2025-07-14 13:27 ` [PATCH 2/3] git-compat-util: convert string predicates to return bool Phillip Wood
2025-07-14 16:46   ` Eric Sunshine
2025-07-14 17:20   ` Elijah Newren
2025-07-14 21:14     ` brian m. carlson
2025-07-15  9:36       ` Phillip Wood
2025-07-14 13:27 ` [PATCH 3/3] strbuf: convert " Phillip Wood
2025-07-15 13:52 ` [PATCH v2 0/3] C99: declare bool experiment a success Phillip Wood
2025-07-15 13:52   ` [PATCH v2 1/3] CodingGuildlines: allow the use of bool Phillip Wood
2025-07-16  4:38     ` Jeff King
2025-07-16  4:46       ` Jeff King
2025-07-16  5:06         ` Elijah Newren
2025-07-15 13:52   ` [PATCH v2 2/3] git-compat-util: convert string predicates to return bool Phillip Wood
2025-07-15 13:52   ` [PATCH v2 3/3] strbuf: convert " Phillip Wood
2025-07-15 17:19   ` [PATCH v2 0/3] C99: declare bool experiment a success Elijah Newren
2025-07-15 18:23     ` rsbecker
2025-07-15 19:35       ` Elijah Newren
2025-07-15 20:47         ` rsbecker
2025-07-15 21:06       ` Junio C Hamano
2025-07-15 18:53     ` Junio C Hamano
2025-07-15 21:48   ` brian m. carlson
2025-07-15 22:09     ` Junio C Hamano
2025-07-16  9:38 ` [PATCH v3 " Phillip Wood
2025-07-16  9:38   ` [PATCH v3 1/3] CodingGuidelines: allow the use of bool Phillip Wood
2025-07-16  9:38   ` [PATCH v3 2/3] git-compat-util: convert string predicates to return bool Phillip Wood
2025-07-16 10:26     ` Karthik Nayak
2025-07-16  9:38   ` [PATCH v3 3/3] strbuf: convert " Phillip Wood
2025-07-16 10:28     ` Karthik Nayak
2025-07-16 10:29   ` [PATCH v3 0/3] C99: declare bool experiment a success Karthik Nayak
2025-07-17 15:21     ` Phillip Wood
2025-07-22  8:09       ` Karthik Nayak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).