View Javadoc
1   /*
2    * Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org> and others
3    *
4    * This program and the accompanying materials are made available under the
5    * terms of the Eclipse Distribution License v. 1.0 which is available at
6    * https://www.eclipse.org/org/documents/edl-v10.php.
7    *
8    * SPDX-License-Identifier: BSD-3-Clause
9    */
10  
11  package org.eclipse.jgit.pgm;
12  
13  import org.eclipse.jgit.revwalk.ObjectWalk;
14  import org.eclipse.jgit.revwalk.RevCommit;
15  import org.eclipse.jgit.revwalk.RevFlag;
16  import org.eclipse.jgit.revwalk.RevObject;
17  import org.eclipse.jgit.revwalk.RevTree;
18  
19  @Command(usage = "usage_RevList")
20  class RevList extends RevWalkTextBuiltin {
21  	/** {@inheritDoc} */
22  	@Override
23  	protected void show(RevCommit c) throws Exception {
24  		if (c.has(RevFlag.UNINTERESTING))
25  			outw.print('-');
26  		c.getId().copyTo(outbuffer, outw);
27  		if (parents)
28  			for (int i = 0; i < c.getParentCount(); i++) {
29  				outw.print(' ');
30  				c.getParent(i).getId().copyTo(outbuffer, outw);
31  			}
32  		outw.println();
33  	}
34  
35  	/** {@inheritDoc} */
36  	@Override
37  	protected void show(ObjectWalk ow, RevObject obj)
38  			throws Exception {
39  		if (obj.has(RevFlag.UNINTERESTING))
40  			outw.print('-');
41  		obj.getId().copyTo(outbuffer, outw);
42  		final String path = ow.getPathString();
43  		if (path != null) {
44  			outw.print(' ');
45  			outw.print(path);
46  		} else if (obj instanceof RevTree)
47  			outw.print(' ');
48  		outw.println();
49  
50  	}
51  }