threads / patch / 64620

patcht4014: support Git version strings with spaces

Subject: [PATCH] t4014: support Git version strings with spaces

## tl;dr

4 messages between Dec 13, 2025 and Dec 13, 2025. Diffs are folded; open one to read it.

replies: 3people: 2as markdown or json

René Scharfe· Dec 13, 2025, 08:03 UTC · lore

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(-)
Show changes to t/t4014-format-patch.sh +1 −1
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
Junio C Hamano· Dec 13, 2025, 08:42 UTC · re: René Scharfe · lore

Re: [PATCH] t4014: support Git version strings with spaces

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.
Show 23 quoted lines
> 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() {
René Scharfe· Dec 13, 2025, 08:49 UTC · re: Junio C Hamano · lore

Re: [PATCH] t4014: support Git version strings with spaces

On 12/13/25 9:42 AM, Junio C Hamano wrote:
Show 7 quoted lines
> 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é
René Scharfe· Dec 13, 2025, 09:40 UTC · re: René Scharfe · lore

[PATCH v2] t4014: support Git version strings with spaces

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(-)
Show changes to t/t4014-format-patch.sh +1 −1
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

← back to recent threads