diff options
author | Christian Halstrick <christian.halstrick@sap.com> | 2012-08-21 15:10:02 +0200 |
---|---|---|
committer | Stefan Lay <stefan.lay@sap.com> | 2012-08-21 15:10:02 +0200 |
commit | 252727c4fcfb1277661b9e9e3396e6ccd488cc82 (patch) | |
tree | d216a55cc2caf4c702fdd50bf6294f98d254496d /org.eclipse.jgit.test/tst/org/eclipse/jgit/storage | |
parent | 376a741d8f2ddbd7d801067fdbf304ea3ba3a2bb (diff) | |
download | jgit-252727c4fcfb1277661b9e9e3396e6ccd488cc82.tar.gz jgit-252727c4fcfb1277661b9e9e3396e6ccd488cc82.zip |
Support branches with name 'config'
JGit was not able to lookup refs which had the name of files which exist
in the .git folder. When JGit was looking up a ref named X it has a
fixed set of directories where it searched for files named X
(ignore packed refs for now). First directory to search for is .git. In
case of the ref named 'config' it searched there for this file, found it
(it's the .git/config file with the repo configuration in it), parsed
it, found it is an invalid ref and stopped searching. It never looked
for a file .git/refs/heads/config.
I changed JGit in a way that when it finds a file in GIT_DIR which
corresponds to a ref name and if this file doesn't contain a valid ref
then it will ignore the InvalidObjectIdException and continue searching.
Change-Id: Ic26a329fb1624a5b2b2494c78bac4bd76817c100
Bug: 381574
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
Diffstat (limited to 'org.eclipse.jgit.test/tst/org/eclipse/jgit/storage')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/RefDirectoryTest.java | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/RefDirectoryTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/RefDirectoryTest.java index 153f7b791c..a602f7c7d5 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/RefDirectoryTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/RefDirectoryTest.java @@ -360,6 +360,19 @@ public class RefDirectoryTest extends LocalDiskRepositoryTestCase { } @Test + public void testReadNotExistingBranchConfig() throws IOException { + assertNull("find branch config", refdir.getRef("config")); + assertNull("find branch config", refdir.getRef("refs/heads/config")); + } + + @Test + public void testReadBranchConfig() throws IOException { + writeLooseRef("refs/heads/config", A); + + assertNotNull("find branch config", refdir.getRef("config")); + } + + @Test public void testGetRefs_HeadsOnly_AllLoose() throws IOException { Map<String, Ref> heads; Ref a, b; |