Skip to content

Instantly share code, notes, and snippets.

@bjornfor
bjornfor / deterministic-git-test.sh
Last active August 29, 2015 14:15
Test if git clones (at specific revision) can be deterministic
#!/usr/bin/env bash
# A test to see if a deterministic fetchgit with leaveDotGit is possible.
# Short answer; yes.
#
# Q: Can .git/index be deterministic?
# A: No, impossible (it contains inode numbers). If you *must* have it, remove
# it before calculating checksums, then re-create it from the repo contents.
create_annotated_tag()
{
Old clone (git-export) diffed against new-clone (possibly fetched with newer git.
diff -uNr /nix/store/80zgflqjwc5pq57gjw9338fi44mhxphp-git-export/.git/info/refs /home/bfo/new-clone/.git/info/refs
--- /nix/store/80zgflqjwc5pq57gjw9338fi44mhxphp-git-export/.git/info/refs 1970-01-01 01:00:01.000000000 +0100
+++ /home/bfo/new-clone/.git/info/refs 2015-07-01 13:35:13.632206482 +0200
@@ -1 +1,8 @@
5e29263871cafe31c5ea77bc1ac0a765982fd645 refs/heads/fetchgit
+0bd698d90136380225a95edc4ff36ff052632673 refs/tags/show
+4a549566dbffdb14e1913680e0a264d233adcfc8 refs/tags/v0.0
+0dc48e2023764f4eeb9e0dbf040e02ee1872ce8d refs/tags/v0.0^{}