Idenifying a repository [message #647947] |
Mon, 10 January 2011 10:04  |
Eclipse User |
|
|
|
Hello,
I want to write a program that works on top of EGit/JGit. I have one problem: Given a list of remote repositories (these repos may be specified by some unique information) and a local .git repository, I want to be able to tell to which remote repository of this list the local repository belongs.
"Belongs" means created by pulling from that remote repository in this context. Of course, a local may belong to more than one remote repository, but in my scenario, this is not the case.
Is there any way to identify a remote repository such that I can quickly (without repulling the remote repo) tell, if a local repository corresponds to that remote one. This is not security relevant, so the used concept does not have to work in the case when someone maliciously deletes information from the local repository.
I thought about identifying remotes by a random key and then just adding this key to the config file. However, I think the config is rather local and is not copied from a remote repo. Is this true?
Another idea was just recording the SHA of the first commit in the remote repo and using this as the key saved in the list of remote repos. Then I could just check if the local repository has this commit.
Do you have a good solution for identifying local repositories?
|
|
|
Re: Idenifying a repository [message #648087 is a reply to message #647947] |
Tue, 11 January 2011 03:15  |
Eclipse User |
|
|
|
The configuration (the .git/config file) of your local repo may contain the info you need. If a local branch have been setup from a remote repo's branch then this will be stored in the config. E.g. if you clone a remote repo your local branch "master" is connected to the remote repo by the config params "branch.master.merge" and "branch.master.remote". If branch.master.remote is equal to "origin" then remote.origin.url will tell you about the conrecte URL of that repo.
Same is true if you create a local branch which starts of from a remote tracking branch.
|
|
|
Powered by
FUDForum. Page generated in 0.05023 seconds