diff options
author | Robin Rosenberg <robin.rosenberg@dewire.com> | 2010-01-14 23:53:11 +0100 |
---|---|---|
committer | Robin Rosenberg <robin.rosenberg@dewire.com> | 2010-01-15 07:17:34 +0100 |
commit | 0b8b6b5309f2510f1a2e1c3d77942fa9470dd324 (patch) | |
tree | b501b146827de359e3c6c5adfee07d8f0f311abb /org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm | |
parent | f5eb0d93660786213b98dadde7d93c5605454495 (diff) | |
download | jgit-0b8b6b5309f2510f1a2e1c3d77942fa9470dd324.tar.gz jgit-0b8b6b5309f2510f1a2e1c3d77942fa9470dd324.zip |
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>
Diffstat (limited to 'org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm')
6 files changed, 16 insertions, 10 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java index 3fe50d6682..10bb357e26 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java @@ -100,7 +100,7 @@ class Clone extends AbstractFetchCommand { } } if (gitdir == null) - gitdir = new File(localName, ".git"); + gitdir = new File(localName, Constants.DOT_GIT); db = new Repository(gitdir); db.create(); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Glog.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Glog.java index c799222f56..caf4f30e3b 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Glog.java +++ b/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> * 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 org.eclipse.jgit.awtui.CommitGraphPane; +import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.revplot.PlotWalk; import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.revwalk.RevSort; @@ -125,7 +127,7 @@ class Glog extends RevWalkTextBuiltin { private String repoName() { final File f = db.getDirectory(); String n = f.getName(); - if (".git".equals(n)) + if (Constants.DOT_GIT.equals(n)) n = f.getParentFile().getName(); return n; } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Init.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Init.java index b6a4a44a9e..a8fe7d8a53 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Init.java +++ b/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) 2008, Google Inc. + * Copyright (C) 2010, Robin Rosenberg <robin.rosenberg@dewire.com> * and other copyright owners as documented in the project's IP log. * * This program and the accompanying materials are made available @@ -47,6 +48,7 @@ package org.eclipse.jgit.pgm; import java.io.File; import org.kohsuke.args4j.Option; +import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.Repository; @Command(common = true, usage = "Create an empty git repository") @@ -62,7 +64,7 @@ class Init extends TextBuiltin { @Override protected void run() throws Exception { if (gitdir == null) - gitdir = new File(bare ? "." : ".git"); + gitdir = new File(bare ? "." : Constants.DOT_GIT); db = new Repository(gitdir); db.create(bare); out.println("Initialized empty Git repository in " diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java index b4c5660a6d..10ebef4637 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java @@ -228,7 +228,7 @@ public class Main { } File current = new File("").getAbsoluteFile(); while (current != null) { - final File gitDir = new File(current, ".git"); + final File gitDir = new File(current, Constants.DOT_GIT); if (gitDir.isDirectory()) return gitDir; current = current.getParentFile(); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ReceivePack.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ReceivePack.java index c6a6fd0cbf..f43a2793ee 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ReceivePack.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ReceivePack.java @@ -1,6 +1,6 @@ /* * 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. * * This program and the accompanying materials are made available @@ -47,6 +47,7 @@ package org.eclipse.jgit.pgm; import java.io.File; import org.kohsuke.args4j.Argument; +import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.Repository; @Command(common = false, usage = "Server side backend for 'jgit push'") @@ -63,8 +64,8 @@ class ReceivePack extends TextBuiltin { protected void run() throws Exception { final org.eclipse.jgit.transport.ReceivePack rp; - if (new File(dstGitdir, ".git").isDirectory()) - dstGitdir = new File(dstGitdir, ".git"); + if (new File(dstGitdir, Constants.DOT_GIT).isDirectory()) + dstGitdir = new File(dstGitdir, Constants.DOT_GIT); db = new Repository(dstGitdir); if (!db.getObjectsDirectory().isDirectory()) throw die("'" + dstGitdir.getPath() + "' not a git repository"); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java index 85dbbc5d9c..ea30899dcb 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java @@ -1,6 +1,6 @@ /* * 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. * * 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.Option; +import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.Repository; @Command(common = false, usage = "Server side backend for 'jgit fetch'") @@ -67,8 +68,8 @@ class UploadPack extends TextBuiltin { protected void run() throws Exception { final org.eclipse.jgit.transport.UploadPack rp; - if (new File(srcGitdir, ".git").isDirectory()) - srcGitdir = new File(srcGitdir, ".git"); + if (new File(srcGitdir, Constants.DOT_GIT).isDirectory()) + srcGitdir = new File(srcGitdir, Constants.DOT_GIT); db = new Repository(srcGitdir); if (!db.getObjectsDirectory().isDirectory()) throw die("'" + srcGitdir.getPath() + "' not a git repository"); |