Skip to content

Commit f711f37

Browse files
ebiedermgitster
authored andcommitted
t1016-compatObjectFormat: really freeze time for reproduciblity
The strategy in t1016-compatObjectFormat is to build two trees with identical commits, one tree encoded in sha1 the other tree encoded in sha256 and to use the compatibility code to test and see if the two trees are identical. GPG signatures include the current time as part of the signature. To make gpg deterministic I forced the use of gpg --faked-system-time. Unfortunately I did not look closely enough. By default gpg still allows time to move forward with --faked-system-time. So in those rare instances when the system is heavily loaded and gpg runs slower than other times, signatures over the exact same data differ due to timestamps with a minuscule difference. Reading through the gpg documentation with a close eye, time can be frozen by including an exclamation point at the end of the argument to --faked-system-time. Add the exclamation point so gpg really runs with a fixed notion of time, resulting in the exact same data having identical gpg signatures. That is enough that I can run "t1016-compatObjectFormat.sh --stress" and I don't see any failures. It is possible a future change to gpg will make replay protection more robust and not provide a way to allow two separate runs of gpg to produce exactly the same signature for exactly the same data. If that happens a deeper comparison of the two repositories will need to be performed. A comparison that simply verifies the signatures and compares the data for equality. For now that is a lot of work for no gain so I am just documenting the possibility. Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent a1cf0cf commit f711f37

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

t/t1016-compatObjectFormat.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ test_description='Test how well compatObjectFormat works'
2121
# different hash functions result in the same content in the commits.
2222
# This means that when the commit is translated between hash functions
2323
# the commit is identical to the commit in the other repository.
24+
#
25+
# Similarly this test relies on:
26+
# gpg --faked-system-time '20230918T154812!
27+
# freezing the system time from gpg perspective so that two different
28+
# runs of gpg applied to the same data result in identical signatures.
29+
#
2430

2531
compat_hash () {
2632
case "$1" in

t/t1016/gpg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/bin/sh
2-
exec gpg --faked-system-time "20230918T154812" "$@"
2+
exec gpg --faked-system-time '20230918T154812!' "$@"

0 commit comments

Comments
 (0)