1

I've written an open-source app to clone remote repos from well-known Git hosting providers and create bundles from them, for backup purposes. Subsequent runs of the app re-clone, re-bundle, and compare size and hash to determine if it's a new version to archive, or if it's the same and can be discarded.

To save time and bandwidth, I'm trialling a feature to compare bundle and remote refs to determine if they are identical or not, i.e. get the output of both of the following commands and compare refs:

git bundle list-heads myrepo.202211012056.bundle  
git ls-remote https://example.com/myrepo.git

With output looking something like this for each command:

86c9f38dc2e3edc34cfcccad3f3cf7f91a2bbe8d refs/heads/lotsatests
3901f7a0950be9a252aa3020bb8dd607edc6fdf0 refs/heads/main
9f427e597b6dd9e354881a30ba586b729cce3811 refs/tags/0.0.1
3901f7a0950be9a252aa3020bb8dd607edc6fdf0 HEAD

Limited testing suggests the comparison of output from both commands is sufficient to determine if the repos are identical, but are there any gotchas I should be aware of?

jonhadfield
  • 119
  • 1
  • 1
  • 9
  • 4
    no gotchas, comparing commits sha is the correct way to see if they are equal, and `ls-remote` is a reliable way to get the complete view of the remote repository – LeGEC Nov 01 '22 at 22:02
  • 2
    @LeGEC: well, maybe one: it's possible that some site has a shallow repository, so that it has the appropriate tip commits but not all of the history. There's no way to find that out directly though. The new partial clone stuff is going to exacerbate this issue significantly and Git should probably have a new capability in the transfer protocol to indicate whether some site has a *complete* repository (no promisor packs, no shallow grafts) or not. – torek Nov 02 '22 at 10:17
  • Interesting. Thanks both. – jonhadfield Nov 02 '22 at 20:27

0 Answers0