Subject: Re: [PATCH/RFC] Makefile: Fix compilation of windows resource file

From: Junio C Hamano <[email-masked]>
Date: Tue, 21 Jan 2014 15:48:48 -0800

Ramsay Jones <[email-masked]> writes:

>> Note that I am merely guessing that "short-digit" version numbers
>> are acceptable by now after seeing
>> 
>>     https://sourceware.org/ml/binutils/2012-07/msg00199.html
>
> Ah, nice find!
>
> I will test your patch (below) and let you know soon, but it looks
> good to me. (I can't test it tonight, unfortunately.)

One thing to note is that I don't know why the existing code dropped
the fourth digit from the maintenance series.  The updated one will
give you "1,8,5,3,0" (because I just have a hardcoded ",0" at the
end for no good reason there), and if the missing fourth digit in
the original was a deliberate workaround for this file having an
upper limit of the number of digits (like "four"), this change will
break it, so if that is the case, you may have to count and stop the
loop early, perhaps like...

>> diff --git a/gen-version-string.sh b/gen-version-string.sh
>> new file mode 100755
>> index 0000000..00af718
>> --- /dev/null
>> +++ b/gen-version-string.sh
>> @@ -0,0 +1,13 @@
>> +#!/bin/sh
>> +
>> +IFS=.- result=

Add

	num_digits=0

here, and...

>> +for v in $1
>> +do
>> +	if expr "$v" : '[0-9][0-9]*$' >/dev/null
>> +	then
>> +		result=$result${result:+,}$v

... insert these here.

                num_digits=$(( $num_digits + 1 ))
                if test $num_digits = 4
                then
                        break
                fi

>> +	else
>> +		break
>> +	fi
>> +done
>> +echo "$result"
>> diff --git a/git.rc b/git.rc
>> index bce6db9..6f2a8d2 100644
>> --- a/git.rc
>> +++ b/git.rc
>> @@ -1,6 +1,6 @@
>>  1 VERSIONINFO
>> -FILEVERSION     MAJOR,MINOR,PATCH,0
>> -PRODUCTVERSION  MAJOR,MINOR,PATCH,0
>> +FILEVERSION     VERSIONSTRING,0
>> +PRODUCTVERSION  VERSIONSTRING,0
>>  BEGIN
>>    BLOCK "StringFileInfo"
>>    BEGIN
>> .
>>