[gitg/vala] Allow specifying revision for diff view test



commit bdfd307341252e3fc7d65e6d403510fb984aa062
Author: Jesse van den Kieboom <jesse vandenkieboom epfl ch>
Date:   Thu Jul 12 11:23:51 2012 +0200

    Allow specifying revision for diff view test

 tests/diff-view.vala |   28 +++++++++++++++++++++-------
 1 files changed, 21 insertions(+), 7 deletions(-)
---
diff --git a/tests/diff-view.vala b/tests/diff-view.vala
index 3c1bd8f..74f9a8d 100644
--- a/tests/diff-view.vala
+++ b/tests/diff-view.vala
@@ -67,18 +67,32 @@ class TestDiffView
 			return 1;
 		}
 
-		Ggit.Ref head;
 		Ggit.Commit commit;
 
-		try
+		if (args.length > 2)
 		{
-			head = repo.get_head();
-			commit = head.lookup() as Ggit.Commit;
+			try
+			{
+				commit = repo.revparse(args[2]) as Ggit.Commit;
+			}
+			catch
+			{
+				stderr.printf("Failed to parse `%s' as a commit.\n", args[2]);
+				return 1;
+			}
 		}
-		catch
+		else
 		{
-			stderr.printf("The repository does not have a current HEAD\n");
-			return 1;
+			try
+			{
+				var head = repo.get_head();
+				commit = head.lookup() as Ggit.Commit;
+			}
+			catch
+			{
+				stderr.printf("The repository does not have a current HEAD\n");
+				return 1;
+			}
 		}
 
 		var wnd = new Gtk.Window();



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]