diff options
author | Yash Chaturvedi <quic_zeref@quicinc.com> | 2024-11-14 20:03:08 +0530 |
---|---|---|
committer | Yash Chaturvedi <quic_zeref@quicinc.com> | 2024-11-22 10:07:07 +0530 |
commit | 6fa28d7677f8242d73dc32294fa7db6e86c23b25 (patch) | |
tree | e686e175629ef24f43490f76e84595b9258541e4 /org.eclipse.jgit.pgm/src | |
parent | f295477b1925cc272c6219126daf1fd7cfc5b602 (diff) | |
download | jgit-6fa28d7677f8242d73dc32294fa7db6e86c23b25.tar.gz jgit-6fa28d7677f8242d73dc32294fa7db6e86c23b25.zip |
Add pack-refs command to the CLI
This command can be used to optimize storage of references.
For a RefDirectory database, it packs non-symbolic, loose refs into
packed-refs. By default, only the references under '$GIT_DIR/refs/tags'
are packed. The '--all' option can be used to pack all the references
under '$GIT_DIR/refs'.
For Reftable, all refs are compacted into a single table.
Change-Id: I92e786403f8638d35ae3037844a7ad89e8959e02
Diffstat (limited to 'org.eclipse.jgit.pgm/src')
-rw-r--r-- | org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/PackRefs.java | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/PackRefs.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/PackRefs.java new file mode 100644 index 0000000000..ee05f5ca0b --- /dev/null +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/PackRefs.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Qualcomm Innovation Center, Inc. + * and other copyright owners as documented in the project's IP log. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Distribution License v. 1.0 which is available at + * https://www.eclipse.org/org/documents/edl-v10.php. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +package org.eclipse.jgit.pgm; + +import org.eclipse.jgit.api.Git; +import org.eclipse.jgit.api.errors.GitAPIException; +import org.eclipse.jgit.lib.TextProgressMonitor; +import org.kohsuke.args4j.Option; + +@Command(common = true, usage = "usage_PackRefs") +class PackRefs extends TextBuiltin { + @Option(name = "--all", usage = "usage_All") + private boolean all; + + @Override + protected void run() { + Git git = Git.wrap(db); + try { + git.packRefs().setProgressMonitor(new TextProgressMonitor(errw)) + .setAll(all).call(); + } catch (GitAPIException e) { + throw die(e.getMessage(), e); + } + } +} |