diff options
author | Charles Bailey <cbailey32@bloomberg.net> | 2017-11-12 15:25:23 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-11-13 12:48:00 +0900 |
commit | 5555a2aa4bb004a24d8bea32051be0b56fb2532e (patch) | |
tree | bfa5f093fd5762c628f3a8d1749ef96ba0089f3c /t/test-lib.sh | |
parent | 9752ad0bb79f680bca48db7adc45338b298304b0 (diff) | |
download | git-5555a2aa4bb004a24d8bea32051be0b56fb2532e.tar.gz |
t4201: make use of abbreviation in the test more robustcb/t4201-robustify
The test for '--abbrev' in t4201-shortlog.sh assumes that the commits
generated in the test can always be uniquely abbreviated to 5 hex digits
but this is not always the case. If you were unlucky and happened to run
the test at (say) Thu Jun 22 03:04:49 2017 +0000, you would find that
the first commit generated would collide with a tree object created
later in the same test.
This can be simulated in the version of t4201-shortlog.sh prior to this
commit by setting GIT_COMMITTER_DATE and GIT_AUTHOR_DATE to 1498100689
after sourcing test-lib.sh.
Change the test to test --abbrev=35 instead of --abbrev=5 to almost
completely avoid the possibility of a partial collision and add a call
to test_tick in the setup to make the test repeatable (the latter alone
is sufficient to make it robust enough).
Signed-off-by: Charles Bailey <cbailey32@bloomberg.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/test-lib.sh')
-rw-r--r-- | t/test-lib.sh | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/t/test-lib.sh b/t/test-lib.sh index 23c29bce6e..ee08c03d58 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -166,9 +166,10 @@ esac # Convenience # -# A regexp to match 5 and 40 hexdigits +# A regexp to match 5, 35 and 40 hexdigits _x05='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' -_x40="$_x05$_x05$_x05$_x05$_x05$_x05$_x05$_x05" +_x35="$_x05$_x05$_x05$_x05$_x05$_x05$_x05" +_x40="$_x35$_x05" # Zero SHA-1 _z40=0000000000000000000000000000000000000000 @@ -184,7 +185,7 @@ LF=' # when case-folding filenames u200c=$(printf '\342\200\214') -export _x05 _x40 _z40 LF u200c EMPTY_TREE EMPTY_BLOB +export _x05 _x35 _x40 _z40 LF u200c EMPTY_TREE EMPTY_BLOB # Each test should start with something like this, after copyright notices: # |