Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

2008-12-03 Miguel de Icaza <miguel@novell.com>

	* test.cs: make the sample program dump all the refs.

	* Lib/Repository.cs: Expose GetAllRefs.

	* Lib/RefDatabase.cs (ReadOneLooseRef): Do not crash if the
	refName is not present in the looseKeys.

	(RefreshPackedRefs): If the packed-refs file does not exist, do
	not try to continue, it would otherwise crash.
  • Loading branch information...
commit e79e1a52daa2307011c6bba778ff89504b17943b 1 parent 37c2a7c
Miguel de Icaza authored
View
10 ChangeLog
@@ -1,5 +1,15 @@
2008-12-03 Miguel de Icaza <miguel@novell.com>
+ * test.cs: make the sample program dump all the refs.
+
+ * Lib/Repository.cs: Expose GetAllRefs.
+
+ * Lib/RefDatabase.cs (ReadOneLooseRef): Do not crash if the
+ refName is not present in the looseKeys.
+
+ (RefreshPackedRefs): If the packed-refs file does not exist, do
+ not try to continue, it would otherwise crash.
+
* Lib/WindowedFile.cs: Implement another file from the original
Java implementation.
View
8 Lib/RefDatabase.cs
@@ -202,8 +202,9 @@ private void ReadLooseRefs(Dictionary<string, Ref> avail, string prefix, Directo
private void ReadOneLooseRef(Dictionary<string, Ref> avail, string refName, FileSystemInfo ent)
{
- CachedRef reff = looseRefs[refName];
- if (reff != null)
+ CachedRef reff;
+
+ if (looseRefs.TryGetValue (refName, out reff) && reff != null)
{
if (reff.LastModified == ent.LastWriteTime)
{
@@ -346,6 +347,9 @@ private Ref ReadRefBasic(string name, int depth)
private void RefreshPackedRefs()
{
+ if (!_packedRefsFile.Exists)
+ return;
+
DateTime currTime = _packedRefsFile.LastWriteTime;
long currLen = currTime == DateTime.MinValue ? 0 : _packedRefsFile.Length;
if (currTime == packedRefsLastModified && currLen == packedRefsLength)
View
7 Lib/Repository.cs
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2007, Dave Watson <dwatson@mimvista.com>
* Copyright (C) 2008, Robin Rosenberg <robin.rosenberg@dewire.com>
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
@@ -901,6 +901,11 @@ public RepositoryState GetRespositoryState()
return RepositoryState.Safe;
}
+ public Dictionary<string, Ref> GetAllRefs ()
+ {
+ return _refs.GetAllRefs ();
+ }
+
/**
* Check validty of a ref name. It must not contain character that has
* a special meaning in a Git object reference expression. Some other
View
2  Makefile
@@ -87,7 +87,7 @@ test.exe: Gitty.Lib.CSharp.dll
$(CSC) -r:Gitty.Lib.CSharp.dll -debug test.cs
run: test.exe
- mono test.exe
+ mono --debug test.exe
clean:
rm -f *.dll *.mdb *.exe
View
7 test.cs
@@ -7,6 +7,11 @@ class X {
static void Main (string [] args)
{
var repo = new Repository (new DirectoryInfo ("/cvs/egit/.git"));
-
+
+ Console.WriteLine ("Refs:");
+ var refs = repo.GetAllRefs ();
+ foreach (var k in refs){
+ Console.WriteLine (" {0} -> {1}", k.Key, k.Value);
+ }
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.