git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] t4014: support Git version strings with spaces
@ 2025-12-13  8:03 René Scharfe
  2025-12-13  8:42 ` Junio C Hamano
  2025-12-13  9:40 ` [PATCH v2] " René Scharfe
  0 siblings, 2 replies; 4+ messages in thread
From: René Scharfe @ 2025-12-13  8:03 UTC (permalink / raw)
  To: Git List

git --version reports its version with the prefix "git version ".
Remove precisely this string instead of everything up to and including
the first space to avoid butchering version strings that contain spaces.
This helps Apple's release of Git, which reports its version like this:
"git version 2.50.1 (Apple Git-155)".

Signed-off-by: René Scharfe <l.s.r@web.de>
---
Not an Apple patch.  They use sed(1) instead, which inadvertently hides
the return code of git:

https://github.com/apple-oss-distributions/Git/blob/6b2f9bfe72d6d4b5c9bcc1c2d0236c026d321cba/src/git/t/t4014-format-patch.sh#L982

 t/t4014-format-patch.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index 2782b1fc18..21d6d0cd9e 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -980,7 +980,7 @@ test_expect_success 'format-patch --ignore-if-in-upstream HEAD' '
 
 test_expect_success 'get git version' '
 	git_version=$(git --version) &&
-	git_version=${git_version##* }
+	git_version=${git_version#git version }
 '
 
 signature() {
-- 
2.52.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] t4014: support Git version strings with spaces
  2025-12-13  8:03 [PATCH] t4014: support Git version strings with spaces René Scharfe
@ 2025-12-13  8:42 ` Junio C Hamano
  2025-12-13  8:49   ` René Scharfe
  2025-12-13  9:40 ` [PATCH v2] " René Scharfe
  1 sibling, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2025-12-13  8:42 UTC (permalink / raw)
  To: René Scharfe; +Cc: Git List

René Scharfe <l.s.r@web.de> writes:

> git --version reports its version with the prefix "git version ".
> Remove precisely this string instead of everything up to and including
> the first space to avoid butchering version strings that contain spaces.

"everything up to and including the last (rightmost) space"?

> This helps Apple's release of Git, which reports its version like this:
> "git version 2.50.1 (Apple Git-155)".

Sounds sensible.

> Signed-off-by: René Scharfe <l.s.r@web.de>
> ---
> Not an Apple patch.  They use sed(1) instead, which inadvertently hides
> the return code of git:
>
> https://github.com/apple-oss-distributions/Git/blob/6b2f9bfe72d6d4b5c9bcc1c2d0236c026d321cba/src/git/t/t4014-format-patch.sh#L982
>
>  t/t4014-format-patch.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
> index 2782b1fc18..21d6d0cd9e 100755
> --- a/t/t4014-format-patch.sh
> +++ b/t/t4014-format-patch.sh
> @@ -980,7 +980,7 @@ test_expect_success 'format-patch --ignore-if-in-upstream HEAD' '
>  
>  test_expect_success 'get git version' '
>  	git_version=$(git --version) &&
> -	git_version=${git_version##* }
> +	git_version=${git_version#git version }
>  '
>  
>  signature() {

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] t4014: support Git version strings with spaces
  2025-12-13  8:42 ` Junio C Hamano
@ 2025-12-13  8:49   ` René Scharfe
  0 siblings, 0 replies; 4+ messages in thread
From: René Scharfe @ 2025-12-13  8:49 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git List

On 12/13/25 9:42 AM, Junio C Hamano wrote:
> René Scharfe <l.s.r@web.de> writes:
> 
>> git --version reports its version with the prefix "git version ".
>> Remove precisely this string instead of everything up to and including
>> the first space to avoid butchering version strings that contain spaces.
> 
> "everything up to and including the last (rightmost) space"?

Ugh, yes, did that before.  Perhaps a variant of left-right confusion? :-|

René


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] t4014: support Git version strings with spaces
  2025-12-13  8:03 [PATCH] t4014: support Git version strings with spaces René Scharfe
  2025-12-13  8:42 ` Junio C Hamano
@ 2025-12-13  9:40 ` René Scharfe
  1 sibling, 0 replies; 4+ messages in thread
From: René Scharfe @ 2025-12-13  9:40 UTC (permalink / raw)
  To: Git List

git --version reports its version with the prefix "git version ".
Remove precisely this string instead of everything up to and including
the rightmost space to avoid butchering version strings that contain
spaces.  This helps Apple's release of Git, which reports its version
like this: "git version 2.50.1 (Apple Git-155)".

Signed-off-by: René Scharfe <l.s.r@web.de>
---
Changes since v1:
- fix description of current removal pattern in commit message

 t/t4014-format-patch.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index 2782b1fc18..21d6d0cd9e 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -980,7 +980,7 @@ test_expect_success 'format-patch --ignore-if-in-upstream HEAD' '
 
 test_expect_success 'get git version' '
 	git_version=$(git --version) &&
-	git_version=${git_version##* }
+	git_version=${git_version#git version }
 '
 
 signature() {
-- 
2.52.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-12-13  9:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-13  8:03 [PATCH] t4014: support Git version strings with spaces René Scharfe
2025-12-13  8:42 ` Junio C Hamano
2025-12-13  8:49   ` René Scharfe
2025-12-13  9:40 ` [PATCH v2] " René Scharfe

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).