git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[JGIT PATCH 3/3] Introduce the command 'jgit gui'

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jul 12, 2009, 14:47 UTC
Message-ID
<3966c8049c37155b2d09d3b4d2997d9e289d1e7a.1247408350u.git.johannes.schindelin@gmx.de>
In-Reply-To
<cover.1247408350u.git.johannes.schindelin@gmx.de>

Expose the graph-based user interface to the user. This command takes the same arguments as 'jgit log'.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 .../services/org.spearce.jgit.pgm.TextBuiltin      |    1 +
 .../src/org/spearce/jgit/pgm/Gui.java              |  100 ++++++++++++++++++++
 2 files changed, 101 insertions(+), 0 deletions(-)
 create mode 100644 org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Gui.java
diff --git a/org.spearce.jgit.pgm/src/META-INF/services/org.spearce.jgit.pgm.TextBuiltin b/org.spearce.jgit.pgm/src/META-INF/services/org.spearce.jgit.pgm.TextBuiltin
index 3a8cc09..335a643 100644
--- a/org.spearce.jgit.pgm/src/META-INF/services/org.spearce.jgit.pgm.TextBuiltin
+++ b/org.spearce.jgit.pgm/src/META-INF/services/org.spearce.jgit.pgm.TextBuiltin
@@ -4,6 +4,7 @@ org.spearce.jgit.pgm.Daemon
 org.spearce.jgit.pgm.DiffTree
 org.spearce.jgit.pgm.Fetch
 org.spearce.jgit.pgm.Glog
+org.spearce.jgit.pgm.Gui
 org.spearce.jgit.pgm.IndexPack
 org.spearce.jgit.pgm.Init
 org.spearce.jgit.pgm.Log
diff --git a/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Gui.java b/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Gui.java
new file mode 100644
index 0000000..59904a7
--- /dev/null
+++ b/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Gui.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2009, Shawn O. Pearce <spearce@spearce.org>,
+ *                     Johannes E. Schindelin <johannes.schindelin@gmx.de>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer in the documentation and/or other materials provided
+ *   with the distribution.
+ *
+ * - Neither the name of the Git Development Community nor the
+ *   names of its contributors may be used to endorse or promote
+ *   products derived from this software without specific prior
+ *   written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.spearce.jgit.pgm;
+
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+
+import java.io.File;
+
+import javax.swing.JFrame;
+
+import org.spearce.jgit.gui.CommitGraph;
+import org.spearce.jgit.gui.GraphWalk;
+
+import org.spearce.jgit.revwalk.RevCommit;
+import org.spearce.jgit.revwalk.RevWalk;
+
+class Gui extends RevWalkTextBuiltin {
+	final JFrame frame;
+
+	CommitGraph graph;
+
+	Gui() {
+		frame = new JFrame();
+		frame.addWindowListener(new WindowAdapter() {
+			@Override
+			public void windowClosing(final WindowEvent e) {
+				frame.dispose();
+			}
+		});
+	}
+
+	@Override
+	protected int walkLoop() throws Exception {
+		graph = new CommitGraph((GraphWalk)walk);
+		frame.getContentPane().add(graph);
+
+		frame.setTitle("[" + repoName() + "]");
+		frame.pack();
+		frame.setVisible(true);
+		return 0;
+	}
+
+	@Override
+	protected void show(final RevCommit c) throws Exception {
+		throw new UnsupportedOperationException();
+	}
+
+	@Override
+	protected RevWalk createWalk() {
+		if (objects)
+			throw die("Cannot use --objects with gui");
+		final GraphWalk w = new GraphWalk(db);
+		return w;
+	}
+
+	private String repoName() {
+		final File f = db.getDirectory();
+		String n = f.getName();
+		if (".git".equals(n))
+			n = f.getParentFile().getName();
+		return n;
+	}
+}
-- 
1.6.3.3.644.g82c56
Previous: Johannes SchindelinNext: Robin Rosenberg
Message 4 of 8 in “Request for help: graph-based UI”
  1. 0/3 Request for help: graph-based UIJohannes Schindelin, Jul 12, 2009
  2. 1/3 Add a rudimentary graph-based user interfaceJohannes Schindelin, Jul 12, 2009
  3. 2/3 Add license boiler-platesJohannes Schindelin, Jul 12, 2009
  4. 3/3 Introduce the command 'jgit gui'Johannes Schindelin, Jul 12, 2009
  5. Robin RosenbergJul 21, 2009
  6. Douglas CamposJul 25, 2009
  7. Shawn O. PearceJul 25, 2009
  8. Johannes SchindelinJul 25, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.