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

Loading…
Cancel
Save