Create a show-ref command line for jgit
[egit/zawir.git] / org.spearce.jgit / src / org / spearce / jgit / pgm / ShowRef.java
blobdc0a8e3684339af1af3d796fb36e351d16ee4d7f
1 /*
2 * Copyright (C) 2008 Shawn Pearce <spearce@spearce.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License, version 2, as published by the Free Software Foundation.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
17 package org.spearce.jgit.pgm;
19 import java.util.TreeMap;
21 import org.spearce.jgit.lib.AnyObjectId;
22 import org.spearce.jgit.lib.Ref;
24 class ShowRef extends TextBuiltin {
25 @Override
26 void execute(String[] args) throws Exception {
27 for (final Ref r : new TreeMap<String, Ref>(db.getAllRefs()).values()) {
28 show(r.getObjectId(), r.getName());
29 if (r.getPeeledObjectId() != null)
30 show(r.getPeeledObjectId(), r.getName() + "^{}");
34 private void show(final AnyObjectId id, final String name) {
35 out.print(id);
36 out.print('\t');
37 out.print(name);
38 out.println();