blob: 29a69c5ac47e64f0319fb84c039061614c322d44 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
/*
* 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.api;
import java.io.IOException;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.api.errors.JGitInternalException;
import org.eclipse.jgit.internal.JGitText;
import org.eclipse.jgit.lib.NullProgressMonitor;
import org.eclipse.jgit.lib.ProgressMonitor;
import org.eclipse.jgit.lib.Repository;
/**
* Optimize storage of references.
*
* @since 7.1
*/
public class PackRefsCommand extends GitCommand<String> {
private ProgressMonitor monitor;
private boolean all;
/**
* Creates a new {@link PackRefsCommand} instance with default values.
*
* @param repo
* the repository this command will be used on
*/
public PackRefsCommand(Repository repo) {
super(repo);
this.monitor = NullProgressMonitor.INSTANCE;
}
/**
* Set progress monitor
*
* @param monitor
* a progress monitor
* @return this instance
*/
public PackRefsCommand setProgressMonitor(ProgressMonitor monitor) {
this.monitor = monitor;
return this;
}
/**
* Specify whether to pack all the references.
*
* @param all
* if <code>true</code> all the loose refs will be packed
* @return this instance
*/
public PackRefsCommand setAll(boolean all) {
this.all = all;
return this;
}
/**
* Whether to pack all the references
*
* @return whether to pack all the references
*/
public boolean isAll() {
return all;
}
@Override
public String call() throws GitAPIException {
checkCallable();
try {
repo.getRefDatabase().packRefs(monitor, this);
return JGitText.get().packRefsSuccessful;
} catch (IOException e) {
throw new JGitInternalException(JGitText.get().packRefsFailed, e);
}
}
}
|