Browse Source

Introduce a named constant for the .git directory.

Not all occurrences of ".git" are replaced by this constant, only
those where it actually refers to the directory with that name, i.e
not the ".git" directory suffix.

Asserts and comment are also excluded from replacement.

Change-Id: I65a9da89aedd53817f2ea3eaab4f9c2bed35d7ee
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
stable-0.7
Robin Rosenberg 15 years ago
parent
commit
0b8b6b5309
  1. 2
      org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java
  2. 2
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java
  3. 4
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Glog.java
  4. 4
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Init.java
  5. 2
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java
  6. 7
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ReceivePack.java
  7. 7
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java
  8. 28
      org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/T0003_Basic.java
  9. 3
      org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java
  10. 4
      org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java
  11. 4
      org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java
  12. 5
      org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportLocal.java
  13. 6
      org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java
  14. 5
      org.eclipse.jgit/src/org/eclipse/jgit/treewalk/FileTreeIterator.java
  15. 2
      org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java

2
org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java

@ -286,7 +286,7 @@ public abstract class LocalDiskRepositoryTestCase extends TestCase {
*/ */
private Repository createRepository(boolean bare) throws IOException { private Repository createRepository(boolean bare) throws IOException {
String uniqueId = System.currentTimeMillis() + "_" + (testCount++); String uniqueId = System.currentTimeMillis() + "_" + (testCount++);
String gitdirName = "test" + uniqueId + (bare ? "" : "/") + ".git"; String gitdirName = "test" + uniqueId + (bare ? "" : "/") + Constants.DOT_GIT;
File gitdir = new File(trash, gitdirName).getCanonicalFile(); File gitdir = new File(trash, gitdirName).getCanonicalFile();
Repository db = new Repository(gitdir); Repository db = new Repository(gitdir);

2
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java

@ -100,7 +100,7 @@ class Clone extends AbstractFetchCommand {
} }
} }
if (gitdir == null) if (gitdir == null)
gitdir = new File(localName, ".git"); gitdir = new File(localName, Constants.DOT_GIT);
db = new Repository(gitdir); db = new Repository(gitdir);
db.create(); db.create();

4
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Glog.java

@ -1,4 +1,5 @@
/* /*
* Copyright (C) 2010, Robin Rosenberg <robin.rosenberg@dewire.com>
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org> * Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
* and other copyright owners as documented in the project's IP log. * and other copyright owners as documented in the project's IP log.
* *
@ -57,6 +58,7 @@ import javax.swing.JPanel;
import javax.swing.JScrollPane; import javax.swing.JScrollPane;
import org.eclipse.jgit.awtui.CommitGraphPane; import org.eclipse.jgit.awtui.CommitGraphPane;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.revplot.PlotWalk; import org.eclipse.jgit.revplot.PlotWalk;
import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevSort; import org.eclipse.jgit.revwalk.RevSort;
@ -125,7 +127,7 @@ class Glog extends RevWalkTextBuiltin {
private String repoName() { private String repoName() {
final File f = db.getDirectory(); final File f = db.getDirectory();
String n = f.getName(); String n = f.getName();
if (".git".equals(n)) if (Constants.DOT_GIT.equals(n))
n = f.getParentFile().getName(); n = f.getParentFile().getName();
return n; return n;
} }

4
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Init.java

@ -1,6 +1,7 @@
/* /*
* Copyright (C) 2009, Constantine Plotnikov <constantine.plotnikov@gmail.com> * Copyright (C) 2009, Constantine Plotnikov <constantine.plotnikov@gmail.com>
* Copyright (C) 2008, Google Inc. * Copyright (C) 2008, Google Inc.
* Copyright (C) 2010, Robin Rosenberg <robin.rosenberg@dewire.com>
* and other copyright owners as documented in the project's IP log. * and other copyright owners as documented in the project's IP log.
* *
* This program and the accompanying materials are made available * This program and the accompanying materials are made available
@ -47,6 +48,7 @@ package org.eclipse.jgit.pgm;
import java.io.File; import java.io.File;
import org.kohsuke.args4j.Option; import org.kohsuke.args4j.Option;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.Repository;
@Command(common = true, usage = "Create an empty git repository") @Command(common = true, usage = "Create an empty git repository")
@ -62,7 +64,7 @@ class Init extends TextBuiltin {
@Override @Override
protected void run() throws Exception { protected void run() throws Exception {
if (gitdir == null) if (gitdir == null)
gitdir = new File(bare ? "." : ".git"); gitdir = new File(bare ? "." : Constants.DOT_GIT);
db = new Repository(gitdir); db = new Repository(gitdir);
db.create(bare); db.create(bare);
out.println("Initialized empty Git repository in " out.println("Initialized empty Git repository in "

2
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java

@ -228,7 +228,7 @@ public class Main {
} }
File current = new File("").getAbsoluteFile(); File current = new File("").getAbsoluteFile();
while (current != null) { while (current != null) {
final File gitDir = new File(current, ".git"); final File gitDir = new File(current, Constants.DOT_GIT);
if (gitDir.isDirectory()) if (gitDir.isDirectory())
return gitDir; return gitDir;
current = current.getParentFile(); current = current.getParentFile();

7
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ReceivePack.java

@ -1,6 +1,6 @@
/* /*
* Copyright (C) 2008-2009, Google Inc. * Copyright (C) 2008-2009, Google Inc.
* Copyright (C) 2009, Robin Rosenberg <robin.rosenberg@dewire.com> * Copyright (C) 2009-2010, Robin Rosenberg <robin.rosenberg@dewire.com>
* and other copyright owners as documented in the project's IP log. * and other copyright owners as documented in the project's IP log.
* *
* This program and the accompanying materials are made available * This program and the accompanying materials are made available
@ -47,6 +47,7 @@ package org.eclipse.jgit.pgm;
import java.io.File; import java.io.File;
import org.kohsuke.args4j.Argument; import org.kohsuke.args4j.Argument;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.Repository;
@Command(common = false, usage = "Server side backend for 'jgit push'") @Command(common = false, usage = "Server side backend for 'jgit push'")
@ -63,8 +64,8 @@ class ReceivePack extends TextBuiltin {
protected void run() throws Exception { protected void run() throws Exception {
final org.eclipse.jgit.transport.ReceivePack rp; final org.eclipse.jgit.transport.ReceivePack rp;
if (new File(dstGitdir, ".git").isDirectory()) if (new File(dstGitdir, Constants.DOT_GIT).isDirectory())
dstGitdir = new File(dstGitdir, ".git"); dstGitdir = new File(dstGitdir, Constants.DOT_GIT);
db = new Repository(dstGitdir); db = new Repository(dstGitdir);
if (!db.getObjectsDirectory().isDirectory()) if (!db.getObjectsDirectory().isDirectory())
throw die("'" + dstGitdir.getPath() + "' not a git repository"); throw die("'" + dstGitdir.getPath() + "' not a git repository");

7
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java

@ -1,6 +1,6 @@
/* /*
* Copyright (C) 2008-2009, Google Inc. * Copyright (C) 2008-2009, Google Inc.
* Copyright (C) 2009, Robin Rosenberg <robin.rosenberg@dewire.com> * Copyright (C) 2009-2010, Robin Rosenberg <robin.rosenberg@dewire.com>
* and other copyright owners as documented in the project's IP log. * and other copyright owners as documented in the project's IP log.
* *
* This program and the accompanying materials are made available * This program and the accompanying materials are made available
@ -48,6 +48,7 @@ import java.io.File;
import org.kohsuke.args4j.Argument; import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.Option; import org.kohsuke.args4j.Option;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.Repository;
@Command(common = false, usage = "Server side backend for 'jgit fetch'") @Command(common = false, usage = "Server side backend for 'jgit fetch'")
@ -67,8 +68,8 @@ class UploadPack extends TextBuiltin {
protected void run() throws Exception { protected void run() throws Exception {
final org.eclipse.jgit.transport.UploadPack rp; final org.eclipse.jgit.transport.UploadPack rp;
if (new File(srcGitdir, ".git").isDirectory()) if (new File(srcGitdir, Constants.DOT_GIT).isDirectory())
srcGitdir = new File(srcGitdir, ".git"); srcGitdir = new File(srcGitdir, Constants.DOT_GIT);
db = new Repository(srcGitdir); db = new Repository(srcGitdir);
if (!db.getObjectsDirectory().isDirectory()) if (!db.getObjectsDirectory().isDirectory())
throw die("'" + srcGitdir.getPath() + "' not a git repository"); throw die("'" + srcGitdir.getPath() + "' not a git repository");

28
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/T0003_Basic.java

@ -1,6 +1,6 @@
/* /*
* Copyright (C) 2007, Dave Watson <dwatson@mimvista.com> * Copyright (C) 2007, Dave Watson <dwatson@mimvista.com>
* Copyright (C) 2007-2009, Robin Rosenberg <robin.rosenberg@dewire.com> * Copyright (C) 2007-2010, Robin Rosenberg <robin.rosenberg@dewire.com>
* Copyright (C) 2006-2008, Shawn O. Pearce <spearce@spearce.org> * Copyright (C) 2006-2008, Shawn O. Pearce <spearce@spearce.org>
* and other copyright owners as documented in the project's IP log. * and other copyright owners as documented in the project's IP log.
* *
@ -57,7 +57,7 @@ import org.eclipse.jgit.errors.ConfigInvalidException;
public class T0003_Basic extends SampleDataRepositoryTestCase { public class T0003_Basic extends SampleDataRepositoryTestCase {
public void test001_Initalize() { public void test001_Initalize() {
final File gitdir = new File(trash, ".git"); final File gitdir = new File(trash, Constants.DOT_GIT);
final File objects = new File(gitdir, "objects"); final File objects = new File(gitdir, "objects");
final File objects_pack = new File(objects, "pack"); final File objects_pack = new File(objects, "pack");
final File objects_info = new File(objects, "info"); final File objects_info = new File(objects, "info");
@ -97,11 +97,11 @@ public class T0003_Basic extends SampleDataRepositoryTestCase {
*/ */
public void test000_openrepo_default_gitDirSet() throws IOException { public void test000_openrepo_default_gitDirSet() throws IOException {
File repo1Parent = new File(trash.getParentFile(), "r1"); File repo1Parent = new File(trash.getParentFile(), "r1");
Repository repo1initial = new Repository(new File(repo1Parent, ".git")); Repository repo1initial = new Repository(new File(repo1Parent, Constants.DOT_GIT));
repo1initial.create(); repo1initial.create();
repo1initial.close(); repo1initial.close();
File theDir = new File(repo1Parent, ".git"); File theDir = new File(repo1Parent, Constants.DOT_GIT);
Repository r = new Repository(theDir, null); Repository r = new Repository(theDir, null);
assertEqualsPath(theDir, r.getDirectory()); assertEqualsPath(theDir, r.getDirectory());
assertEqualsPath(repo1Parent, r.getWorkDir()); assertEqualsPath(repo1Parent, r.getWorkDir());
@ -117,11 +117,11 @@ public class T0003_Basic extends SampleDataRepositoryTestCase {
*/ */
public void test000_openrepo_default_gitDirAndWorkTreeSet() throws IOException { public void test000_openrepo_default_gitDirAndWorkTreeSet() throws IOException {
File repo1Parent = new File(trash.getParentFile(), "r1"); File repo1Parent = new File(trash.getParentFile(), "r1");
Repository repo1initial = new Repository(new File(repo1Parent, ".git")); Repository repo1initial = new Repository(new File(repo1Parent, Constants.DOT_GIT));
repo1initial.create(); repo1initial.create();
repo1initial.close(); repo1initial.close();
File theDir = new File(repo1Parent, ".git"); File theDir = new File(repo1Parent, Constants.DOT_GIT);
Repository r = new Repository(theDir, repo1Parent.getParentFile()); Repository r = new Repository(theDir, repo1Parent.getParentFile());
assertEqualsPath(theDir, r.getDirectory()); assertEqualsPath(theDir, r.getDirectory());
assertEqualsPath(repo1Parent.getParentFile(), r.getWorkDir()); assertEqualsPath(repo1Parent.getParentFile(), r.getWorkDir());
@ -137,11 +137,11 @@ public class T0003_Basic extends SampleDataRepositoryTestCase {
*/ */
public void test000_openrepo_default_workDirSet() throws IOException { public void test000_openrepo_default_workDirSet() throws IOException {
File repo1Parent = new File(trash.getParentFile(), "r1"); File repo1Parent = new File(trash.getParentFile(), "r1");
Repository repo1initial = new Repository(new File(repo1Parent, ".git")); Repository repo1initial = new Repository(new File(repo1Parent, Constants.DOT_GIT));
repo1initial.create(); repo1initial.create();
repo1initial.close(); repo1initial.close();
File theDir = new File(repo1Parent, ".git"); File theDir = new File(repo1Parent, Constants.DOT_GIT);
Repository r = new Repository(null, repo1Parent); Repository r = new Repository(null, repo1Parent);
assertEqualsPath(theDir, r.getDirectory()); assertEqualsPath(theDir, r.getDirectory());
assertEqualsPath(repo1Parent, r.getWorkDir()); assertEqualsPath(repo1Parent, r.getWorkDir());
@ -159,14 +159,14 @@ public class T0003_Basic extends SampleDataRepositoryTestCase {
File repo1Parent = new File(trash.getParentFile(), "r1"); File repo1Parent = new File(trash.getParentFile(), "r1");
File workdir = new File(trash.getParentFile(), "rw"); File workdir = new File(trash.getParentFile(), "rw");
workdir.mkdir(); workdir.mkdir();
Repository repo1initial = new Repository(new File(repo1Parent, ".git")); Repository repo1initial = new Repository(new File(repo1Parent, Constants.DOT_GIT));
repo1initial.create(); repo1initial.create();
repo1initial.getConfig().setString("core", null, "worktree", repo1initial.getConfig().setString("core", null, "worktree",
workdir.getAbsolutePath()); workdir.getAbsolutePath());
repo1initial.getConfig().save(); repo1initial.getConfig().save();
repo1initial.close(); repo1initial.close();
File theDir = new File(repo1Parent, ".git"); File theDir = new File(repo1Parent, Constants.DOT_GIT);
Repository r = new Repository(theDir, null); Repository r = new Repository(theDir, null);
assertEqualsPath(theDir, r.getDirectory()); assertEqualsPath(theDir, r.getDirectory());
assertEqualsPath(workdir, r.getWorkDir()); assertEqualsPath(workdir, r.getWorkDir());
@ -184,14 +184,14 @@ public class T0003_Basic extends SampleDataRepositoryTestCase {
File repo1Parent = new File(trash.getParentFile(), "r1"); File repo1Parent = new File(trash.getParentFile(), "r1");
File workdir = new File(trash.getParentFile(), "rw"); File workdir = new File(trash.getParentFile(), "rw");
workdir.mkdir(); workdir.mkdir();
Repository repo1initial = new Repository(new File(repo1Parent, ".git")); Repository repo1initial = new Repository(new File(repo1Parent, Constants.DOT_GIT));
repo1initial.create(); repo1initial.create();
repo1initial.getConfig() repo1initial.getConfig()
.setString("core", null, "worktree", "../../rw"); .setString("core", null, "worktree", "../../rw");
repo1initial.getConfig().save(); repo1initial.getConfig().save();
repo1initial.close(); repo1initial.close();
File theDir = new File(repo1Parent, ".git"); File theDir = new File(repo1Parent, Constants.DOT_GIT);
Repository r = new Repository(theDir, null); Repository r = new Repository(theDir, null);
assertEqualsPath(theDir, r.getDirectory()); assertEqualsPath(theDir, r.getDirectory());
assertEqualsPath(workdir, r.getWorkDir()); assertEqualsPath(workdir, r.getWorkDir());
@ -211,11 +211,11 @@ public class T0003_Basic extends SampleDataRepositoryTestCase {
File indexFile = new File(trash, "idx"); File indexFile = new File(trash, "idx");
File objDir = new File(trash, "../obj"); File objDir = new File(trash, "../obj");
File[] altObjDirs = new File[] { db.getObjectsDirectory() }; File[] altObjDirs = new File[] { db.getObjectsDirectory() };
Repository repo1initial = new Repository(new File(repo1Parent, ".git")); Repository repo1initial = new Repository(new File(repo1Parent, Constants.DOT_GIT));
repo1initial.create(); repo1initial.create();
repo1initial.close(); repo1initial.close();
File theDir = new File(repo1Parent, ".git"); File theDir = new File(repo1Parent, Constants.DOT_GIT);
Repository r = new Repository(theDir, null, objDir, altObjDirs, Repository r = new Repository(theDir, null, objDir, altObjDirs,
indexFile); indexFile);
assertEqualsPath(theDir, r.getDirectory()); assertEqualsPath(theDir, r.getDirectory());

3
org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java

@ -308,6 +308,9 @@ public final class Constants {
/** Default remote name used by clone, push and fetch operations */ /** Default remote name used by clone, push and fetch operations */
public static final String DEFAULT_REMOTE_NAME = "origin"; public static final String DEFAULT_REMOTE_NAME = "origin";
/** Default name for the Git repository directory */
public static final String DOT_GIT = ".git";
/** /**
* Create a new digest function for objects. * Create a new digest function for objects.
* *

4
org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java

@ -1,6 +1,6 @@
/* /*
* Copyright (C) 2007, Dave Watson <dwatson@mimvista.com> * Copyright (C) 2007, Dave Watson <dwatson@mimvista.com>
* Copyright (C) 2006-2009, Robin Rosenberg <robin.rosenberg@dewire.com> * Copyright (C) 2006-2010, Robin Rosenberg <robin.rosenberg@dewire.com>
* Copyright (C) 2006-2008, Shawn O. Pearce <spearce@spearce.org> * Copyright (C) 2006-2008, Shawn O. Pearce <spearce@spearce.org>
* and other copyright owners as documented in the project's IP log. * and other copyright owners as documented in the project's IP log.
* *
@ -183,7 +183,7 @@ public class Repository {
if (workTree != null) { if (workTree != null) {
workDir = workTree; workDir = workTree;
if (d == null) if (d == null)
gitDir = new File(workTree, ".git"); gitDir = new File(workTree, Constants.DOT_GIT);
else else
gitDir = d; gitDir = d;
} else { } else {

4
org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java

@ -377,8 +377,8 @@ public class RepositoryCache {
public static File resolve(final File directory) { public static File resolve(final File directory) {
if (isGitRepository(directory)) if (isGitRepository(directory))
return directory; return directory;
if (isGitRepository(new File(directory, ".git"))) if (isGitRepository(new File(directory, Constants.DOT_GIT)))
return new File(directory, ".git"); return new File(directory, Constants.DOT_GIT);
final String name = directory.getName(); final String name = directory.getName();
final File parent = directory.getParentFile(); final File parent = directory.getParentFile();

5
org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportLocal.java

@ -56,6 +56,7 @@ import java.io.PipedOutputStream;
import org.eclipse.jgit.errors.NotSupportedException; import org.eclipse.jgit.errors.NotSupportedException;
import org.eclipse.jgit.errors.TransportException; import org.eclipse.jgit.errors.TransportException;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.util.FS; import org.eclipse.jgit.util.FS;
@ -101,8 +102,8 @@ class TransportLocal extends Transport implements PackTransport {
super(local, uri); super(local, uri);
File d = FS.resolve(new File(PWD), uri.getPath()).getAbsoluteFile(); File d = FS.resolve(new File(PWD), uri.getPath()).getAbsoluteFile();
if (new File(d, ".git").isDirectory()) if (new File(d, Constants.DOT_GIT).isDirectory())
d = new File(d, ".git"); d = new File(d, Constants.DOT_GIT);
remoteGitDir = d; remoteGitDir = d;
} }

6
org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java

@ -50,6 +50,8 @@ import java.net.URL;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.eclipse.jgit.lib.Constants;
/** /**
* This URI like construct used for referencing Git archives over the net, as * This URI like construct used for referencing Git archives over the net, as
* well as locally stored archives. The most important difference compared to * well as locally stored archives. The most important difference compared to
@ -57,8 +59,6 @@ import java.util.regex.Pattern;
* any special character is written as-is. * any special character is written as-is.
*/ */
public class URIish { public class URIish {
private static final String DOT_GIT = ".git";
private static final Pattern FULL_URI = Pattern private static final Pattern FULL_URI = Pattern
.compile("^(?:([a-z][a-z0-9+-]+)://(?:([^/]+?)(?::([^/]+?))?@)?(?:([^/]+?))?(?::(\\d+))?)?((?:[A-Za-z]:)?/.+)$"); .compile("^(?:([a-z][a-z0-9+-]+)://(?:([^/]+?)(?::([^/]+?))?@)?(?:([^/]+?))?(?::(\\d+))?)?((?:[A-Za-z]:)?/.+)$");
@ -408,7 +408,7 @@ public class URIish {
if (elements.length == 0) if (elements.length == 0)
throw new IllegalArgumentException(); throw new IllegalArgumentException();
String result = elements[elements.length - 1]; String result = elements[elements.length - 1];
if (DOT_GIT.equals(result)) if (Constants.DOT_GIT.equals(result))
result = elements[elements.length - 2]; result = elements[elements.length - 2];
else if (result.endsWith(DOT_GIT)) else if (result.endsWith(DOT_GIT))
result = result.substring(0, result.length() - DOT_GIT.length()); result = result.substring(0, result.length() - DOT_GIT.length());

5
org.eclipse.jgit/src/org/eclipse/jgit/treewalk/FileTreeIterator.java

@ -1,6 +1,6 @@
/* /*
* Copyright (C) 2008, Google Inc. * Copyright (C) 2008, Google Inc.
* Copyright (C) 2007, Robin Rosenberg <robin.rosenberg@dewire.com> * Copyright (C) 2007-2010, Robin Rosenberg <robin.rosenberg@dewire.com>
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org> * Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
* Copyright (C) 2009, Tor Arne Vestbø <torarnv@gmail.com> * Copyright (C) 2009, Tor Arne Vestbø <torarnv@gmail.com>
* and other copyright owners as documented in the project's IP log. * and other copyright owners as documented in the project's IP log.
@ -52,6 +52,7 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import org.eclipse.jgit.errors.IncorrectObjectTypeException; import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.FileMode; import org.eclipse.jgit.lib.FileMode;
import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.util.FS; import org.eclipse.jgit.util.FS;
@ -124,7 +125,7 @@ public class FileTreeIterator extends WorkingTreeIterator {
file = f; file = f;
if (f.isDirectory()) { if (f.isDirectory()) {
if (new File(f, ".git").isDirectory()) if (new File(f, Constants.DOT_GIT).isDirectory())
mode = FileMode.GITLINK; mode = FileMode.GITLINK;
else else
mode = FileMode.TREE; mode = FileMode.TREE;

2
org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java

@ -336,7 +336,7 @@ public abstract class WorkingTreeIterator extends AbstractTreeIterator {
final String name = e.getName(); final String name = e.getName();
if (".".equals(name) || "..".equals(name)) if (".".equals(name) || "..".equals(name))
continue; continue;
if (".git".equals(name)) if (Constants.DOT_GIT.equals(name))
continue; continue;
if (i != o) if (i != o)
entries[o] = e; entries[o] = e;

Loading…
Cancel
Save