Browse Source

Consistently use 'path' for the path to a subrepo in RepoCommand

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Change-Id: I79ea7eb7b4d319e0100e3121aca5ef82eb8ad92a
stable-4.7
Han-Wen Nienhuys 8 years ago committed by Matthias Sohn
parent
commit
27b05c7d71
  1. 36
      org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java

36
org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java

@ -96,8 +96,8 @@ import org.eclipse.jgit.util.FileUtils;
* If called against a bare repository, it will replace all the existing content
* of the repository with the contents populated from the manifest.
*
* repo manifest allows projects overlapping, e.g. one project's path is
* &quot;foo&quot; and another project's path is &quot;foo/bar&quot;. This won't
* repo manifest allows projects overlapping, e.g. one project's manifestPath is
* &quot;foo&quot; and another project's manifestPath is &quot;foo/bar&quot;. This won't
* work in git submodule, so we'll skip all the sub projects
* (&quot;foo/bar&quot; in the example) while converting.
*
@ -105,7 +105,7 @@ import org.eclipse.jgit.util.FileUtils;
* @since 3.4
*/
public class RepoCommand extends GitCommand<RevCommit> {
private String path;
private String manifestPath;
private String uri;
private String groupsParam;
private String branch;
@ -244,7 +244,7 @@ public class RepoCommand extends GitCommand<RevCommit> {
* @return this command
*/
public RepoCommand setPath(String path) {
this.path = path;
this.manifestPath = path;
return this;
}
@ -452,11 +452,11 @@ public class RepoCommand extends GitCommand<RevCommit> {
throw new IllegalArgumentException(
JGitText.get().uriNotConfigured);
if (inputStream == null) {
if (path == null || path.length() == 0)
if (manifestPath == null || manifestPath.length() == 0)
throw new IllegalArgumentException(
JGitText.get().pathNotConfigured);
try {
inputStream = new FileInputStream(path);
inputStream = new FileInputStream(manifestPath);
} catch (IOException e) {
throw new IllegalArgumentException(
JGitText.get().pathNotConfigured);
@ -473,7 +473,7 @@ public class RepoCommand extends GitCommand<RevCommit> {
git = new Git(repo);
ManifestParser parser = new ManifestParser(
includedReader, path, branch, uri, groupsParam, repo);
includedReader, manifestPath, branch, uri, groupsParam, repo);
try {
parser.read(inputStream);
for (RepoProject proj : parser.getFilteredProjects()) {
@ -504,7 +504,7 @@ public class RepoCommand extends GitCommand<RevCommit> {
Config cfg = new Config();
StringBuilder attributes = new StringBuilder();
for (RepoProject proj : bareProjects) {
String name = proj.getPath();
String path = proj.getPath();
String nameUri = proj.getName();
ObjectId objectId;
if (ObjectId.isId(proj.getRevision())
@ -520,7 +520,7 @@ public class RepoCommand extends GitCommand<RevCommit> {
}
if (recordRemoteBranch) {
// can be branch or tag
cfg.setString("submodule", name, "branch", //$NON-NLS-1$ //$NON-NLS-2$
cfg.setString("submodule", path, "branch", //$NON-NLS-1$ //$NON-NLS-2$
proj.getRevision());
}
@ -530,14 +530,14 @@ public class RepoCommand extends GitCommand<RevCommit> {
// depth in the 'clone-depth' field, while
// git core only uses a binary 'shallow = true/false'
// hint, we'll map any depth to 'shallow = true'
cfg.setBoolean("submodule", name, "shallow", //$NON-NLS-1$ //$NON-NLS-2$
cfg.setBoolean("submodule", path, "shallow", //$NON-NLS-1$ //$NON-NLS-2$
true);
}
}
if (recordSubmoduleLabels) {
StringBuilder rec = new StringBuilder();
rec.append("/"); //$NON-NLS-1$
rec.append(name);
rec.append(path);
for (String group : proj.getGroups()) {
rec.append(" "); //$NON-NLS-1$
rec.append(group);
@ -545,11 +545,11 @@ public class RepoCommand extends GitCommand<RevCommit> {
rec.append("\n"); //$NON-NLS-1$
attributes.append(rec.toString());
}
cfg.setString("submodule", name, "path", name); //$NON-NLS-1$ //$NON-NLS-2$
cfg.setString("submodule", name, "url", nameUri); //$NON-NLS-1$ //$NON-NLS-2$
cfg.setString("submodule", path, "path", path); //$NON-NLS-1$ //$NON-NLS-2$
cfg.setString("submodule", path, "url", nameUri); //$NON-NLS-1$ //$NON-NLS-2$
// create gitlink
DirCacheEntry dcEntry = new DirCacheEntry(name);
DirCacheEntry dcEntry = new DirCacheEntry(path);
dcEntry.setObjectId(objectId);
dcEntry.setFileMode(FileMode.GITLINK);
builder.add(dcEntry);
@ -636,17 +636,17 @@ public class RepoCommand extends GitCommand<RevCommit> {
}
}
private void addSubmodule(String url, String name, String revision,
private void addSubmodule(String url, String path, String revision,
List<CopyFile> copyfiles, Set<String> groups, String recommendShallow)
throws GitAPIException, IOException {
if (repo.isBare()) {
RepoProject proj = new RepoProject(url, name, revision, null, groups, recommendShallow);
RepoProject proj = new RepoProject(url, path, revision, null, groups, recommendShallow);
proj.addCopyFiles(copyfiles);
bareProjects.add(proj);
} else {
SubmoduleAddCommand add = git
.submoduleAdd()
.setPath(name)
.setPath(path)
.setURI(url);
if (monitor != null)
add.setProgressMonitor(monitor);
@ -658,7 +658,7 @@ public class RepoCommand extends GitCommand<RevCommit> {
.call();
}
subRepo.close();
git.add().addFilepattern(name).call();
git.add().addFilepattern(path).call();
}
for (CopyFile copyfile : copyfiles) {
copyfile.copy();

Loading…
Cancel
Save