* Re: rename tracking and file-name swapping
From: Yuri D'Elia @ 2009-09-13 21:13 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Bernardo Innocenti
In-Reply-To: <7viqfmsoej.fsf@alter.siamese.dyndns.org>
On 13 Sep 2009, at 20:14, Junio C Hamano wrote:
>> % mv file1.txt file3.txt
>> % mv file2.txt file1.txt
>> % mv file3.txt file2.txt
>> % git add file1.txt file2.txt
>> % git diff -M --stat --cached
>> file1.txt | 150 ++++++++++++++++++++++
>> +-------------------------------------
>> file2.txt | 150 ++++++++++++++++++++++++++++++++++++
>> +-----------------------
>> 2 files changed, 150 insertions(+), 150 deletions(-)
>
> By default, if the pathname that was present in the old version still
> appears in the new version, that path is not considered as a candiate
> for rename detection. Only "X used to be there but is gone" and "Y
> did
> not exist but appeared" are paired up and checked if they are similar.
>
> Give the command -B option, too, to break the filepair that does not
> disappear.
That does the trick. I'm curious, is there any other use for -B
besides rename handling?
Any reason of why it isn't a default when --find-copies-harder is in
effect?
^ permalink raw reply
* Re: [PATCH v2 2/2] teach git-archive to auto detect the output format
From: Junio C Hamano @ 2009-09-13 21:27 UTC (permalink / raw)
To: Dmitry Potapov; +Cc: git, John Tapsell
In-Reply-To: <20090913201701.GH30385@dpotapov.dyndns.org>
Dmitry Potapov <dpotapov@gmail.com> writes:
> On Sun, Sep 13, 2009 at 11:52:56AM -0700, Junio C Hamano wrote:
>> > + sprintf(fmt_opt, "--format=%s", format);
>> > + argv[argc++] = fmt_opt;
>> > + argv[argc] = NULL;
>>
> Either --output or --format option was used before, and this option is
> extracted from argv[] by parse_options(). So it should be space for at
> least one argument in argv.
To my taste, that is a unwarranted (on the borderline) assumption of what
parse_options() does, but I'll let it pass with some additional comment to
warn readers of the code.
Applied.
^ permalink raw reply
* Re: [PATCH] git-gui: suggest gc only when counting at least 2 objects
From: Clemens Buchacher @ 2009-09-13 21:19 UTC (permalink / raw)
To: Jeff King; +Cc: Junio C Hamano, git, msysgit, Shawn O. Pearce
In-Reply-To: <20090913204433.GA8796@coredump.intra.peff.net>
On Sun, Sep 13, 2009 at 04:44:33PM -0400, Jeff King wrote:
> On Sun, Sep 13, 2009 at 08:41:50PM +0200, Clemens Buchacher wrote:
>
> > 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.
>
> Maybe 8ff487c?
Ok. But it's been 2 years since then and if I'm not mistaken, there have
been a number of performance improvements to msysgit. So maybe it's time to
revisit that threshold.
If, on the other hand, requiring 2 objects really is too many, we should
maybe check at least two or four directories, which would greatly improve
the statistic.
For example, the probability of q directories containing q objects, for n
objects total is
n \ q 1 4
50 18% 1%
100 32% 7%
200 54% 38%
500 86% 95%
Clemens
^ permalink raw reply
* Re: Confusing git pull error message
From: Junio C Hamano @ 2009-09-13 21:18 UTC (permalink / raw)
To: John Tapsell; +Cc: Jeff King, Git List
In-Reply-To: <43d8ce650909131357m50428ffbs9c939be051254eb7@mail.gmail.com>
John Tapsell <johnflux@gmail.com> writes:
> Yeah, it kinda sounds like git is just being lazy, and can't be
> bothered to fetch it :-)
Do you want it to say "you didn't tell us to fetch it"?
After all, we only do what the user instructs us to do, so I thought that
goes without saying it.
^ permalink raw reply
* Re: Confusing git pull error message
From: Junio C Hamano @ 2009-09-13 21:16 UTC (permalink / raw)
To: Jeff King; +Cc: John Tapsell, Git List
In-Reply-To: <20090913204231.GA8654@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
> On Sun, Sep 13, 2009 at 01:38:48PM -0700, Junio C Hamano wrote:
>
>> I saw some discussion on improving the wording. Here is what I plan to
>> commit.
>
> Thanks for picking this up, I meant to re-post with improvements.
I am _not_ going to commit the following patch, because it will interfere
with this clarification effort, but I think we want to do something along
this line after the "clarification" settles.
An observation I'd like to make is that this is way too ugly:
[advice]
pullNoMergeFound = false
pushNonFastForward = false
statusHints = false
than
[IKnowWhatIAmDoingThankYouVeryMuch]
pullNoMergeFound
pushNonFastForward
statusHints
but this feature is for people who know what they are doing, so I guess
the current set-up would be fine.
git-pull.sh | 78 ++++++++++++++++++++++++++++++++++++++++------------------
1 files changed, 54 insertions(+), 24 deletions(-)
diff --git a/git-pull.sh b/git-pull.sh
index 0bbd5bf..101545e 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -76,14 +76,64 @@ do
shift
done
+advice_tags_only () {
+ if test -z "$1"
+ then
+ echo "Fetching tags only."
+ return
+ fi
+ echo "Fetching tags only, you probably meant:"
+ echo " git fetch --tags"
+}
+
+advice_detached_head () {
+ if test -z "$1"
+ then
+ echo "No default merge candidate on a detached HEAD."
+ return
+ fi
+ echo "You are not currently on a branch, so I cannot use any"
+ echo "'branch.<branchname>.merge' in your configuration file."
+ echo "Please specify which branch you want to merge on the command"
+ echo "line and try again (e.g. 'git pull <repository> <refspec>')."
+ echo "See git-pull(1) for details."
+}
+
+advice_no_merge_candidates () {
+ if test -z "$1"
+ then
+ echo "No merge candidate for the current branch fetched."
+ return
+ fi
+ cat <<EOF
+You asked me to pull without telling me which branch you
+want to merge with, and 'branch.$2.merge' in
+your configuration file does not tell me either. Please
+specify which branch you want to merge on the command line and
+try again (e.g. 'git pull <repository> <refspec>').
+See git-pull(1) for details.
+
+If you often merge with the same branch, you may want to
+configure the following variables in your configuration
+file:
+
+ branch.$2.remote = <nickname>
+ branch.$2.merge = <remote-ref>
+ remote.<nickname>.url = <url>"
+ remote.<nickname>.fetch = <refspec>
+
+See git-config(1) for details.
+EOF
+}
+
error_on_no_merge_candidates () {
exec >&2
+ advice=$(git config --bool advice.pullNoMergeFound)
for opt
do
case "$opt" in
-t|--t|--ta|--tag|--tags)
- echo "Fetching tags only, you probably meant:"
- echo " git fetch --tags"
+ advice_tags_only "$advice"
exit 1
esac
done
@@ -91,29 +141,9 @@ error_on_no_merge_candidates () {
curr_branch=${curr_branch#refs/heads/}
if [ -z "$curr_branch" ]; then
- echo "You are not currently on a branch, so I cannot use any"
- echo "'branch.<branchname>.merge' in your configuration file."
- echo "Please specify which branch you want to merge on the command"
- echo "line and try again (e.g. 'git pull <repository> <refspec>')."
- echo "See git-pull(1) for details."
+ advice_detached_head "$advice"
else
- echo "You asked me to pull without telling me which branch you"
- echo "want to merge with, and 'branch.${curr_branch}.merge' in"
- echo "your configuration file does not tell me either. Please"
- echo "specify which branch you want to merge on the command line and"
- echo "try again (e.g. 'git pull <repository> <refspec>')."
- echo "See git-pull(1) for details."
- echo
- echo "If you often merge with the same branch, you may want to"
- echo "configure the following variables in your configuration"
- echo "file:"
- echo
- echo " branch.${curr_branch}.remote = <nickname>"
- echo " branch.${curr_branch}.merge = <remote-ref>"
- echo " remote.<nickname>.url = <url>"
- echo " remote.<nickname>.fetch = <refspec>"
- echo
- echo "See git-config(1) for details."
+ advice_no_merge_candidate "$advice" "$curr_branch"
fi
exit 1
}
^ permalink raw reply related
* [ANNOUNCE] CGIT 0.8.3
From: Lars Hjemli @ 2009-09-13 21:00 UTC (permalink / raw)
To: Git Mailing List
In-Reply-To: <8c5c35580909131355n78d817e0x67c15a1e19beb8c3@mail.gmail.com>
A new feature-release of cgit, a fast webinterface for git, is now
available for cloning from git://hjemli.net/pub/git/cgit (or browsing
on http://hjemli.net/git/cgit).
Some release highlights:
* support for output filters, e.g. syntax highlighting and bugtracker
integration - check subdirectory "filters" for examples
* support for automatic scanning for repositories and caching of the
resulting list
* improved support for mimetypes in "plain" view
* improved support for lightweight tags
* improved support for embedding cgit in site-specific layouts
* option to avoid printing author/committer/tagger email
* support for styling treeview based on filename extension (i.e. icons)
* lots of bugfixes
Thanks to everyone who contributed code and/or feedback.
Shortlog v0.8.2.1..v0.8.2.2
===========================
Lars Hjemli (4):
ui-tag.c: do not segfault when id is missing from query-string
cgit.c: do not segfault on unexpected query-string format
ui-plain.c: only return the blob with the specified path
CGIT 0.8.2.2
Matthew Metnetsky (1):
ui-shared: don't print header <img/> if there isn't a logo defined
Shortlog v0.8.2.2..v0.8.3
=========================
Simon Arlott (1):
truncate buffer before reading empty files
Diego Ongaro (2):
add cgit_httpscheme() -> http:// or https://
use cgit_httpscheme() for atom feed
Florian Pritz (2):
ui-tree.c: show line numbers when highlighting
Add 'linenumbers' config option
Lars Hjemli (62):
Add support for an 'embedded' option in cgitrc
cgitrc.5.txt: make the cgitrc options a valid asciidoc labeled list
cgitrc.5.txt: wrap the example file in an asciidoc LiteralBlock
cgitrc.5.txt: un-indent the name section
Add cgit-doc.css
Makefile: add doc-related targets
Add support for ETag in 'plain' view
Add support for HEAD requests
Fix doc-related glitches in Makefile and .gitignore
Return http statuscode 404 on unknown branch
ui-blob: return 'application/octet-stream' for binary blobs
cgitrc.5.txt: document 'head-include'
Add support for 'noheader' option
cgitrc.5.txt: document 'embedded' and 'noheader'
cgit.h: keep config flags sorted
Add support for mime type registration and lookup
Add generic filter/plugin infrastructure
ui-snapshot: use cgit_{open|close}_filter() to execute compressors
ui-tree: add support for source-filter option
ui-commit: add support for 'commit-filter' option
Add support for repo.commit-filter and repo.source-filter
cgit.c: allow repo.*-filter options to unset the current default
ui-summary: enable arbitrary paths below repo.readme
Add 'about-filter' and 'repo.about-filter' options
Add some example filter scripts
Cleanup handling of environment variables
ui-shared: add support for NO_HTTP=1/--nohttp
cgit.css: align commit message with subject in expanded log listing
cgit.c: make '/cgit.png' the default value for 'logo' option
cgitrc.5.txt: describe where/how cgit will locate cgitrc
ui-shared: add support for header/footer options when embedded=1
Use GIT-1.6.3.4
ui-log.c: handle lightweight tags when printing commit decorations
Add and use a common readfile() function
cgit.c: fix caching keyed on PATH_INFO with no QUERY_STRING
Rename "linenumbers" to "enable-tree-linenumbers", change default to "1"
cgit.css: make the blob display in tree view a bit prettier
cgitrc.5.txt: fix description and markup for 'snapshots' option
scan-tree: detect non-bare repository and stop scanning early
cgit.c: add support for cgitrc option 'repo.scan'
cache.h: export hash_str()
cgit.c: make print_repolist() and print_repo() reusable for caching
cgit.c: add support for caching autodetected repositories
cgitrc.5.txt: document repo.scan and cache-scanrc-ttl
Rename 'repo.scan' to 'scan-path'
Add support for --scan-path command line option
Introduce 'section' as canonical spelling for 'repo.group'
Add config option 'repo.section'
ui-repolist.c: sort by section name, repo name as default
cgit.c: refactor repo_config() from config_cb()
Add support for repo-local cgitrc file
ui-repolist: handle empty sections similar to NULL sections
cgitrc.5.txt: fix markup errors
Add config option 'enable-filter-overrides'
shared.c: initialize cgit_repo structs properly
cgit.c: add missing options to print_repo()
cgit.c: generate repo.snapshots in print_repo()
Add and use cgit_find_stats_periodname() in print_repo()
cgit.c: only print first line of repo.desc in print_repo()
cgit.c: respect repo-local 'snapshots' option for --scan-path
Use GIT-1.6.4.3
CGIT 0.8.3
Mark Lodato (1):
Add head-include configuration option.
Martin Szulecki (2):
Introduce noplainemail option to hide email adresses from spambots
Expose file extension in tree lists as class to allow nicer tree styling
Matt McCormick (thewtex) (1):
make cgitrc.5.txt asciidoc manpage compatible
Remko Tronçon (1):
ui-plain: Return 'application/octet-stream' for binary files.
Stefan Bühler (1):
ui-refs.c: improve handling of lightweight tags
Stefan Naewe (1):
scan-tree: split the pw_gecos field at the ',' to get the real name
^ permalink raw reply
* Re: Confusing git pull error message
From: John Tapsell @ 2009-09-13 20:57 UTC (permalink / raw)
To: Jeff King; +Cc: Junio C Hamano, Git List
In-Reply-To: <20090913204231.GA8654@coredump.intra.peff.net>
2009/9/13 Jeff King <peff@peff.net>:
> On Sun, Sep 13, 2009 at 01:38:48PM -0700, Junio C Hamano wrote:
>
>> I saw some discussion on improving the wording. Here is what I plan to
>> commit.
>
> Thanks for picking this up, I meant to re-post with improvements.
>
>> + else
>> + echo "Your configuration specifies to merge the ref"
>> + echo "'${upstream#refs/heads/}' from the remote, but no such ref"
>> + echo "was fetched."
>
> What you have here is precisely what we observed. But I think one of the
> complaints was to say more explicitly "that ref doesn't exist on the
> remote", which I think should be the case if we have got to this point
> (anything else would have triggered an error in fetch).
Yeah, it kinda sounds like git is just being lazy, and can't be
bothered to fetch it :-)
^ permalink raw reply
* Re: Confusing git pull error message
From: Junio C Hamano @ 2009-09-13 20:57 UTC (permalink / raw)
To: Jeff King; +Cc: John Tapsell, Git List
In-Reply-To: <20090913204231.GA8654@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
> What you have here is precisely what we observed. But I think one of the
> complaints was to say more explicitly "that ref doesn't exist on the
> remote", which I think should be the case if we have got to this point
> (anything else would have triggered an error in fetch).
Wouldn't you get into the situation with this?
[remote "origin"]
fetch = refs/heads/master:refs/heads/master
[branch "master"]
remote = origin
merge = refs/heads/next
I think saying "does not exist" will repeat the same mistake of
overguessing you are trying to rectify.
^ permalink raw reply
* Re: [PATCH] git-gui: suggest gc only when counting at least 2 objects
From: Jeff King @ 2009-09-13 20:44 UTC (permalink / raw)
To: Clemens Buchacher; +Cc: Junio C Hamano, git, msysgit, Shawn O. Pearce
In-Reply-To: <20090913184150.GA19209@localhost>
On Sun, Sep 13, 2009 at 08:41:50PM +0200, Clemens Buchacher wrote:
> 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.
Maybe 8ff487c?
-Peff
^ permalink raw reply
* Re: Confusing git pull error message
From: Jeff King @ 2009-09-13 20:42 UTC (permalink / raw)
To: Junio C Hamano; +Cc: John Tapsell, Git List
In-Reply-To: <7v1vmar353.fsf@alter.siamese.dyndns.org>
On Sun, Sep 13, 2009 at 01:38:48PM -0700, Junio C Hamano wrote:
> I saw some discussion on improving the wording. Here is what I plan to
> commit.
Thanks for picking this up, I meant to re-post with improvements.
> + else
> + echo "Your configuration specifies to merge the ref"
> + echo "'${upstream#refs/heads/}' from the remote, but no such ref"
> + echo "was fetched."
What you have here is precisely what we observed. But I think one of the
complaints was to say more explicitly "that ref doesn't exist on the
remote", which I think should be the case if we have got to this point
(anything else would have triggered an error in fetch).
I don't have a strong feeling either way, though.
-Peff
^ permalink raw reply
* Re: [PATCH] completion: Replace config --list with --get-regexp
From: Junio C Hamano @ 2009-09-13 20:40 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: Todd Zullinger, Jeff King, james bardin, git
In-Reply-To: <20090912183139.GO1033@spearce.org>
Thanks, everybody. Will apply.
^ permalink raw reply
* Re: Confusing git pull error message
From: Junio C Hamano @ 2009-09-13 20:38 UTC (permalink / raw)
To: Jeff King; +Cc: John Tapsell, Git List
In-Reply-To: <20090912211119.GA30966@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
> I think it is enough for git-pull to just check whether the config
> exists, and if so, guess that the ref was simply not fetched. IOW,
> this:
Thanks.
I saw some discussion on improving the wording. Here is what I plan to
commit.
diff --git a/git-pull.sh b/git-pull.sh
index 0bbd5bf..2c2fa79 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -89,6 +89,8 @@ error_on_no_merge_candidates () {
done
curr_branch=${curr_branch#refs/heads/}
+ upstream=$(git config "branch.$curr_branch.merge" ||
+ git config "branch.$curr_branch.rebase")
if [ -z "$curr_branch" ]; then
echo "You are not currently on a branch, so I cannot use any"
@@ -96,7 +98,7 @@ error_on_no_merge_candidates () {
echo "Please specify which branch you want to merge on the command"
echo "line and try again (e.g. 'git pull <repository> <refspec>')."
echo "See git-pull(1) for details."
- else
+ elif [ -z "$upstream" ]; then
echo "You asked me to pull without telling me which branch you"
echo "want to merge with, and 'branch.${curr_branch}.merge' in"
echo "your configuration file does not tell me either. Please"
@@ -114,6 +116,10 @@ error_on_no_merge_candidates () {
echo " remote.<nickname>.fetch = <refspec>"
echo
echo "See git-config(1) for details."
+ else
+ echo "Your configuration specifies to merge the ref"
+ echo "'${upstream#refs/heads/}' from the remote, but no such ref"
+ echo "was fetched."
fi
exit 1
}
^ permalink raw reply related
* [PATCH v2 2/2] teach git-archive to auto detect the output format
From: Dmitry Potapov @ 2009-09-13 20:17 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, John Tapsell
In-Reply-To: <7vzl8yr81j.fsf@alter.siamese.dyndns.org>
When I type something like this:
git archive -o my-v2.0.zip v2.0
it is almost certainly that I want to create a zip archive, and not
a tar file.
This patch teaches git-archive to auto detect the output format from the
file name. Currently, only '.zip' is supported. If the auto detect failed,
the tar format is used as before. The auto detect is not used when the
output format is specified explicitly.
Signed-off-by: Dmitry Potapov <dpotapov@gmail.com>
---
I have corrected all remarks except this:
On Sun, Sep 13, 2009 at 11:52:56AM -0700, Junio C Hamano wrote:
> > + 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.
Either --output or --format option was used before, and this option is
extracted from argv[] by parse_options(). So it should be space for at
least one argument in argv.
Documentation/git-archive.txt | 13 +++++++++++--
builtin-archive.c | 25 ++++++++++++++++++++++++-
2 files changed, 35 insertions(+), 3 deletions(-)
diff --git a/Documentation/git-archive.txt b/Documentation/git-archive.txt
index 1917f2e..3d1c1e7 100644
--- a/Documentation/git-archive.txt
+++ b/Documentation/git-archive.txt
@@ -34,8 +34,11 @@ OPTIONS
-------
--format=<fmt>::
- Format of the resulting archive: 'tar' or 'zip'. The default
- is 'tar'.
+ Format of the resulting archive: 'tar' or 'zip'. 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`.
-l::
--list::
@@ -130,6 +133,12 @@ git archive --format=zip --prefix=git-docs/ HEAD:Documentation/ > git-1.4.0-docs
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
+ inferred by the extension of the output file.
+
SEE ALSO
--------
diff --git a/builtin-archive.c b/builtin-archive.c
index 565314b..6efba6f 100644
--- a/builtin-archive.c
+++ b/builtin-archive.c
@@ -60,6 +60,17 @@ static int run_remote_archiver(int argc, const char **argv,
return !!rv;
}
+static const char* format_from_name(const char *filename)
+{
+ const char *ext = strrchr(filename, '.');
+ if (!ext)
+ return NULL;
+ ext++;
+ if (!strcasecmp(ext, "zip"))
+ return "zip";
+ return NULL;
+}
+
#define PARSE_OPT_KEEP_ALL ( PARSE_OPT_KEEP_DASHDASH | \
PARSE_OPT_KEEP_ARGV0 | \
PARSE_OPT_KEEP_UNKNOWN | \
@@ -70,6 +81,7 @@ int cmd_archive(int argc, const char **argv, const char *prefix)
const char *exec = "git-upload-archive";
const char *output = NULL;
const char *remote = NULL;
+ const char *format = NULL;
struct option local_opts[] = {
OPT_STRING('o', "output", &output, "file",
"write the archive to this file"),
@@ -77,14 +89,25 @@ 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)
+ if (output) {
create_output_file(output);
+ if (!format)
+ format = format_from_name(output);
+ }
+
+ if (format) {
+ sprintf(fmt_opt, "--format=%s", format);
+ argv[argc++] = fmt_opt;
+ argv[argc] = NULL;
+ }
if (remote)
return run_remote_archiver(argc, argv, remote, exec);
--
1.6.5.rc1.2.g6bb993
^ permalink raw reply related
* [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
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