I would like to create a tool that checks if I already have a local clone of a remote repository before cloning said repository. To do this, I need a way of testing if B is the same as repository A -- by which I guess i mean they have mergeable histories. B might be named differently than A, and might have additional branches -- the usual use cases.
Is there a way to do this? I have a tentative idea how to do it, but I thought perhaps someone here has a definitive answer.
Tentative idea
Get a list of branches and search for common branches (by hash). Then for the common branches, check that the initial commits are the same (by hash). At that point I would say 'good enough'. I figure I'm okay unless someone has been messing with history, which use-case I'm willing to neglect. To do this though, I need a way of getting the branch and commit information from the remote repository, without doing a clone. I can solve this using ssh & bash, but a git-only solution would be preferable.
Feedback on the half-baked idea is also welcome.
Why this is not a duplicate of Git repository unique id
The referenced question is looking for a unique repository id, or a way of creating one. No such beast exists, and even if it did, it is questionable if it would be relevant here, since I want to determine if two repositories have mergeable histories (i.e. I could fetch and merge between the two) -- a slightly better defined problem. I'm willing to ignore the possibilty that a user has modified history, but would love to hear how to handle that case as well.