--- /dev/null
+/*\r
+ * Copyright (C) 2012, Tomasz Zarna <tomasz.zarna@tasktop.com>\r
+ * and other copyright owners as documented in the project's IP log.\r
+ *\r
+ * This program and the accompanying materials are made available\r
+ * under the terms of the Eclipse Distribution License v1.0 which\r
+ * accompanies this distribution, is reproduced below, and is\r
+ * available at http://www.eclipse.org/org/documents/edl-v10.php\r
+ *\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or\r
+ * without modification, are permitted provided that the following\r
+ * conditions are met:\r
+ *\r
+ * - Redistributions of source code must retain the above copyright\r
+ * notice, this list of conditions and the following disclaimer.\r
+ *\r
+ * - Redistributions in binary form must reproduce the above\r
+ * copyright notice, this list of conditions and the following\r
+ * disclaimer in the documentation and/or other materials provided\r
+ * with the distribution.\r
+ *\r
+ * - Neither the name of the Eclipse Foundation, Inc. nor the\r
+ * names of its contributors may be used to endorse or promote\r
+ * products derived from this software without specific prior\r
+ * written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND\r
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,\r
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\r
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\r
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\r
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\r
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF\r
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+package org.eclipse.jgit.pgm;\r
+\r
+import static org.junit.Assert.assertArrayEquals;\r
+import static org.junit.Assert.assertEquals;\r
+\r
+import org.eclipse.jgit.api.Git;\r
+import org.eclipse.jgit.lib.CLIRepositoryTestCase;\r
+import org.junit.Test;\r
+\r
+public class ReflogTest extends CLIRepositoryTestCase {\r
+ @Test\r
+ public void testClean() throws Exception {\r
+ assertArrayEquals(new String[] { "" }, execute("git reflog"));\r
+ }\r
+\r
+ @Test\r
+ public void testSingleCommit() throws Exception {\r
+ new Git(db).commit().setMessage("initial commit").call();\r
+\r
+ assertEquals("6fd41be HEAD@{0}: commit (initial): initial commit",\r
+ execute("git reflog")[0]);\r
+ }\r
+\r
+ @Test\r
+ public void testBranch() throws Exception {\r
+ Git git = new Git(db);\r
+ git.commit().setMessage("first commit").call();\r
+ git.checkout().setCreateBranch(true).setName("side").call();\r
+ writeTrashFile("file", "side content");\r
+ git.add().addFilepattern("file").call();\r
+ git.commit().setMessage("side commit").call();\r
+\r
+ assertArrayEquals(new String[] {\r
+ "38890c7 side@{0}: commit: side commit",\r
+ "d216986 side@{1}: branch: Created from commit first commit",\r
+ "" }, execute("git reflog refs/heads/side"));\r
+ }\r
+}
\ No newline at end of file
org.eclipse.jgit.pgm.MergeBase
org.eclipse.jgit.pgm.Push
org.eclipse.jgit.pgm.ReceivePack
+org.eclipse.jgit.pgm.Reflog
org.eclipse.jgit.pgm.RevList
org.eclipse.jgit.pgm.RevParse
org.eclipse.jgit.pgm.Rm
usage_listBothRemoteTrackingAndLocalBranches=list both remote-tracking and local branches
usage_listCreateOrDeleteBranches=List, create, or delete branches
usage_logAllPretty=format:%H %ct %P' output=log --all '--pretty=format:%H %ct %P' output
+usage_manageReflogInformation=Manage reflog information
usage_mergeStrategy=Use the given merge strategy. Can be supplied more than once to specify them in the order they should be tried. If there is no -s option, the resolve strategy is used. Currently the following strategies are supported: ours, theirs, simple-two-way-in-core, resolve
usage_moveRenameABranch=move/rename a branch
usage_nameStatus=show only name and status of files
--- /dev/null
+/*\r
+ * Copyright (C) 2012, Tomasz Zarna <tomasz.zarna@tasktop.com>\r
+ * and other copyright owners as documented in the project's IP log.\r
+ *\r
+ * This program and the accompanying materials are made available\r
+ * under the terms of the Eclipse Distribution License v1.0 which\r
+ * accompanies this distribution, is reproduced below, and is\r
+ * available at http://www.eclipse.org/org/documents/edl-v10.php\r
+ *\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or\r
+ * without modification, are permitted provided that the following\r
+ * conditions are met:\r
+ *\r
+ * - Redistributions of source code must retain the above copyright\r
+ * notice, this list of conditions and the following disclaimer.\r
+ *\r
+ * - Redistributions in binary form must reproduce the above\r
+ * copyright notice, this list of conditions and the following\r
+ * disclaimer in the documentation and/or other materials provided\r
+ * with the distribution.\r
+ *\r
+ * - Neither the name of the Eclipse Foundation, Inc. nor the\r
+ * names of its contributors may be used to endorse or promote\r
+ * products derived from this software without specific prior\r
+ * written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND\r
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,\r
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\r
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\r
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\r
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\r
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF\r
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+package org.eclipse.jgit.pgm;\r
+\r
+import java.util.Collection;\r
+\r
+import org.eclipse.jgit.api.Git;\r
+import org.eclipse.jgit.api.ReflogCommand;\r
+import org.eclipse.jgit.lib.Constants;\r
+import org.eclipse.jgit.lib.ObjectId;\r
+import org.eclipse.jgit.lib.Repository;\r
+import org.eclipse.jgit.storage.file.ReflogEntry;\r
+import org.kohsuke.args4j.Argument;\r
+\r
+@Command(common = true, usage = "usage_manageReflogInformation")\r
+class Reflog extends TextBuiltin {\r
+\r
+ @Argument(metaVar = "metaVar_ref")\r
+ private String ref;\r
+\r
+ @Override\r
+ protected void run() throws Exception {\r
+ ReflogCommand cmd = new Git(db).reflog();\r
+ if (ref != null)\r
+ cmd.setRef(ref);\r
+ Collection<ReflogEntry> entries = cmd.call();\r
+ int i = 0;\r
+ for (ReflogEntry entry : entries) {\r
+ outw.println(toString(entry, i++));\r
+ }\r
+ }\r
+\r
+ private String toString(ReflogEntry entry, int i) {\r
+ final StringBuilder s = new StringBuilder();\r
+ s.append(entry.getNewId().abbreviate(7).name());\r
+ s.append(" ");\r
+ s.append(ref == null ? Constants.HEAD : Repository.shortenRefName(ref));\r
+ s.append("@{" + i + "}:");\r
+ s.append(" ");\r
+ // temporary workaround for bug 393463\r
+ if (entry.getOldId().equals(ObjectId.zeroId()))\r
+ s.append(entry.getComment().replaceFirst("^commit:",\r
+ "commit (initial):"));\r
+ else\r
+ s.append(entry.getComment());\r
+ return s.toString();\r
+ }\r
+}\r