The git version string is used in the wild, and in git gui,
for capability checking purposes. Test the string format
and version X.Y.Z number.
The version string shall be:
* a single line
* less that 80 characters
* start with `git version `
* with a following numeric X.Y.Z version.
The remaining characters are undefined.
Signed-off-by: Philip Oakley <redacted>
---
Should this be applied to t0000, or another test file?
Should the version string be always limited to one line?
Should the maximum string length be <80 characters?
Is egrep OK, or should I use grep with a longer BRE?
t/t0000-basic.sh | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index cefe33d..052afca 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -610,4 +610,12 @@ test_expect_success 'very long name in the index handled sanely' '
test $len = 4098
'
+test_expect_success 'git version string X.Y.Z' '
+ git --version >verstring &&
+ test_line_count = 1 verstring &&
+ len=$(wc -c verstring | sed "s/[^0-9]//g") &&
+ test $len -lt 80 &&
+ egrep -q "^git version [0-9]+\.[0-9]+\.[0-9]+.*" verstring
+'
+
test_done
--
1.8.1.msysgit.1