Project

General

Profile

Bug #476

git version check in configure / genversion.sh is broken for non-GNU test

Added by Christoph Junghans over 9 years ago. Updated about 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
mdrun
Target version:
Affected version - extra info:
Affected version:
Difficulty:
uncategorized
Close

Description

+ test git version 1.6.4.2 < git version 1.5.3
./genversion.sh16: <: 0403-012 A test command parameter is not valid.

I do not know a easy way to fix that, maybe

git --version | sed -e 's/[^0-9]//g' -e 's/^...$/&0/'

The problem is mainly that some version are 1.X.X and some are 1.X.X.X

History

#1 Updated by Teemu Murtola over 9 years ago

The proposed fix is really obscure. :) Even if it may work for now, it can easily break at some point... It seems that test a < b is not POSIX-compatible, although it works on GNU and BSD implementations, so some kind of a workaround would be necessary. A similar test is used in configure.ac to test whether the git version is 1.5.1 or greater, and that should be fixed as well. To enable compilation on systems that do not support that test, we could change the configure.ac test around such that genversion.sh is not run if that test does not work, but that is only a temporary workaround.

A proper fix for genversion.sh would be to test whether "git rev-list --pretty=format:%ci" works or not (or "git rev-list --pretty=format:%cd --date=short") , and something like that should be easy to implement if one has access to older git versions to see how they actually behave if invoked with those flags. The test in configure.ac could probably also be changed to test for the actual features used... I think the main reason for the test in configure.ac is that we just haven't tested the scripts with older versions, so it might be completely unnecessary. We might also do all the tests in configure.ac if that is easier, and then just pass the result into the script.

I don't have an easy access to older git versions, so I can't fix it quickly, but I can try to take a look at this after my holidays if no one else has time.

#2 Updated by Christoph Junghans over 9 years ago

I think the solution is to test the git command used.
You never know maybe it will fail with newer version of git again ;-)

#3 Updated by Teemu Murtola over 9 years ago

The main problem with testing the git command is that one has to check what really happens with older versions of git (preferably several...), and that takes some effort if/when one has to compile those: for example, the problematic command with pre-1.5.3 git is
git rev-list -n1 --pretty=format:%ci
If I remember correctly, the command actually does not fail on older git, it just prints %ci instead of a date...

#4 Updated by Erik Lindahl about 9 years ago

Hi Christoph,

To look into this I think we need access to an example of a test command that actually fails - my mac (BSD?) version seems to pass the test.

The bug report has 'Linux' as the OS; which Linux versions use a non-GNU test?

Cheers,

Erik

#5 Updated by Erik Lindahl about 9 years ago

PS Teemu: I would prefer to test the actual command, and think it works if we do something like

if ~/git-1.5/bin/git rev-list -n1 --pretty=format:%cd HEAD | grep '[0-9]\{4\}'  > /dev/null 2>&1; then echo "Good version" ; fi

...but the problem is that this only works if it is executed in a git repository, and I have no idea what will happen with normal out-of-tree builds.

For now I think the easiest option is to hack the version test, but we need to be a bit careful with things like -rc3 suffixes.

#6 Updated by Teemu Murtola about 9 years ago

I also think that the best solution is to test the actual command and get rid of the version tests altogether, and if you now anyway have a git compiled that doesn't support these, this shouldn't be too hard. The command you pasted probably does the trick (with --git-dir added, see below). In that case, we need to change both configure.ac and the genversion.sh scripts. configure should check that --pretty=format:%cd works, and genversion.sh whether --pretty=format:%ci works.

For out-of-tree builds, it is possible to provide the repository location with --git-dir=$srcdir/.git. If there's something wrong with the repository, git will exit with a non-zero error code in configure, which should result in never calling the genversion.sh script.

#7 Updated by Erik Lindahl about 9 years ago

Fixed in commit commit 491695653409d057aeda9ddf157bed30dadc3f31. We not test for git features.

#8 Updated by Erik Lindahl about 9 years ago

Forgot to change status.

#9 Updated by Christoph Junghans about 9 years ago

Just for the records, it is IBM's version of test coming with AIX 5.3 and AIX 6.1

$/bin/test 'git version 1.6.4.2' \> 'git version 1.5.3'; echo $?
test: 0402-154 An operator is missing or is not valid.
255

Btw the bash/sh/ksh93 internal test works:
$test 'git version 1.6.4.2' \> 'git version 1.5.3'; echo $?
0

I am not sure why configure is using /bin/test and not the shell build-in.

Also available in: Atom PDF