* [PATCH v2 1/2] git-archive: add '-o' as a alias for '--output'
From: Dmitry Potapov @ 2009-09-13 20:13 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, John Tapsell
In-Reply-To: <7v4or6sngc.fsf@alter.siamese.dyndns.org>
The '-o' option is commonly used in many tools to specify the output file.
Typing '--output' every time is a bit too long to be a practical alternative
to redirecting output. But specifying the output name has the advantage of
making possible to guess the desired output format by filename extension.
Signed-off-by: Dmitry Potapov <dpotapov@gmail.com>
---
On Sun, Sep 13, 2009 at 11:34:43AM -0700, Junio C Hamano wrote:
> I think this patch is very reasonable, except for this hunk, which would
> want to say "-o <file>::" instead.
Corrected.
Documentation/git-archive.txt | 3 ++-
archive.c | 2 +-
builtin-archive.c | 2 +-
3 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/Documentation/git-archive.txt b/Documentation/git-archive.txt
index 92444dd..1917f2e 100644
--- a/Documentation/git-archive.txt
+++ b/Documentation/git-archive.txt
@@ -10,7 +10,7 @@ SYNOPSIS
--------
[verse]
'git archive' [--format=<fmt>] [--list] [--prefix=<prefix>/] [<extra>]
- [--output=<file>] [--worktree-attributes]
+ [-o | --output=<file>] [--worktree-attributes]
[--remote=<repo> [--exec=<git-upload-archive>]] <tree-ish>
[path...]
@@ -48,6 +48,7 @@ OPTIONS
--prefix=<prefix>/::
Prepend <prefix>/ to each filename in the archive.
+-o <file>::
--output=<file>::
Write the archive to <file> instead of stdout.
diff --git a/archive.c b/archive.c
index 0bca9ca..73b8e8a 100644
--- a/archive.c
+++ b/archive.c
@@ -283,7 +283,7 @@ static int parse_archive_args(int argc, const char **argv,
OPT_STRING(0, "format", &format, "fmt", "archive format"),
OPT_STRING(0, "prefix", &base, "prefix",
"prepend prefix to each pathname in the archive"),
- OPT_STRING(0, "output", &output, "file",
+ OPT_STRING('o', "output", &output, "file",
"write the archive to this file"),
OPT_BOOLEAN(0, "worktree-attributes", &worktree_attributes,
"read .gitattributes in working directory"),
diff --git a/builtin-archive.c b/builtin-archive.c
index f9a4bea..565314b 100644
--- a/builtin-archive.c
+++ b/builtin-archive.c
@@ -71,7 +71,7 @@ int cmd_archive(int argc, const char **argv, const char *prefix)
const char *output = NULL;
const char *remote = NULL;
struct option local_opts[] = {
- OPT_STRING(0, "output", &output, "file",
+ OPT_STRING('o', "output", &output, "file",
"write the archive to this file"),
OPT_STRING(0, "remote", &remote, "repo",
"retrieve the archive from remote repository <repo>"),
--
1.6.5.rc1.2.g6bb993
^ permalink raw reply related
* Re: [PATCH] git-commit: Only describe --dry-run once
From: Johannes Gilger @ 2009-09-13 19:25 UTC (permalink / raw)
To: Git Mailing List; +Cc: Junio C Hamano
In-Reply-To: <7vocper80j.fsf@alter.siamese.dyndns.org>
On 13/09/09 11:53, Junio C Hamano wrote:
> I think it is a better option just to revert that commit except for the
> second hunk that makes it stop talking about "git status", like this.
Woops, didn't realize you also duplicated the long description. I
promise to be more thorough next time ;)
Greetings,
Jojo
--
Johannes Gilger <heipei@hackvalue.de>
http://heipei.net
GPG-Key: 0x42F6DE81
GPG-Fingerprint: BB49 F967 775E BB52 3A81 882C 58EE B178 42F6 DE81
^ permalink raw reply
* Re: [PATCH] git-commit: Only describe --dry-run once
From: Junio C Hamano @ 2009-09-13 18:53 UTC (permalink / raw)
To: Johannes Gilger; +Cc: Git Mailing List
In-Reply-To: <1252848905-19115-1-git-send-email-heipei@hackvalue.de>
Johannes Gilger <heipei@hackvalue.de> writes:
> Junio described the option in 3a5d13a and then again in 60c2993.
Thanks.
I must have been too tired to think straight when I did 60c2993.
I think it is a better option just to revert that commit except for the
second hunk that makes it stop talking about "git status", like this.
I'd apply your typofix as a separate patch.
Thanks.
Documentation/git-commit.txt | 8 +-------
1 files changed, 1 insertions(+), 7 deletions(-)
diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
index 64f94cf..0578a40 100644
--- a/Documentation/git-commit.txt
+++ b/Documentation/git-commit.txt
@@ -9,7 +9,7 @@ SYNOPSIS
--------
[verse]
'git commit' [-a | --interactive] [-s] [-v] [-u<mode>] [--amend] [--dry-run]
- [(-c | -C) <commit>] [-F <file> | -m <msg>] [--dry-run]
+ [(-c | -C) <commit>] [-F <file> | -m <msg>]
[--allow-empty] [--no-verify] [-e] [--author=<author>]
[--cleanup=<mode>] [--] [[-i | -o ]<file>...]
@@ -69,12 +69,6 @@ OPTIONS
Like '-C', but with '-c' the editor is invoked, so that
the user can further edit the commit message.
---dry-run::
- Do not actually make a commit, but show the list of paths
- with updates in the index, paths with changes in the work tree,
- and paths that are untracked, similar to the one that is given
- in the commit log editor.
-
-F <file>::
--file=<file>::
Take the commit message from the given file. Use '-' to
^ permalink raw reply related
* [PATCH JGit 15/19] Adding in a InfoDatabase like ObjectDatabase and and implementation based upon a directory.
From: mr.gaffo @ 2009-09-13 18:44 UTC (permalink / raw)
To: git; +Cc: mike.gaffney
In-Reply-To: <1252867475-858-15-git-send-email-mr.gaffo@gmail.com>
From: mike.gaffney <mike.gaffney@asolutions.com>
Currently only creates itself.
---
.../jgit/lib/InfoDirectoryDatabaseTest.java | 30 ++++++++++++++++++++
.../src/org/spearce/jgit/lib/InfoDatabase.java | 8 +++++
.../spearce/jgit/lib/InfoDirectoryDatabase.java | 18 ++++++++++++
.../src/org/spearce/jgit/lib/Repository.java | 11 +++++++
.../org/spearce/jgit/transport/ReceivePack.java | 1 +
5 files changed, 68 insertions(+), 0 deletions(-)
create mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/lib/InfoDirectoryDatabaseTest.java
create mode 100644 org.spearce.jgit/src/org/spearce/jgit/lib/InfoDatabase.java
create mode 100644 org.spearce.jgit/src/org/spearce/jgit/lib/InfoDirectoryDatabase.java
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/InfoDirectoryDatabaseTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/InfoDirectoryDatabaseTest.java
new file mode 100644
index 0000000..2b7fb5b
--- /dev/null
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/InfoDirectoryDatabaseTest.java
@@ -0,0 +1,30 @@
+package org.spearce.jgit.lib;
+
+import java.io.File;
+
+import org.spearce.jgit.util.JGitTestUtil;
+
+import junit.framework.TestCase;
+
+public class InfoDirectoryDatabaseTest extends TestCase {
+
+ private File testDir;
+
+ @Override
+ protected void setUp() throws Exception {
+ testDir = JGitTestUtil.generateTempDirectoryFileObject();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ if (testDir.exists()){
+ JGitTestUtil.deleteDir(testDir);
+ }
+ }
+
+ public void testCreateCreatesDirectory() throws Exception {
+ assertFalse(testDir.exists());
+ new InfoDirectoryDatabase(testDir).create();
+ assertTrue(testDir.exists());
+ }
+}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDatabase.java b/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDatabase.java
new file mode 100644
index 0000000..2f1f398
--- /dev/null
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDatabase.java
@@ -0,0 +1,8 @@
+package org.spearce.jgit.lib;
+
+public abstract class InfoDatabase {
+
+ public void create() {
+ }
+
+}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDirectoryDatabase.java b/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDirectoryDatabase.java
new file mode 100644
index 0000000..20d8a70
--- /dev/null
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDirectoryDatabase.java
@@ -0,0 +1,18 @@
+package org.spearce.jgit.lib;
+
+import java.io.File;
+
+public class InfoDirectoryDatabase extends InfoDatabase {
+
+ private File info;
+
+ public InfoDirectoryDatabase(final File directory) {
+ info = directory;
+ }
+
+ @Override
+ public void create() {
+ info.mkdirs();
+ }
+
+}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
index 46b7804..f658b5c 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
@@ -97,6 +97,8 @@
private final RefDatabase refs;
private final ObjectDirectory objectDatabase;
+
+ private final InfoDatabase infoDatabase;
private GitIndex index;
@@ -116,6 +118,7 @@ public Repository(final File d) throws IOException {
gitDir = d.getAbsoluteFile();
refs = new RefDatabase(this);
objectDatabase = new ObjectDirectory(FS.resolve(gitDir, "objects"));
+ infoDatabase = new InfoDirectoryDatabase(FS.resolve(gitDir, "info"));
final FileBasedConfig userConfig;
userConfig = SystemReader.getInstance().openUserConfig();
@@ -177,6 +180,7 @@ public void create(boolean bare) throws IOException {
gitDir.mkdirs();
refs.create();
objectDatabase.create();
+ infoDatabase.create();
new File(gitDir, "branches").mkdir();
new File(gitDir, "remotes").mkdir();
@@ -210,6 +214,13 @@ public File getObjectsDirectory() {
public ObjectDatabase getObjectDatabase() {
return objectDatabase;
}
+
+ /**
+ * @return the info database which stores this repository's info
+ */
+ public InfoDatabase getInfoDatabase() {
+ return infoDatabase;
+ }
/**
* @return the configuration of this repository
diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java b/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java
index 5865736..baa1dec 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java
@@ -62,6 +62,7 @@
import org.spearce.jgit.lib.PersonIdent;
import org.spearce.jgit.lib.Ref;
import org.spearce.jgit.lib.RefUpdate;
+import org.spearce.jgit.lib.RefWriter;
import org.spearce.jgit.lib.Repository;
import org.spearce.jgit.lib.Config.SectionParser;
import org.spearce.jgit.revwalk.ObjectWalk;
--
1.6.4.2
^ permalink raw reply related
* Re: [PATCH 2/2] teach git-archive to auto detect the output format
From: Junio C Hamano @ 2009-09-13 18:52 UTC (permalink / raw)
To: Dmitry Potapov; +Cc: git, John Tapsell
In-Reply-To: <1252863407-2598-2-git-send-email-dpotapov@gmail.com>
Dmitry Potapov <dpotapov@gmail.com> writes:
> diff --git a/Documentation/git-archive.txt b/Documentation/git-archive.txt
> index f7a3b95..c6fb21c 100644
> --- a/Documentation/git-archive.txt
> +++ b/Documentation/git-archive.txt
> @@ -35,7 +35,9 @@ OPTIONS
>
> --format=<fmt>::
> Format of the resulting archive: 'tar' or 'zip'. The default
> - is 'tar'.
> + is 'tar', unless the output file is specified, and it has a known
> + extension (such as '.zip') then the default for the output format
> + will be determined by this extension.
Once it is _determined_, then it is not the default anymore.
If this option is not given, and the output file is specified, the
format is inferred from the filename if possible (e.g. writing to
"foo.zip" makes the output to be in the zip format). Otherwise
the output format is `tar`.
> @@ -130,6 +132,12 @@ git archive --format=zip
> Put everything in the current head's Documentation/ directory
> into 'git-1.4.0-docs.zip', with the prefix 'git-docs/'.
>
> +git archive -o latest.zip HEAD::
> +
> + Create a Zip archive that contains the contents of the latest
> + commit on the current branch. Note that the output format is
> + specified implicitly by the extension of the output file.
> +
Perhaps "s/specified implicitly/inferred/" but that is a minor point.
> diff --git a/builtin-archive.c b/builtin-archive.c
> index 565314b..878c6b2 100644
> --- a/builtin-archive.c
> +++ b/builtin-archive.c
> @@ -77,14 +89,27 @@ int cmd_archive(int argc, const char **argv, const char *prefix)
> "retrieve the archive from remote repository <repo>"),
> OPT_STRING(0, "exec", &exec, "cmd",
> "path to the remote git-upload-archive command"),
> + OPT_STRING(0, "format", &format, "fmt", "archive format"),
> OPT_END()
> };
> + char fmt_opt[32];
>
> argc = parse_options(argc, argv, prefix, local_opts, NULL,
> PARSE_OPT_KEEP_ALL);
>
> if (output)
> + {
On the same line, i.e. "if (output) {".
> create_output_file(output);
> + if (!format)
> + format = format_from_name(output);
> + }
> +
> + if (format)
> + {
On the same line, i.e. "if (format) {".
> + sprintf(fmt_opt, "--format=%s", format);
> + argv[argc++] = fmt_opt;
> + argv[argc] = NULL;
Did you make sure you are allowed to write into argv[] and the array is
large enough? You probably need to make a copy of the array.
Otherwise, the idea feels sound.
^ permalink raw reply
* [PATCH JGit 11/19] removed unused import
From: mr.gaffo @ 2009-09-13 18:44 UTC (permalink / raw)
To: git; +Cc: mike.gaffney
In-Reply-To: <1252867475-858-11-git-send-email-mr.gaffo@gmail.com>
From: mike.gaffney <mike.gaffney@asolutions.com>
---
.../lib/UpdateDirectoryBasedPacksInfoCache.java | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryBasedPacksInfoCache.java b/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryBasedPacksInfoCache.java
index 3e24cd2..e4caa43 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryBasedPacksInfoCache.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryBasedPacksInfoCache.java
@@ -1,6 +1,5 @@
package org.spearce.jgit.lib;
-import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
--
1.6.4.2
^ permalink raw reply related
* [PATCH JGit 09/19] Didn't like the old name, this is more specific to it just updating the packs info cache
From: mr.gaffo @ 2009-09-13 18:44 UTC (permalink / raw)
To: git; +Cc: mike.gaffney
In-Reply-To: <1252867475-858-9-git-send-email-mr.gaffo@gmail.com>
From: mike.gaffney <mike.gaffney@asolutions.com>
---
.../UpdateDirectoryBasedPacksInfoCacheTest.java | 30 ++++++++++++++++++++
.../jgit/lib/UpdateDirectoryInfoCacheTest.java | 30 --------------------
.../src/org/spearce/jgit/lib/ObjectDirectory.java | 2 +-
.../lib/UpdateDirectoryBasedPacksInfoCache.java | 27 ++++++++++++++++++
.../spearce/jgit/lib/UpdateDirectoryInfoCache.java | 27 ------------------
5 files changed, 58 insertions(+), 58 deletions(-)
create mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryBasedPacksInfoCacheTest.java
delete mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryInfoCacheTest.java
create mode 100644 org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryBasedPacksInfoCache.java
delete mode 100644 org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryInfoCache.java
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryBasedPacksInfoCacheTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryBasedPacksInfoCacheTest.java
new file mode 100644
index 0000000..f5163e4
--- /dev/null
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryBasedPacksInfoCacheTest.java
@@ -0,0 +1,30 @@
+package org.spearce.jgit.lib;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.spearce.jgit.util.JGitTestUtil;
+
+public class UpdateDirectoryBasedPacksInfoCacheTest extends TestCase {
+ private static final String PACK_NAME = "pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f";
+ private static final File TEST_PACK = JGitTestUtil.getTestResourceFile(PACK_NAME + ".pack");
+ private static final File TEST_IDX = JGitTestUtil.getTestResourceFile(PACK_NAME + ".idx");
+
+ public void testCreatesTheFileAndPutsTheContentsIn() throws Exception {
+ List<PackFile> packs = new ArrayList<PackFile>();
+ packs.add(new PackFile(TEST_IDX, TEST_PACK));
+
+ File packsFile = File.createTempFile(UpdateDirectoryBasedPacksInfoCacheTest.class.getSimpleName(), "tstdata");
+ packsFile.deleteOnExit();
+
+ String expectedContents = new PacksFileContentsCreator(packs).toString();
+
+ new UpdateDirectoryBasedPacksInfoCache(packs, packsFile).execute();
+
+ assertEquals(expectedContents, JGitTestUtil.readFileAsString(packsFile));
+ }
+
+}
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryInfoCacheTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryInfoCacheTest.java
deleted file mode 100644
index 25b78c5..0000000
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryInfoCacheTest.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package org.spearce.jgit.lib;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.spearce.jgit.util.JGitTestUtil;
-
-public class UpdateDirectoryInfoCacheTest extends TestCase {
- private static final String PACK_NAME = "pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f";
- private static final File TEST_PACK = JGitTestUtil.getTestResourceFile(PACK_NAME + ".pack");
- private static final File TEST_IDX = JGitTestUtil.getTestResourceFile(PACK_NAME + ".idx");
-
- public void testCreatesTheFileAndPutsTheContentsIn() throws Exception {
- List<PackFile> packs = new ArrayList<PackFile>();
- packs.add(new PackFile(TEST_IDX, TEST_PACK));
-
- File packsFile = File.createTempFile(UpdateDirectoryInfoCacheTest.class.getSimpleName(), "tstdata");
- packsFile.deleteOnExit();
-
- String expectedContents = new PacksFileContentsCreator(packs).toString();
-
- new UpdateDirectoryInfoCache(packs, packsFile).execute();
-
- assertEquals(expectedContents, JGitTestUtil.readFileAsString(packsFile));
- }
-
-}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java
index 95618b9..71536c9 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java
@@ -517,6 +517,6 @@ boolean tryAgain(final long currLastModified) {
@Override
public void updateInfoCache() throws IOException {
- new UpdateDirectoryInfoCache(this.listLocalPacks(), new File(this.infoDirectory, "packs")).execute();
+ new UpdateDirectoryBasedPacksInfoCache(this.listLocalPacks(), new File(this.infoDirectory, "packs")).execute();
}
}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryBasedPacksInfoCache.java b/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryBasedPacksInfoCache.java
new file mode 100644
index 0000000..3e24cd2
--- /dev/null
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryBasedPacksInfoCache.java
@@ -0,0 +1,27 @@
+package org.spearce.jgit.lib;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.List;
+
+public class UpdateDirectoryBasedPacksInfoCache {
+
+ private List<PackFile> packsList;
+ private File infoPacksFile;
+
+ public UpdateDirectoryBasedPacksInfoCache(List<PackFile> packsList,
+ File infoPacksFile) {
+ this.packsList = packsList;
+ this.infoPacksFile = infoPacksFile;
+ }
+
+ public void execute() throws IOException {
+ String packsContents = new PacksFileContentsCreator(packsList).toString();
+ FileOutputStream fos = new FileOutputStream(infoPacksFile);
+ fos.write(packsContents.getBytes());
+ fos.close();
+ }
+
+}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryInfoCache.java b/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryInfoCache.java
deleted file mode 100644
index 72a315a..0000000
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryInfoCache.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package org.spearce.jgit.lib;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.List;
-
-public class UpdateDirectoryInfoCache {
-
- private List<PackFile> packsList;
- private File infoPacksFile;
-
- public UpdateDirectoryInfoCache(List<PackFile> packsList,
- File infoPacksFile) {
- this.packsList = packsList;
- this.infoPacksFile = infoPacksFile;
- }
-
- public void execute() throws IOException {
- String packsContents = new PacksFileContentsCreator(packsList).toString();
- FileOutputStream fos = new FileOutputStream(infoPacksFile);
- fos.write(packsContents.getBytes());
- fos.close();
- }
-
-}
--
1.6.4.2
^ permalink raw reply related
* [PATCH JGit 02/19] Create abstract method on ObjectDatabase for accessing the list of local pack files.
From: mr.gaffo @ 2009-09-13 18:44 UTC (permalink / raw)
To: git; +Cc: mike.gaffney
In-Reply-To: <1252867475-858-2-git-send-email-mr.gaffo@gmail.com>
From: mike.gaffney <mike.gaffney@asolutions.com>
Implemented the method for AlternateRepository database as a passthrough
Implemented the method for ObjectDirectory as a toList of the current
cached private PackList.
Hopefully this will allow easier reference to the list of packs for
others like the server side of fetch.
---
.../jgit/lib/AlternateRepositoryDatabase.java | 6 ++++++
.../src/org/spearce/jgit/lib/ObjectDatabase.java | 11 ++++++++++-
.../src/org/spearce/jgit/lib/ObjectDirectory.java | 5 +++++
3 files changed, 21 insertions(+), 1 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/AlternateRepositoryDatabase.java b/org.spearce.jgit/src/org/spearce/jgit/lib/AlternateRepositoryDatabase.java
index ee4c4cf..68ad488 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/AlternateRepositoryDatabase.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/AlternateRepositoryDatabase.java
@@ -39,6 +39,7 @@
import java.io.IOException;
import java.util.Collection;
+import java.util.List;
/**
* An ObjectDatabase of another {@link Repository}.
@@ -124,4 +125,9 @@ void openObjectInAllPacks1(final Collection<PackedObjectLoader> out,
protected void closeAlternates(final ObjectDatabase[] alt) {
// Do nothing; these belong to odb to close, not us.
}
+
+ @Override
+ public List<PackFile> listLocalPacks() {
+ return odb.listLocalPacks();
+ }
}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDatabase.java b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDatabase.java
index a547052..722c802 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDatabase.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDatabase.java
@@ -39,6 +39,7 @@
import java.io.IOException;
import java.util.Collection;
+import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
/**
@@ -64,7 +65,15 @@
protected ObjectDatabase() {
alternates = new AtomicReference<ObjectDatabase[]>();
}
-
+
+ /**
+ * The list of Packs THIS repo contains
+ *
+ * @return List<PackFile> of package names contained in this repo.
+ * Should be an empty list if there are none.
+ */
+ public abstract List<PackFile> listLocalPacks();
+
/**
* Does this database exist yet?
*
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java
index 859824d..fe219c6 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java
@@ -508,4 +508,9 @@ boolean tryAgain(final long currLastModified) {
return true;
}
}
+
+ @Override
+ public List<PackFile> listLocalPacks() {
+ return new ArrayList<PackFile>(Arrays.asList(packList.get().packs));
+ }
}
--
1.6.4.2
^ permalink raw reply related
* [PATCH JGit 18/19] Added Copyright Notices
From: mr.gaffo @ 2009-09-13 18:44 UTC (permalink / raw)
To: git; +Cc: mike.gaffney
In-Reply-To: <1252867475-858-18-git-send-email-mr.gaffo@gmail.com>
From: mike.gaffney <mike.gaffney@asolutions.com>
---
.../jgit/lib/InfoDirectoryDatabaseTest.java | 36 +++++++++++++++++
.../org/spearce/jgit/lib/ObjectDirectoryTest.java | 41 ++++++++++++++++++-
.../jgit/lib/PacksFileContentsCreatorTest.java | 36 +++++++++++++++++
.../src/org/spearce/jgit/lib/InfoDatabase.java | 36 +++++++++++++++++
.../spearce/jgit/lib/InfoDirectoryDatabase.java | 36 +++++++++++++++++
.../spearce/jgit/lib/PacksFileContentsCreator.java | 36 +++++++++++++++++
.../lib/UpdateDirectoryBasedPacksInfoCache.java | 36 +++++++++++++++++
7 files changed, 254 insertions(+), 3 deletions(-)
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/InfoDirectoryDatabaseTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/InfoDirectoryDatabaseTest.java
index 22972fa..3aa0fd6 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/InfoDirectoryDatabaseTest.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/InfoDirectoryDatabaseTest.java
@@ -1,3 +1,39 @@
+/*
+ * Copyright (C) 2009, Mike Gaffney.
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the Git Development Community nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
package org.spearce.jgit.lib;
import java.io.File;
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java
index 4fecce7..e14db75 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java
@@ -1,14 +1,49 @@
+/*
+ * Copyright (C) 2009, Mike Gaffney.
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the Git Development Community nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
package org.spearce.jgit.lib;
import java.io.File;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.List;
-import org.spearce.jgit.util.JGitTestUtil;
-
import junit.framework.TestCase;
+import org.spearce.jgit.util.JGitTestUtil;
+
public class ObjectDirectoryTest extends TestCase {
private static final String PACK_NAME = "pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f";
private static final File TEST_PACK = JGitTestUtil.getTestResourceFile(PACK_NAME + ".pack");
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PacksFileContentsCreatorTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PacksFileContentsCreatorTest.java
index ef28a26..8dc9109 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PacksFileContentsCreatorTest.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PacksFileContentsCreatorTest.java
@@ -1,3 +1,39 @@
+/*
+ * Copyright (C) 2009, Mike Gaffney.
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the Git Development Community nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
package org.spearce.jgit.lib;
import java.io.File;
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDatabase.java b/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDatabase.java
index 26f8f22..96a39fc 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDatabase.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDatabase.java
@@ -1,3 +1,39 @@
+/*
+ * Copyright (C) 2009, Mike Gaffney.
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the Git Development Community nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
package org.spearce.jgit.lib;
import java.io.IOException;
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDirectoryDatabase.java b/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDirectoryDatabase.java
index f95be2f..48f60d1 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDirectoryDatabase.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDirectoryDatabase.java
@@ -1,3 +1,39 @@
+/*
+ * Copyright (C) 2009, Mike Gaffney.
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the Git Development Community nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
package org.spearce.jgit.lib;
import java.io.File;
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/PacksFileContentsCreator.java b/org.spearce.jgit/src/org/spearce/jgit/lib/PacksFileContentsCreator.java
index 3dd0418..0efc244 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/PacksFileContentsCreator.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/PacksFileContentsCreator.java
@@ -1,3 +1,39 @@
+/*
+ * Copyright (C) 2009, Mike Gaffney.
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the Git Development Community nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
package org.spearce.jgit.lib;
import java.util.List;
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryBasedPacksInfoCache.java b/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryBasedPacksInfoCache.java
index e4caa43..af61069 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryBasedPacksInfoCache.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryBasedPacksInfoCache.java
@@ -1,3 +1,39 @@
+/*
+ * Copyright (C) 2009, Mike Gaffney.
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the Git Development Community nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
package org.spearce.jgit.lib;
import java.io.File;
--
1.6.4.2
^ permalink raw reply related
* [PATCH JGit 12/19] moved info/packs into a constant
From: mr.gaffo @ 2009-09-13 18:44 UTC (permalink / raw)
To: git; +Cc: mike.gaffney
In-Reply-To: <1252867475-858-12-git-send-email-mr.gaffo@gmail.com>
From: mike.gaffney <mike.gaffney@asolutions.com>
---
.../org/spearce/jgit/lib/ObjectDirectoryTest.java | 5 ++---
.../src/org/spearce/jgit/lib/Constants.java | 3 +++
.../src/org/spearce/jgit/lib/ObjectDirectory.java | 2 +-
3 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java
index 4ac62fa..b27f2f8 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java
@@ -79,7 +79,7 @@ public void testListLocalPacksWhenThereIsAPack() throws Exception {
assertEquals(TEST_PACK.getName(), localPacks.get(0).getPackFile().getName());
}
- public void testUpdateInfoCacheCreatesPacksFile() throws Exception {
+ public void testUpdateInfoCacheCreatesPacksAndRefsFile() throws Exception {
createSamplePacksDir();
ObjectDirectory od = new ObjectDirectory(testDir);
@@ -87,7 +87,7 @@ public void testUpdateInfoCacheCreatesPacksFile() throws Exception {
od.updateInfoCache();
String expectedContents = new PacksFileContentsCreator(od.listLocalPacks()).toString();
- File packsFile = new File(od.getDirectory(), "info/packs");
+ File packsFile = new File(od.getDirectory(), Constants.CACHED_PACKS_FILE);
assertTrue(packsFile.exists());
assertEquals(expectedContents, JGitTestUtil.readFileAsString(packsFile));
@@ -103,7 +103,6 @@ public boolean deleteDir(File dir) {
}
}
}
-
// The directory is now empty so delete it
return dir.delete();
}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/Constants.java b/org.spearce.jgit/src/org/spearce/jgit/lib/Constants.java
index 9afea67..2d78dda 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/Constants.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Constants.java
@@ -224,6 +224,9 @@
/** Info refs folder */
public static final String INFO_REFS = "info/refs";
+
+ /** cached packs file */
+ public static final String CACHED_PACKS_FILE = "info/packs";
/** Packed refs file */
public static final String PACKED_REFS = "packed-refs";
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java
index 71536c9..f4251c1 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java
@@ -517,6 +517,6 @@ boolean tryAgain(final long currLastModified) {
@Override
public void updateInfoCache() throws IOException {
- new UpdateDirectoryBasedPacksInfoCache(this.listLocalPacks(), new File(this.infoDirectory, "packs")).execute();
+ new UpdateDirectoryBasedPacksInfoCache(this.listLocalPacks(), new File(this.getDirectory(), Constants.CACHED_PACKS_FILE)).execute();
}
}
--
1.6.4.2
^ permalink raw reply related
* [PATCH JGit 13/19] made the call update the object database's info cache
From: mr.gaffo @ 2009-09-13 18:44 UTC (permalink / raw)
To: git; +Cc: mike.gaffney
In-Reply-To: <1252867475-858-13-git-send-email-mr.gaffo@gmail.com>
From: mike.gaffney <mike.gaffney@asolutions.com>
---
.../org/spearce/jgit/transport/ReceivePack.java | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java b/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java
index eb21254..5865736 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java
@@ -521,6 +521,16 @@ void sendString(final String s) throws IOException {
}
postReceive.onPostReceive(this, filterCommands(Result.OK));
+ updateObjectInfoCache();
+ }
+ }
+
+ private void updateObjectInfoCache() {
+ try{
+ getRepository().getObjectDatabase().updateInfoCache();
+ }
+ catch (IOException e){
+ sendMessage("error updating server info: " + e.getMessage());
}
}
--
1.6.4.2
^ permalink raw reply related
* [PATCH JGit 16/19] added tests for the file based info cache update and made pass
From: mr.gaffo @ 2009-09-13 18:44 UTC (permalink / raw)
To: git; +Cc: mike.gaffney
In-Reply-To: <1252867475-858-16-git-send-email-mr.gaffo@gmail.com>
From: mike.gaffney <mike.gaffney@asolutions.com>
---
.../jgit/lib/InfoDirectoryDatabaseTest.java | 30 ++++++++++++++++++++
.../src/org/spearce/jgit/lib/InfoDatabase.java | 15 ++++++++++
.../spearce/jgit/lib/InfoDirectoryDatabase.java | 15 ++++++++++
3 files changed, 60 insertions(+), 0 deletions(-)
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/InfoDirectoryDatabaseTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/InfoDirectoryDatabaseTest.java
index 2b7fb5b..22972fa 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/InfoDirectoryDatabaseTest.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/InfoDirectoryDatabaseTest.java
@@ -1,6 +1,10 @@
package org.spearce.jgit.lib;
import java.io.File;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Collection;
import org.spearce.jgit.util.JGitTestUtil;
@@ -27,4 +31,30 @@ public void testCreateCreatesDirectory() throws Exception {
new InfoDirectoryDatabase(testDir).create();
assertTrue(testDir.exists());
}
+
+ public void testUpdateInfoCache() throws Exception {
+ Collection<Ref> refs = new ArrayList<Ref>();
+ refs.add(new Ref(Ref.Storage.LOOSE, "refs/heads/master", ObjectId.fromString("32aae7aef7a412d62192f710f2130302997ec883")));
+ refs.add(new Ref(Ref.Storage.LOOSE, "refs/heads/development", ObjectId.fromString("184063c9b594f8968d61a686b2f6052779551613")));
+
+ File expectedFile = new File(testDir, "refs");
+ assertFalse(expectedFile.exists());
+
+
+ final StringWriter expectedString = new StringWriter();
+ new RefWriter(refs) {
+ @Override
+ protected void writeFile(String file, byte[] content) throws IOException {
+ expectedString.write(new String(content));
+ }
+ }.writeInfoRefs();
+
+ InfoDirectoryDatabase out = new InfoDirectoryDatabase(testDir);
+ out.create();
+ out.updateInfoCache(refs);
+ assertTrue(expectedFile.exists());
+
+ String actual = JGitTestUtil.readFileAsString(expectedFile);
+ assertEquals(expectedString.toString(), actual);
+ }
}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDatabase.java b/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDatabase.java
index 2f1f398..26f8f22 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDatabase.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDatabase.java
@@ -1,8 +1,23 @@
package org.spearce.jgit.lib;
+import java.io.IOException;
+import java.util.Collection;
+
public abstract class InfoDatabase {
+ /**
+ * Create the info database
+ */
public void create() {
}
+ /**
+ * Updates the info cache typically done by update-server-info command.
+ * This writes THIS repository's refs out to the info/refs file.
+ * @param collection the collections of refs to update the info cache with
+ * @throws IOException for any type of failure on the local or remote
+ * data store
+ */
+ public abstract void updateInfoCache(Collection<Ref> collection) throws IOException;
+
}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDirectoryDatabase.java b/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDirectoryDatabase.java
index 20d8a70..f95be2f 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDirectoryDatabase.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDirectoryDatabase.java
@@ -1,6 +1,9 @@
package org.spearce.jgit.lib;
import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Collection;
public class InfoDirectoryDatabase extends InfoDatabase {
@@ -15,4 +18,16 @@ public void create() {
info.mkdirs();
}
+ @Override
+ public void updateInfoCache(Collection<Ref> refs) throws IOException {
+ new RefWriter(refs) {
+ @Override
+ protected void writeFile(String file, byte[] content) throws IOException {
+ FileOutputStream fos = new FileOutputStream(new File(info, "refs"));
+ fos.write(content);
+ fos.close();
+ }
+ }.writeInfoRefs();
+ }
+
}
--
1.6.4.2
^ permalink raw reply related
* [PATCH JGit 19/19] changed \r to \n per compliance with real git
From: mr.gaffo @ 2009-09-13 18:44 UTC (permalink / raw)
To: git; +Cc: mike.gaffney
In-Reply-To: <1252867475-858-19-git-send-email-mr.gaffo@gmail.com>
From: mike.gaffney <mike.gaffney@asolutions.com>
---
.../jgit/lib/PacksFileContentsCreatorTest.java | 9 +++++----
.../spearce/jgit/lib/PacksFileContentsCreator.java | 3 ++-
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PacksFileContentsCreatorTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PacksFileContentsCreatorTest.java
index 8dc9109..bf61a59 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PacksFileContentsCreatorTest.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PacksFileContentsCreatorTest.java
@@ -53,7 +53,7 @@ public void testGettingPacksContentsSinglePack() throws Exception {
List<PackFile> packs = new ArrayList<PackFile>();
packs.add(new PackFile(TEST_IDX, TEST_PACK));
- assertEquals("P " + TEST_PACK.getName() + '\r', new PacksFileContentsCreator(packs).toString());
+ assertEquals("P " + TEST_PACK.getName() + "\n\n", new PacksFileContentsCreator(packs).toString());
}
public void testGettingPacksContentsMultiplePacks() throws Exception {
@@ -63,9 +63,10 @@ public void testGettingPacksContentsMultiplePacks() throws Exception {
packs.add(new PackFile(TEST_IDX, TEST_PACK));
StringBuilder expected = new StringBuilder();
- expected.append("P ").append(TEST_PACK.getName()).append("\r");
- expected.append("P ").append(TEST_PACK.getName()).append("\r");
- expected.append("P ").append(TEST_PACK.getName()).append("\r");
+ expected.append("P ").append(TEST_PACK.getName()).append('\n');
+ expected.append("P ").append(TEST_PACK.getName()).append('\n');
+ expected.append("P ").append(TEST_PACK.getName()).append('\n');
+ expected.append('\n');
assertEquals(expected.toString(), new PacksFileContentsCreator(packs).toString());
}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/PacksFileContentsCreator.java b/org.spearce.jgit/src/org/spearce/jgit/lib/PacksFileContentsCreator.java
index 0efc244..e8b90a2 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/PacksFileContentsCreator.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/PacksFileContentsCreator.java
@@ -49,8 +49,9 @@ public PacksFileContentsCreator(List<PackFile> packs) {
public String toString(){
StringBuilder builder = new StringBuilder();
for (PackFile packFile : packs) {
- builder.append("P ").append(packFile.getPackFile().getName()).append('\r');
+ builder.append("P ").append(packFile.getPackFile().getName()).append('\n');
}
+ builder.append('\n');
return builder.toString();
}
--
1.6.4.2
^ permalink raw reply related
* [PATCH JGit 14/19] pulled out some helper functions that will be useful for other tests
From: mr.gaffo @ 2009-09-13 18:44 UTC (permalink / raw)
To: git; +Cc: mike.gaffney
In-Reply-To: <1252867475-858-14-git-send-email-mr.gaffo@gmail.com>
From: mike.gaffney <mike.gaffney@asolutions.com>
---
.../org/spearce/jgit/lib/ObjectDirectoryTest.java | 21 ++-----------------
.../tst/org/spearce/jgit/util/JGitTestUtil.java | 20 ++++++++++++++++++-
2 files changed, 22 insertions(+), 19 deletions(-)
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java
index b27f2f8..4fecce7 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java
@@ -4,7 +4,6 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-import java.util.UUID;
import org.spearce.jgit.util.JGitTestUtil;
@@ -19,13 +18,13 @@
@Override
protected void setUp() throws Exception {
- testDir = new File(new File(System.getProperty("java.io.tmpdir")), UUID.randomUUID().toString());
+ testDir = JGitTestUtil.generateTempDirectoryFileObject();
}
-
+
@Override
protected void tearDown() throws Exception {
if (testDir.exists()){
- deleteDir(testDir);
+ JGitTestUtil.deleteDir(testDir);
}
}
@@ -93,20 +92,6 @@ public void testUpdateInfoCacheCreatesPacksAndRefsFile() throws Exception {
assertEquals(expectedContents, JGitTestUtil.readFileAsString(packsFile));
}
- public boolean deleteDir(File dir) {
- if (dir.isDirectory()) {
- String[] children = dir.list();
- for (int i=0; i<children.length; i++) {
- boolean success = deleteDir(new File(dir, children[i]));
- if (!success) {
- return false;
- }
- }
- }
- // The directory is now empty so delete it
- return dir.delete();
- }
-
private void createTestDir(){
testDir.mkdir();
}
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/util/JGitTestUtil.java b/org.spearce.jgit.test/tst/org/spearce/jgit/util/JGitTestUtil.java
index b958282..7506553 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/util/JGitTestUtil.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/util/JGitTestUtil.java
@@ -40,7 +40,6 @@
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
@@ -48,6 +47,7 @@
import java.io.OutputStream;
import java.net.URISyntaxException;
import java.net.URL;
+import java.util.UUID;
public abstract class JGitTestUtil {
public static final String CLASSPATH_TO_RESOURCES = "org/spearce/jgit/test/resources/";
@@ -105,4 +105,22 @@ public static String readFileAsString(final File file)
private static ClassLoader cl() {
return JGitTestUtil.class.getClassLoader();
}
+
+ public static boolean deleteDir(File dir) {
+ if (dir.isDirectory()) {
+ String[] children = dir.list();
+ for (int i=0; i<children.length; i++) {
+ boolean success = deleteDir(new File(dir, children[i]));
+ if (!success) {
+ return false;
+ }
+ }
+ }
+ // The directory is now empty so delete it
+ return dir.delete();
+ }
+
+ public static File generateTempDirectoryFileObject() {
+ return new File(new File(System.getProperty("java.io.tmpdir")), UUID.randomUUID().toString());
+ }
}
--
1.6.4.2
^ permalink raw reply related
* [PATCH JGit 17/19] added call to update the info refs file
From: mr.gaffo @ 2009-09-13 18:44 UTC (permalink / raw)
To: git; +Cc: mike.gaffney
In-Reply-To: <1252867475-858-17-git-send-email-mr.gaffo@gmail.com>
From: mike.gaffney <mike.gaffney@asolutions.com>
---
.../org/spearce/jgit/transport/ReceivePack.java | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java b/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java
index baa1dec..0c818d9 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java
@@ -523,6 +523,16 @@ void sendString(final String s) throws IOException {
postReceive.onPostReceive(this, filterCommands(Result.OK));
updateObjectInfoCache();
+ updateInfoRefsCache();
+ }
+ }
+
+ private void updateInfoRefsCache() {
+ try{
+ getRepository().getInfoDatabase().updateInfoCache(getRepository().getAllRefs().values());
+ }
+ catch (IOException e){
+ sendMessage("error updating info/refs: " + e.getMessage());
}
}
--
1.6.4.2
^ permalink raw reply related
* [PATCH JGit 08/19] changed signature to allow a IOException
From: mr.gaffo @ 2009-09-13 18:44 UTC (permalink / raw)
To: git; +Cc: mike.gaffney
In-Reply-To: <1252867475-858-8-git-send-email-mr.gaffo@gmail.com>
From: mike.gaffney <mike.gaffney@asolutions.com>
---
.../jgit/lib/AlternateRepositoryDatabase.java | 2 +-
.../src/org/spearce/jgit/lib/ObjectDatabase.java | 3 ++-
.../src/org/spearce/jgit/lib/ObjectDirectory.java | 4 ++--
3 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/AlternateRepositoryDatabase.java b/org.spearce.jgit/src/org/spearce/jgit/lib/AlternateRepositoryDatabase.java
index 5cb0579..70ce505 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/AlternateRepositoryDatabase.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/AlternateRepositoryDatabase.java
@@ -132,7 +132,7 @@ protected void closeAlternates(final ObjectDatabase[] alt) {
}
@Override
- public void updateInfoCache() {
+ public void updateInfoCache() throws IOException {
odb.updateInfoCache();
}
}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDatabase.java b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDatabase.java
index 68ff523..5ded7bb 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDatabase.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDatabase.java
@@ -78,8 +78,9 @@ protected ObjectDatabase() {
* Creates the caches that are typically done by
* update-server-info, namely objects/info/packs and
* info/refs
+ * @throws IOException
*/
- public abstract void updateInfoCache();
+ public abstract void updateInfoCache() throws IOException;
/**
* Does this database exist yet?
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java
index a90ae00..95618b9 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java
@@ -516,7 +516,7 @@ boolean tryAgain(final long currLastModified) {
}
@Override
- public void updateInfoCache() {
- new UpdateDirectoryInfoCache(this.listLocalPacks(), this.infoDirectory).execute();
+ public void updateInfoCache() throws IOException {
+ new UpdateDirectoryInfoCache(this.listLocalPacks(), new File(this.infoDirectory, "packs")).execute();
}
}
--
1.6.4.2
^ permalink raw reply related
* [PATCH JGit 10/19] moved test up to a higher level to test actual functionality
From: mr.gaffo @ 2009-09-13 18:44 UTC (permalink / raw)
To: git; +Cc: mike.gaffney
In-Reply-To: <1252867475-858-10-git-send-email-mr.gaffo@gmail.com>
From: mike.gaffney <mike.gaffney@asolutions.com>
---
.../org/spearce/jgit/lib/ObjectDirectoryTest.java | 32 ++++++++++++++++----
.../UpdateDirectoryBasedPacksInfoCacheTest.java | 30 ------------------
2 files changed, 26 insertions(+), 36 deletions(-)
delete mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryBasedPacksInfoCacheTest.java
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java
index 8e4d8e5..4ac62fa 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java
@@ -1,6 +1,8 @@
package org.spearce.jgit.lib;
import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
@@ -69,12 +71,7 @@ public void testListLocalPacksNotCreated() throws Exception {
}
public void testListLocalPacksWhenThereIsAPack() throws Exception {
- createTestDir();
- File packsDir = new File(testDir, "pack");
- packsDir.mkdirs();
-
- JGitTestUtil.copyFile(TEST_PACK, new File(packsDir, TEST_PACK.getName()));
- JGitTestUtil.copyFile(TEST_IDX, new File(packsDir, TEST_IDX.getName()));
+ createSamplePacksDir();
ObjectDirectory od = new ObjectDirectory(testDir);
List<PackFile> localPacks = od.listLocalPacks();
@@ -82,6 +79,20 @@ public void testListLocalPacksWhenThereIsAPack() throws Exception {
assertEquals(TEST_PACK.getName(), localPacks.get(0).getPackFile().getName());
}
+ public void testUpdateInfoCacheCreatesPacksFile() throws Exception {
+ createSamplePacksDir();
+
+ ObjectDirectory od = new ObjectDirectory(testDir);
+ od.create();
+ od.updateInfoCache();
+
+ String expectedContents = new PacksFileContentsCreator(od.listLocalPacks()).toString();
+ File packsFile = new File(od.getDirectory(), "info/packs");
+
+ assertTrue(packsFile.exists());
+ assertEquals(expectedContents, JGitTestUtil.readFileAsString(packsFile));
+ }
+
public boolean deleteDir(File dir) {
if (dir.isDirectory()) {
String[] children = dir.list();
@@ -100,5 +111,14 @@ public boolean deleteDir(File dir) {
private void createTestDir(){
testDir.mkdir();
}
+
+ private void createSamplePacksDir() throws IOException {
+ createTestDir();
+ File packsDir = new File(testDir, "pack");
+ packsDir.mkdirs();
+
+ JGitTestUtil.copyFile(TEST_PACK, new File(packsDir, TEST_PACK.getName()));
+ JGitTestUtil.copyFile(TEST_IDX, new File(packsDir, TEST_IDX.getName()));
+ }
}
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryBasedPacksInfoCacheTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryBasedPacksInfoCacheTest.java
deleted file mode 100644
index f5163e4..0000000
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryBasedPacksInfoCacheTest.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package org.spearce.jgit.lib;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.spearce.jgit.util.JGitTestUtil;
-
-public class UpdateDirectoryBasedPacksInfoCacheTest extends TestCase {
- private static final String PACK_NAME = "pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f";
- private static final File TEST_PACK = JGitTestUtil.getTestResourceFile(PACK_NAME + ".pack");
- private static final File TEST_IDX = JGitTestUtil.getTestResourceFile(PACK_NAME + ".idx");
-
- public void testCreatesTheFileAndPutsTheContentsIn() throws Exception {
- List<PackFile> packs = new ArrayList<PackFile>();
- packs.add(new PackFile(TEST_IDX, TEST_PACK));
-
- File packsFile = File.createTempFile(UpdateDirectoryBasedPacksInfoCacheTest.class.getSimpleName(), "tstdata");
- packsFile.deleteOnExit();
-
- String expectedContents = new PacksFileContentsCreator(packs).toString();
-
- new UpdateDirectoryBasedPacksInfoCache(packs, packsFile).execute();
-
- assertEquals(expectedContents, JGitTestUtil.readFileAsString(packsFile));
- }
-
-}
--
1.6.4.2
^ permalink raw reply related
* [PATCH JGit 07/19] implemented the packs file update functionality
From: mr.gaffo @ 2009-09-13 18:44 UTC (permalink / raw)
To: git; +Cc: mike.gaffney
In-Reply-To: <1252867475-858-7-git-send-email-mr.gaffo@gmail.com>
From: mike.gaffney <mike.gaffney@asolutions.com>
---
.../jgit/lib/UpdateDirectoryInfoCacheTest.java | 23 ++++++++++++++++++-
.../spearce/jgit/lib/UpdateDirectoryInfoCache.java | 17 +++++++++-----
2 files changed, 32 insertions(+), 8 deletions(-)
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryInfoCacheTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryInfoCacheTest.java
index 11d183e..25b78c5 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryInfoCacheTest.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryInfoCacheTest.java
@@ -1,11 +1,30 @@
package org.spearce.jgit.lib;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
import junit.framework.TestCase;
+import org.spearce.jgit.util.JGitTestUtil;
+
public class UpdateDirectoryInfoCacheTest extends TestCase {
+ private static final String PACK_NAME = "pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f";
+ private static final File TEST_PACK = JGitTestUtil.getTestResourceFile(PACK_NAME + ".pack");
+ private static final File TEST_IDX = JGitTestUtil.getTestResourceFile(PACK_NAME + ".idx");
- public void testBase() throws Exception {
- fail("nyi");
+ public void testCreatesTheFileAndPutsTheContentsIn() throws Exception {
+ List<PackFile> packs = new ArrayList<PackFile>();
+ packs.add(new PackFile(TEST_IDX, TEST_PACK));
+
+ File packsFile = File.createTempFile(UpdateDirectoryInfoCacheTest.class.getSimpleName(), "tstdata");
+ packsFile.deleteOnExit();
+
+ String expectedContents = new PacksFileContentsCreator(packs).toString();
+
+ new UpdateDirectoryInfoCache(packs, packsFile).execute();
+
+ assertEquals(expectedContents, JGitTestUtil.readFileAsString(packsFile));
}
}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryInfoCache.java b/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryInfoCache.java
index 2bceb9e..72a315a 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryInfoCache.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryInfoCache.java
@@ -1,22 +1,27 @@
package org.spearce.jgit.lib;
+import java.io.BufferedWriter;
import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
import java.util.List;
public class UpdateDirectoryInfoCache {
private List<PackFile> packsList;
- private File infoDirectory;
+ private File infoPacksFile;
public UpdateDirectoryInfoCache(List<PackFile> packsList,
- File infoDirectory) {
+ File infoPacksFile) {
this.packsList = packsList;
- this.infoDirectory = infoDirectory;
+ this.infoPacksFile = infoPacksFile;
}
- public void execute() {
-// File objectFile = objectDatabase.
-// String packsContents = new PacksFileContentsCreator(this.objectDatabase.listLocalPacks()).toString();
+ public void execute() throws IOException {
+ String packsContents = new PacksFileContentsCreator(packsList).toString();
+ FileOutputStream fos = new FileOutputStream(infoPacksFile);
+ fos.write(packsContents.getBytes());
+ fos.close();
}
}
--
1.6.4.2
^ permalink raw reply related
* [PATCH JGit 05/19] Made tests for listLocalPacks function on ObjectDirectory and made them pass
From: mr.gaffo @ 2009-09-13 18:44 UTC (permalink / raw)
To: git; +Cc: mike.gaffney
In-Reply-To: <1252867475-858-5-git-send-email-mr.gaffo@gmail.com>
From: mike.gaffney <mike.gaffney@asolutions.com>
---
.../org/spearce/jgit/lib/ObjectDirectoryTest.java | 24 ++++++++++++++++++++
.../jgit/lib/UpdateDirectoryInfoCacheTest.java | 11 +++++++++
.../tst/org/spearce/jgit/util/JGitTestUtil.java | 21 ++++++++++++++++-
.../src/org/spearce/jgit/lib/ObjectDirectory.java | 6 +++++
.../spearce/jgit/lib/UpdateDirectoryInfoCache.java | 22 ++++++++++++++++++
5 files changed, 83 insertions(+), 1 deletions(-)
create mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryInfoCacheTest.java
create mode 100644 org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryInfoCache.java
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java
index fe019af..8e4d8e5 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java
@@ -1,11 +1,17 @@
package org.spearce.jgit.lib;
import java.io.File;
+import java.util.List;
import java.util.UUID;
+import org.spearce.jgit.util.JGitTestUtil;
+
import junit.framework.TestCase;
public class ObjectDirectoryTest extends TestCase {
+ private static final String PACK_NAME = "pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f";
+ private static final File TEST_PACK = JGitTestUtil.getTestResourceFile(PACK_NAME + ".pack");
+ private static final File TEST_IDX = JGitTestUtil.getTestResourceFile(PACK_NAME + ".idx");
private File testDir;
@@ -58,6 +64,24 @@ public void testGettingObjectFile() throws Exception {
od.fileFor(ObjectId.fromString("b052a1272310d8df34de72f60204dee7e28a43d0")));
}
+ public void testListLocalPacksNotCreated() throws Exception {
+ assertEquals(0, new ObjectDirectory(testDir).listLocalPacks().size());
+ }
+
+ public void testListLocalPacksWhenThereIsAPack() throws Exception {
+ createTestDir();
+ File packsDir = new File(testDir, "pack");
+ packsDir.mkdirs();
+
+ JGitTestUtil.copyFile(TEST_PACK, new File(packsDir, TEST_PACK.getName()));
+ JGitTestUtil.copyFile(TEST_IDX, new File(packsDir, TEST_IDX.getName()));
+
+ ObjectDirectory od = new ObjectDirectory(testDir);
+ List<PackFile> localPacks = od.listLocalPacks();
+ assertEquals(1, localPacks.size());
+ assertEquals(TEST_PACK.getName(), localPacks.get(0).getPackFile().getName());
+ }
+
public boolean deleteDir(File dir) {
if (dir.isDirectory()) {
String[] children = dir.list();
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryInfoCacheTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryInfoCacheTest.java
new file mode 100644
index 0000000..11d183e
--- /dev/null
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryInfoCacheTest.java
@@ -0,0 +1,11 @@
+package org.spearce.jgit.lib;
+
+import junit.framework.TestCase;
+
+public class UpdateDirectoryInfoCacheTest extends TestCase {
+
+ public void testBase() throws Exception {
+ fail("nyi");
+ }
+
+}
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/util/JGitTestUtil.java b/org.spearce.jgit.test/tst/org/spearce/jgit/util/JGitTestUtil.java
index eee0c14..04184d7 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/util/JGitTestUtil.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/util/JGitTestUtil.java
@@ -38,6 +38,12 @@
package org.spearce.jgit.util;
import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
import java.net.URISyntaxException;
import java.net.URL;
@@ -60,11 +66,24 @@ public static File getTestResourceFile(final String fileName) {
}
try {
return new File(url.toURI());
- } catch(URISyntaxException e) {
+ } catch (URISyntaxException e) {
return new File(url.getPath());
}
}
+ public static void copyFile(final File fromFile, final File toFile) throws IOException {
+ InputStream in = new FileInputStream(fromFile);
+ OutputStream out = new FileOutputStream(toFile);
+
+ byte[] buf = new byte[1024];
+ int len;
+ while ((len = in.read(buf)) > 0) {
+ out.write(buf, 0, len);
+ }
+ in.close();
+ out.close();
+ }
+
private static ClassLoader cl() {
return JGitTestUtil.class.getClassLoader();
}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java
index fe219c6..a90ae00 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java
@@ -511,6 +511,12 @@ boolean tryAgain(final long currLastModified) {
@Override
public List<PackFile> listLocalPacks() {
+ tryAgain1();
return new ArrayList<PackFile>(Arrays.asList(packList.get().packs));
}
+
+ @Override
+ public void updateInfoCache() {
+ new UpdateDirectoryInfoCache(this.listLocalPacks(), this.infoDirectory).execute();
+ }
}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryInfoCache.java b/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryInfoCache.java
new file mode 100644
index 0000000..2bceb9e
--- /dev/null
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryInfoCache.java
@@ -0,0 +1,22 @@
+package org.spearce.jgit.lib;
+
+import java.io.File;
+import java.util.List;
+
+public class UpdateDirectoryInfoCache {
+
+ private List<PackFile> packsList;
+ private File infoDirectory;
+
+ public UpdateDirectoryInfoCache(List<PackFile> packsList,
+ File infoDirectory) {
+ this.packsList = packsList;
+ this.infoDirectory = infoDirectory;
+ }
+
+ public void execute() {
+// File objectFile = objectDatabase.
+// String packsContents = new PacksFileContentsCreator(this.objectDatabase.listLocalPacks()).toString();
+ }
+
+}
--
1.6.4.2
^ permalink raw reply related
* [PATCH JGit 06/19] added utility for reading the contents of a file as a string
From: mr.gaffo @ 2009-09-13 18:44 UTC (permalink / raw)
To: git; +Cc: mike.gaffney
In-Reply-To: <1252867475-858-6-git-send-email-mr.gaffo@gmail.com>
From: mike.gaffney <mike.gaffney@asolutions.com>
---
.../tst/org/spearce/jgit/util/JGitTestUtil.java | 20 +++++++++++++++++++-
1 files changed, 19 insertions(+), 1 deletions(-)
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/util/JGitTestUtil.java b/org.spearce.jgit.test/tst/org/spearce/jgit/util/JGitTestUtil.java
index 04184d7..b958282 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/util/JGitTestUtil.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/util/JGitTestUtil.java
@@ -37,10 +37,12 @@
package org.spearce.jgit.util;
+import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
+import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -71,7 +73,8 @@ public static File getTestResourceFile(final String fileName) {
}
}
- public static void copyFile(final File fromFile, final File toFile) throws IOException {
+ public static void copyFile(final File fromFile, final File toFile)
+ throws IOException {
InputStream in = new FileInputStream(fromFile);
OutputStream out = new FileOutputStream(toFile);
@@ -84,6 +87,21 @@ public static void copyFile(final File fromFile, final File toFile) throws IOExc
out.close();
}
+ public static String readFileAsString(final File file)
+ throws java.io.IOException {
+ StringBuilder fileData = new StringBuilder(1000);
+ BufferedReader reader = new BufferedReader(new FileReader(file));
+ char[] buf = new char[1024];
+ int numRead = 0;
+ while ((numRead = reader.read(buf)) != -1) {
+ String readData = String.valueOf(buf, 0, numRead);
+ fileData.append(readData);
+ buf = new char[1024];
+ }
+ reader.close();
+ return fileData.toString();
+ }
+
private static ClassLoader cl() {
return JGitTestUtil.class.getClassLoader();
}
--
1.6.4.2
^ permalink raw reply related
* [PATCH JGit 03/19] Add abstract method for updating the object db's info cache Implemented passthrough on Alternate for the update of infocache
From: mr.gaffo @ 2009-09-13 18:44 UTC (permalink / raw)
To: git; +Cc: mike.gaffney
In-Reply-To: <1252867475-858-3-git-send-email-mr.gaffo@gmail.com>
From: mike.gaffney <mike.gaffney@asolutions.com>
---
.../jgit/lib/AlternateRepositoryDatabase.java | 5 +++++
.../src/org/spearce/jgit/lib/ObjectDatabase.java | 7 +++++++
2 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/AlternateRepositoryDatabase.java b/org.spearce.jgit/src/org/spearce/jgit/lib/AlternateRepositoryDatabase.java
index 68ad488..5cb0579 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/AlternateRepositoryDatabase.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/AlternateRepositoryDatabase.java
@@ -130,4 +130,9 @@ protected void closeAlternates(final ObjectDatabase[] alt) {
public List<PackFile> listLocalPacks() {
return odb.listLocalPacks();
}
+
+ @Override
+ public void updateInfoCache() {
+ odb.updateInfoCache();
+ }
}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDatabase.java b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDatabase.java
index 722c802..68ff523 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDatabase.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDatabase.java
@@ -75,6 +75,13 @@ protected ObjectDatabase() {
public abstract List<PackFile> listLocalPacks();
/**
+ * Creates the caches that are typically done by
+ * update-server-info, namely objects/info/packs and
+ * info/refs
+ */
+ public abstract void updateInfoCache();
+
+ /**
* Does this database exist yet?
*
* @return true if this database is already created; false if the caller
--
1.6.4.2
^ permalink raw reply related
* [PATCH JGit 04/19] added utility that generates the contents of the objects/info/packs file as a string from a list of PackFiles
From: mr.gaffo @ 2009-09-13 18:44 UTC (permalink / raw)
To: git; +Cc: mike.gaffney
In-Reply-To: <1252867475-858-4-git-send-email-mr.gaffo@gmail.com>
From: mike.gaffney <mike.gaffney@asolutions.com>
---
.../jgit/lib/PacksFileContentsCreatorTest.java | 37 ++++++++++++++++++++
.../spearce/jgit/lib/PacksFileContentsCreator.java | 21 +++++++++++
2 files changed, 58 insertions(+), 0 deletions(-)
create mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/lib/PacksFileContentsCreatorTest.java
create mode 100644 org.spearce.jgit/src/org/spearce/jgit/lib/PacksFileContentsCreator.java
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PacksFileContentsCreatorTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PacksFileContentsCreatorTest.java
new file mode 100644
index 0000000..ef28a26
--- /dev/null
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PacksFileContentsCreatorTest.java
@@ -0,0 +1,37 @@
+package org.spearce.jgit.lib;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.spearce.jgit.util.JGitTestUtil;
+
+import junit.framework.TestCase;
+
+public class PacksFileContentsCreatorTest extends TestCase {
+ private static final String PACK_NAME = "pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f";
+ private static final File TEST_PACK = JGitTestUtil.getTestResourceFile(PACK_NAME + ".pack");
+ private static final File TEST_IDX = JGitTestUtil.getTestResourceFile(PACK_NAME + ".idx");
+
+ public void testGettingPacksContentsSinglePack() throws Exception {
+ List<PackFile> packs = new ArrayList<PackFile>();
+ packs.add(new PackFile(TEST_IDX, TEST_PACK));
+
+ assertEquals("P " + TEST_PACK.getName() + '\r', new PacksFileContentsCreator(packs).toString());
+ }
+
+ public void testGettingPacksContentsMultiplePacks() throws Exception {
+ List<PackFile> packs = new ArrayList<PackFile>();
+ packs.add(new PackFile(TEST_IDX, TEST_PACK));
+ packs.add(new PackFile(TEST_IDX, TEST_PACK));
+ packs.add(new PackFile(TEST_IDX, TEST_PACK));
+
+ StringBuilder expected = new StringBuilder();
+ expected.append("P ").append(TEST_PACK.getName()).append("\r");
+ expected.append("P ").append(TEST_PACK.getName()).append("\r");
+ expected.append("P ").append(TEST_PACK.getName()).append("\r");
+
+ assertEquals(expected.toString(), new PacksFileContentsCreator(packs).toString());
+ }
+
+}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/PacksFileContentsCreator.java b/org.spearce.jgit/src/org/spearce/jgit/lib/PacksFileContentsCreator.java
new file mode 100644
index 0000000..3dd0418
--- /dev/null
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/PacksFileContentsCreator.java
@@ -0,0 +1,21 @@
+package org.spearce.jgit.lib;
+
+import java.util.List;
+
+public class PacksFileContentsCreator {
+
+ private List<PackFile> packs;
+
+ public PacksFileContentsCreator(List<PackFile> packs) {
+ this.packs = packs;
+ }
+
+ public String toString(){
+ StringBuilder builder = new StringBuilder();
+ for (PackFile packFile : packs) {
+ builder.append("P ").append(packFile.getPackFile().getName()).append('\r');
+ }
+ return builder.toString();
+ }
+
+}
--
1.6.4.2
^ permalink raw reply related
* [PATCH JGit 01/19] adding tests for ObjectDirectory
From: mr.gaffo @ 2009-09-13 18:44 UTC (permalink / raw)
To: git; +Cc: mike.gaffney
In-Reply-To: <1252867475-858-1-git-send-email-mr.gaffo@gmail.com>
From: mike.gaffney <mike.gaffney@asolutions.com>
---
.../org/spearce/jgit/lib/ObjectDirectoryTest.java | 80 ++++++++++++++++++++
1 files changed, 80 insertions(+), 0 deletions(-)
create mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java
new file mode 100644
index 0000000..fe019af
--- /dev/null
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java
@@ -0,0 +1,80 @@
+package org.spearce.jgit.lib;
+
+import java.io.File;
+import java.util.UUID;
+
+import junit.framework.TestCase;
+
+public class ObjectDirectoryTest extends TestCase {
+
+ private File testDir;
+
+ @Override
+ protected void setUp() throws Exception {
+ testDir = new File(new File(System.getProperty("java.io.tmpdir")), UUID.randomUUID().toString());
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ if (testDir.exists()){
+ deleteDir(testDir);
+ }
+ }
+
+ public void testCanGetDirectory() throws Exception {
+ ObjectDirectory od = new ObjectDirectory(testDir);
+ assertEquals(testDir, od.getDirectory());
+ }
+
+ public void testExistsWithExistingDirectory() throws Exception {
+ createTestDir();
+ ObjectDirectory od = new ObjectDirectory(testDir);
+ assertTrue(od.exists());
+ }
+
+ public void testExistsWithNonExistantDirectory() throws Exception {
+ assertFalse(new ObjectDirectory(new File("/some/nonexistant/file")).exists());
+ }
+
+ public void testCreateMakesCorrectDirectories() throws Exception {
+ assertFalse(testDir.exists());
+ new ObjectDirectory(testDir).create();
+ assertTrue(testDir.exists());
+
+ File infoDir = new File(testDir, "info");
+ assertTrue(infoDir.exists());
+ assertTrue(infoDir.isDirectory());
+
+ File packDir = new File(testDir, "pack");
+ assertTrue(packDir.exists());
+ assertTrue(packDir.isDirectory());
+ }
+
+ public void testGettingObjectFile() throws Exception {
+ ObjectDirectory od = new ObjectDirectory(testDir);
+ assertEquals(new File(testDir, "02/829ae153935095e4223f30cfc98c835de71bee"),
+ od.fileFor(ObjectId.fromString("02829ae153935095e4223f30cfc98c835de71bee")));
+ assertEquals(new File(testDir, "b0/52a1272310d8df34de72f60204dee7e28a43d0"),
+ od.fileFor(ObjectId.fromString("b052a1272310d8df34de72f60204dee7e28a43d0")));
+ }
+
+ public boolean deleteDir(File dir) {
+ if (dir.isDirectory()) {
+ String[] children = dir.list();
+ for (int i=0; i<children.length; i++) {
+ boolean success = deleteDir(new File(dir, children[i]));
+ if (!success) {
+ return false;
+ }
+ }
+ }
+
+ // The directory is now empty so delete it
+ return dir.delete();
+ }
+
+ private void createTestDir(){
+ testDir.mkdir();
+ }
+
+}
--
1.6.4.2
^ permalink raw reply related
* [PATCH JGit] Adding update-server-info functionality
From: mr.gaffo @ 2009-09-13 18:44 UTC (permalink / raw)
To: git
This patch series implements update-server-info functionality
in JGit and integrates it with ReceivePack so that repositories
hosted by git-http can also be hosted by JGit.
^ permalink raw reply
* Re: [PATCH] git-gui: suggest gc only when counting at least 2 objects
From: Clemens Buchacher @ 2009-09-13 18:41 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, msysgit, Shawn O. Pearce
In-Reply-To: <7vr5uasp4a.fsf@alter.siamese.dyndns.org>
On Sun, Sep 13, 2009 at 10:58:45AM -0700, Junio C Hamano wrote:
> Somebody cares to explain why this threashold number has to be different
> per platform in the first place?
I really don't know. I vaguely remember someone claim that performance on
Windows suffered from many loose objects more than on other platforms. I
can't find any discussion of it though.
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox