* Re: [PATCH 3/4] index-pack: Track the object_entry that creates each base_data
From: Nicolas Pitre @ 2008-07-15 2:50 UTC (permalink / raw)
To: Shawn O. Pearce
Cc: Junio C Hamano, Junio C Hamano, git, Stephan Hennig,
Andreas Ericsson
In-Reply-To: <1216001267-33235-4-git-send-email-spearce@spearce.org>
On Sun, 13 Jul 2008, Shawn O. Pearce wrote:
> If we free the data stored within a base_data we need the struct
> object_entry to get the data back again for use with another
> dependent delta. Storing the object_entry* makes it simple to call
> get_data_from_pack() to recover the compressed information.
>
> This however means we must add the missing baes object to the end
Typo?
> of our packfile prior to calling resolve_delta() on each of the
> dependent deltas. Adding the base first ensures we can read the
> base back from the pack we indexing, as if it had been included by
> the remote side.
>
> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
ACK
> ---
> index-pack.c | 18 ++++++++++++------
> 1 files changed, 12 insertions(+), 6 deletions(-)
>
> diff --git a/index-pack.c b/index-pack.c
> index 6c59fd3..7239e89 100644
> --- a/index-pack.c
> +++ b/index-pack.c
> @@ -29,6 +29,7 @@ union delta_base {
> struct base_data {
> struct base_data *base;
> struct base_data *child;
> + struct object_entry *obj;
> void *data;
> unsigned long size;
> };
> @@ -476,6 +477,7 @@ static void resolve_delta(struct object_entry *delta_obj,
> sha1_object(result.data, result.size, type, delta_obj->idx.sha1);
> nr_resolved_deltas++;
>
> + result.obj = delta_obj;
> link_base_data(base_obj, &result);
>
> hashcpy(delta_base.sha1, delta_obj->idx.sha1);
> @@ -588,6 +590,7 @@ static void parse_pack_objects(unsigned char *sha1)
> continue;
> base_obj.data = get_data_from_pack(obj);
> base_obj.size = obj->size;
> + base_obj.obj = obj;
> link_base_data(NULL, &base_obj);
>
> if (ref)
> @@ -633,7 +636,8 @@ static int write_compressed(int fd, void *in, unsigned int size, uint32_t *obj_c
> return size;
> }
>
> -static void append_obj_to_pack(const unsigned char *sha1, void *buf,
> +static struct object_entry *append_obj_to_pack(
> + const unsigned char *sha1, void *buf,
> unsigned long size, enum object_type type)
> {
> struct object_entry *obj = &objects[nr_objects++];
> @@ -654,6 +658,7 @@ static void append_obj_to_pack(const unsigned char *sha1, void *buf,
> obj[1].idx.offset = obj[0].idx.offset + n;
> obj[1].idx.offset += write_compressed(output_fd, buf, size, &obj[0].idx.crc32);
> hashcpy(obj->idx.sha1, sha1);
> + return obj;
> }
>
> static int delta_pos_compare(const void *_a, const void *_b)
> @@ -697,6 +702,12 @@ static void fix_unresolved_deltas(int nr_unresolved)
> base_obj.data = read_sha1_file(d->base.sha1, &type, &base_obj.size);
> if (!base_obj.data)
> continue;
> +
> + if (check_sha1_signature(d->base.sha1, base_obj.data,
> + base_obj.size, typename(type)))
> + die("local object %s is corrupt", sha1_to_hex(d->base.sha1));
> + base_obj.obj = append_obj_to_pack(d->base.sha1, base_obj.data,
> + base_obj.size, type);
> link_base_data(NULL, &base_obj);
>
> find_delta_children(&d->base, &first, &last);
> @@ -706,11 +717,6 @@ static void fix_unresolved_deltas(int nr_unresolved)
> resolve_delta(child, &base_obj, type);
> }
>
> - if (check_sha1_signature(d->base.sha1, base_obj.data,
> - base_obj.size, typename(type)))
> - die("local object %s is corrupt", sha1_to_hex(d->base.sha1));
> - append_obj_to_pack(d->base.sha1, base_obj.data,
> - base_obj.size, type);
> unlink_base_data(&base_obj);
> display_progress(progress, nr_resolved_deltas);
> }
> --
> 1.5.6.2.393.g45096
>
Nicolas
^ permalink raw reply
* Re: Closing the merge window for 1.6.0
From: Shawn O. Pearce @ 2008-07-15 2:51 UTC (permalink / raw)
To: Nicolas Pitre
Cc: Gerrit Pape, Johannes Schindelin, Petr Baudis, Junio C Hamano,
git
In-Reply-To: <alpine.LFD.1.10.0807141351540.12484@xanadu.home>
Nicolas Pitre <nico@cam.org> wrote:
> On Mon, 14 Jul 2008, Gerrit Pape wrote:
>
> > On Mon, Jul 14, 2008 at 12:57:56PM +0100, Johannes Schindelin wrote:
> > > On Mon, 14 Jul 2008, Petr Baudis wrote:
> > > > I'm saying this because I believe the best conservative upper bound for
> > > > backwards compatibility is Git version in Debian stable. It gets
> > > > probably the most stale from all the widely used software distributions
> > > > using Git, and it *is* quite widely used. Etch carries v1.4.4.4, which
> > > > fails miserably on the new packs.
>
> Maybe we can release 1.4.5 with the ability to read index v2? That
> wouldn't be hard to backport the reading part of it.
If we consider that supporting 1.4.4.4 clients is still a priority,
due to the widespread distribution of that version in a popular
version of Debian, we shouldn't be rushing the index v2 or OFS_DELTA
functionality on by default in 1.6.0. Instead we would wait until
Debian stable (and most other widely popular distributions) are on
a modern enough version of Git to understand this format.
Really. As much as I'd love to see the switch to v2 made by default
I don't think we can/should do it unless the majority of the user
base will be able to grok it. And Debian etch sounds like it won't.
--
Shawn.
^ permalink raw reply
* git-mergetool + WinMerge
From: chongyc @ 2008-07-15 2:55 UTC (permalink / raw)
To: git
Hi everybody
I am going to merge conflict by using git-mergetool of msysgit(for
windows) and Winmerge.
what shall i do?
Help me
^ permalink raw reply
* Re: [PATCH 4/4] index-pack: Honor core.deltaBaseCacheLimit when resolving deltas
From: Nicolas Pitre @ 2008-07-15 3:05 UTC (permalink / raw)
To: Shawn O. Pearce
Cc: Junio C Hamano, Junio C Hamano, git, Stephan Hennig,
Andreas Ericsson
In-Reply-To: <1216001267-33235-5-git-send-email-spearce@spearce.org>
On Sun, 13 Jul 2008, Shawn O. Pearce wrote:
> If we are trying to resolve deltas for a long delta chain composed
> of multi-megabyte objects we can easily run into requiring 500M+
> of memory to hold each object in the chain on the call stack while
> we recurse into the dependent objects and resolve them.
>
> We now use a simple delta cache that discards objects near the
> bottom of the call stack first, as they are the most least recently
> used objects in this current delta chain. If we recurse out of a
> chain we may find the base object is no longer available, as it was
> free'd to keep memory under the deltaBaseCacheLimit. In such cases
> we must unpack the base object again, which will require recursing
> back to the root of the top of the delta chain as we released that
> root first.
>
> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
OK now I see what the 'base' pointer I previously dismissed is really
needed for.
But this patch is suboptimal as it actually recreate the same memory
pressure, to a lesser degree, this series is meant to solve. If you do:
> + struct object_entry *obj = c->obj;
> + void *raw = get_data_from_pack(obj);
> + if (obj->type == OBJ_REF_DELTA || obj->type == OBJ_OFS_DELTA) {
> + c->data = patch_delta(
> + get_base_data(c->base), c->base->size,
> + raw, obj->size,
> + &c->size);
> + free(raw);
What you actually do is to read the delta data in memory, then recurse
down to read more delta data, then recurse down to read the base which
might be yet more delta data in memory, etc. etc. Only when you reach
the bottom of the stack will you start resolving all those deltas in
memory. Instead, the check for a delta object should be done first, and
if so then recursion for the base object be performed _before_ reading
the currently wanted object data. This way you won't have more than one
delta buffer at any time in memory.
Nicolas
^ permalink raw reply
* Re: [PATCH 0/4] Honor core.deltaBaseCacheLimit during index-pack
From: Nicolas Pitre @ 2008-07-15 3:06 UTC (permalink / raw)
To: Shawn O. Pearce
Cc: Andreas Ericsson, Johannes Schindelin, Jakub Narebski,
Junio C Hamano, git, Stephan Hennig
In-Reply-To: <20080715024741.GB1700@spearce.org>
On Tue, 15 Jul 2008, Shawn O. Pearce wrote:
> Nicolas Pitre <nico@cam.org> wrote:
> >
> > Those delta chains aren't simple chained lists. They are trees of
> > deltas where one object might be the base for an unlimited number of
> > deltas of depth 1, and in turn each of those deltas might constitute the
> > base for an unlimited number of deltas of depth 2, and so on.
> >
> > So what the code does is to find out which objects are not deltas but
> > are the base for a delta. Then, for each of them, all deltas having
> > given object for base are found and they are recursively resolved so
> > each resolved delta is then considered a possible base for more deltas,
> > etc. In other words, those deltas are resolved by walking the delta
> > tree in a "depth first" fashion.
> >
> > If we discard previous delta bases, we will have to recreate them each
> > time a delta sibling is processed. And if those delta bases are
> > themselves deltas then you have an explosion of delta results to
> > re-compute.
>
> Yes, it would be horrible if we had to recompute 10 deltas in order
> to recover a previously discarded delta base in order to visit new
> siblings.
>
> But its even more horrible that we use 512M of memory in our working
> set size on a 256M machine to process a pack that is only 300M in
> size, due to long delta chains on large objects. In such a case
> the system will swap and perform fairly poorly due to the huge disk
> IO necessary to keep moving the working set around.
>
> We're better off keeping our memory usage low and recomputing
> the delta base when we need to return to it to process a sibling.
Please relax! ;-)
And have a look in your mbox.
Nicolas
^ permalink raw reply
* Re: Closing the merge window for 1.6.0
From: Martin Langhoff @ 2008-07-15 3:14 UTC (permalink / raw)
To: Teemu Likonen
Cc: Junio C Hamano, Nicolas Pitre, Gerrit Pape, Johannes Schindelin,
Petr Baudis, git
In-Reply-To: <20080714191903.GB5788@mithlond.arda.local>
On Tue, Jul 15, 2008 at 7:19 AM, Teemu Likonen <tlikonen@iki.fi> wrote:
>> But as the upstream, we have our own deprecation schedule.
>
> As Debian stable (4.0 "Etch") and its git 1.4.4.4 was mentioned I'd like
> to point out that git 1.5.6 is available for Etch users from
> kind-of-semi-official <www.backports.org>. So I guess Debian stable
> users aren't left completely behind. Git's web page already advertises
> backports.org version for Etch.
I concur. Users of git on Etch are using backports AFAIK.
We still have the case of the "casual" user, who does not know much
about git, but installs it to clone & review a project's code. There,
if v1.4.4 complains with a useful message, the casual user will swear
a bit and grab a backport. If it dies a horrible uninformative death,
then we will get bogus bug reports, flamage, the works.
cheers,
m
--
martin.langhoff@gmail.com
martin@laptop.org -- School Server Architect
- ask interesting questions
- don't get distracted with shiny stuff - working code first
- http://wiki.laptop.org/go/User:Martinlanghoff
^ permalink raw reply
* Re: [PATCH] git-mailinfo: Fix getting the subject from the body
From: Don Zickus @ 2008-07-15 3:13 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Lukas Sandström, Git Mailing List
In-Reply-To: <7v3amfxx3a.fsf@gitster.siamese.dyndns.org>
On Sat, Jul 12, 2008 at 02:36:57AM -0700, Junio C Hamano wrote:
> Another thing I noticed and found puzzling is the handling of ">From "
> line that is shown in the context below. check_header() is supposed to
> return true when it handled header (i.e. not part of the commit message)
> and return false when line is not part of the header. As ">From " is part
> of the commit log message, shouldn't it return zero?
>
> Don, this part was what you introduced. Has this codepath ever been
> exercised in the real life?
Heh. Most emails I deal with usually wind up causing the code to stop
looking for header info (still_looking=0). So I never ran into that
scenario. And I never really tried to rely on inbody stuff.
I thought I was mimicing the original code, guess not.
Now that I think about it, I did run into a situation last year where
git-mailinfo parsed the '>From' as an inbody header instead of a commit
msg. I just put a stupid hack in my scripts to work around, thinking it
was my scripts.
Anyway if it returns zero, wouldn't it be better to just remove the check
to begin with? I kinda forgot why it is there in the first place (my
changes just copied it from somewhere else).
Cheers,
Don
^ permalink raw reply
* Re: [PATCH 4/4] index-pack: Honor core.deltaBaseCacheLimit when resolving deltas
From: Shawn O. Pearce @ 2008-07-15 3:18 UTC (permalink / raw)
To: Nicolas Pitre; +Cc: Junio C Hamano, git, Stephan Hennig, Andreas Ericsson
In-Reply-To: <alpine.LFD.1.10.0807142255240.12484@xanadu.home>
Nicolas Pitre <nico@cam.org> wrote:
> On Sun, 13 Jul 2008, Shawn O. Pearce wrote:
>
> But this patch is suboptimal as it actually recreate the same memory
> pressure, to a lesser degree, this series is meant to solve. If you do:
Arrgh. Good catch on review. I'll post a replacement patch shortly
that doesn't suffer from this problem. Thanks!
> > + struct object_entry *obj = c->obj;
> > + void *raw = get_data_from_pack(obj);
> > + if (obj->type == OBJ_REF_DELTA || obj->type == OBJ_OFS_DELTA) {
> > + c->data = patch_delta(
> > + get_base_data(c->base), c->base->size,
> > + raw, obj->size,
> > + &c->size);
> > + free(raw);
--
Shawn.
^ permalink raw reply
* Re: [PATCH 3/4] index-pack: Track the object_entry that creates each base_data
From: Shawn O. Pearce @ 2008-07-15 3:20 UTC (permalink / raw)
To: Nicolas Pitre; +Cc: Junio C Hamano, git, Stephan Hennig, Andreas Ericsson
In-Reply-To: <alpine.LFD.1.10.0807142249100.12484@xanadu.home>
Nicolas Pitre <nico@cam.org> wrote:
> On Sun, 13 Jul 2008, Shawn O. Pearce wrote:
>
> > If we free the data stored within a base_data we need the struct
> > object_entry to get the data back again for use with another
> > dependent delta. Storing the object_entry* makes it simple to call
> > get_data_from_pack() to recover the compressed information.
> >
> > This however means we must add the missing baes object to the end
>
> Typo?
Yea, Dscho also pointed it out.
Junio, if you can, please fix this typo in the commit message.
Its not really a big deal. I have no plans on posting a replacement
patch just for this one small typo. Plenty of my current commits
in git.git have typos too. I'm not that good of a typist. And gcc
doesn't check my commit messages. ;-)
--
Shawn.
^ permalink raw reply
* Re: Closing the merge window for 1.6.0
From: Nicolas Pitre @ 2008-07-15 3:30 UTC (permalink / raw)
To: Shawn O. Pearce
Cc: Gerrit Pape, Johannes Schindelin, Petr Baudis, Junio C Hamano,
git
In-Reply-To: <20080715025127.GC1700@spearce.org>
On Tue, 15 Jul 2008, Shawn O. Pearce wrote:
> Nicolas Pitre <nico@cam.org> wrote:
> > On Mon, 14 Jul 2008, Gerrit Pape wrote:
> >
> > > On Mon, Jul 14, 2008 at 12:57:56PM +0100, Johannes Schindelin wrote:
> > > > On Mon, 14 Jul 2008, Petr Baudis wrote:
> > > > > I'm saying this because I believe the best conservative upper bound for
> > > > > backwards compatibility is Git version in Debian stable. It gets
> > > > > probably the most stale from all the widely used software distributions
> > > > > using Git, and it *is* quite widely used. Etch carries v1.4.4.4, which
> > > > > fails miserably on the new packs.
> >
> > Maybe we can release 1.4.5 with the ability to read index v2? That
> > wouldn't be hard to backport the reading part of it.
>
> If we consider that supporting 1.4.4.4 clients is still a priority,
> due to the widespread distribution of that version in a popular
> version of Debian, we shouldn't be rushing the index v2 or OFS_DELTA
> functionality on by default in 1.6.0.
OFS_DELTA is supported by 1.4.4.4 so that's a non issue.
> Instead we would wait until Debian stable (and most other widely
> popular distributions) are on a modern enough version of Git to
> understand this format.
I don't think we should have git development be dictated by some
discutable policy from one distribution.
IMHO git prior 1.5.0 is so horrible as general usability goes, and so
different from what everybody is discussing on the net, that no one sane
should still be using it. Even ourselves (i.e. the git community) are
not supporting git 1.4.4 anymore so this hardly can be a priority.
As far as I know, there is no other widely popular distribution other
than Debian using git prior 1.5.0 in their latest release. If Debian
people want to support git 1.4.4 although we called thatversion obsolete
_long_ ago then that's their problem. We should not be bound by that
external policy to which we never agreed with.
Now I proposed a compromise which consists of making 1.4.4.4+1 able to
cope with index v2. That should fall into Debian's "major usability
fix" category. I think that is a far better compromize than delaying
index v2 even further.
> Really. As much as I'd love to see the switch to v2 made by default
> I don't think we can/should do it unless the majority of the user
> base will be able to grok it. And Debian etch sounds like it won't.
I truly hope the majority of the user is _not_ using 1.4.4.4. Otherwise
I may only have pity for them.
Nicolas
^ permalink raw reply
* Re: What's cooking in git.git (topics)
From: Geoffrey Irving @ 2008-07-15 3:38 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Johannes Schindelin
In-Reply-To: <7vtzetjbif.fsf@gitster.siamese.dyndns.org>
On Sun, Jul 13, 2008 at 10:11 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Here are the topics that have been cooking. Commits prefixed
> with '-' are only in 'pu' while commits prefixed with '+' are
> in 'next'.
>
> <snip>
>
> * gi/cherry-cache (Sat Jul 12 20:14:51 2008 -0700) 1 commit
> - cherry: cache patch-ids to avoid repeating work
>
> This does not seem to pass tests even on its own.
The problem (beyond the basic problem of me not having tried running
the tests) is that the current caching code isn't taking into account
the changing values of diff_options. t6007 computes a patch-id for a
commit with one value of options.paths, and then tries to compute a
_different_ patch-id for the same commit using a different value of
options.paths.
Here are a few different ways of fixing this:
1. Modify commit_patch_id in patch-ids.c to compute a sha1 of the
diff_options structure and xor it with the commit sha1 to get a truly
unique hash of the input. This means the optimization can be safely
applied for all patch-id computations regardless of the diff_options.
I can add a diff_options_sha1 function in diff.[ch] to compute the
checksum.
2. Restrict commit_patch_id in patch-ids.c to apply the optimization
only if options.nr_paths is zero, and perhaps a few other conditions.
This is rather fragile, since it would mean that the cache would break
if someone decided to change the default diff options.
3. Add a flag in struct patch_ids defaulting to false which turns the
caching on or off, and manually set the flag to true in cmd_cherry.
I'd lean towards (1), but wanted to check before writing the code to
make sure that it's reasonable to treat diff_options as stable enough
that computing a sha1 hash of it makes sense. According to "git help
patch-id", it is only "reasonable stable", which is sufficient as long
as we're confident that whenever the diff format changes, the
diff_options_sha1 function will be updated to reflect that change.
As an aside: is it correct that as long as the change is in pu, I
should be submitting complete (nonincremental) patches whenever I fix
bugs?
Thanks,
Geoffrey
^ permalink raw reply
* Re: [PATCH 3/4] index-pack: Track the object_entry that creates each base_data
From: Nicolas Pitre @ 2008-07-15 3:42 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: Junio C Hamano, git, Stephan Hennig, Andreas Ericsson
In-Reply-To: <20080715032008.GE1700@spearce.org>
On Tue, 15 Jul 2008, Shawn O. Pearce wrote:
> Nicolas Pitre <nico@cam.org> wrote:
> > On Sun, 13 Jul 2008, Shawn O. Pearce wrote:
> >
> > > If we free the data stored within a base_data we need the struct
> > > object_entry to get the data back again for use with another
> > > dependent delta. Storing the object_entry* makes it simple to call
> > > get_data_from_pack() to recover the compressed information.
> > >
> > > This however means we must add the missing baes object to the end
> >
> > Typo?
>
> Yea, Dscho also pointed it out.
>
> Junio, if you can, please fix this typo in the commit message.
>
> Its not really a big deal. I have no plans on posting a replacement
> patch just for this one small typo.
No, it is not a big deal. I do write crappy english myself. I
initially had some comments on the patch itself which whould have
warranted another patch and then changed my mind.
Nicolas
^ permalink raw reply
* Re: [PATCH 0/4] Honor core.deltaBaseCacheLimit during index-pack
From: Shawn O. Pearce @ 2008-07-15 4:19 UTC (permalink / raw)
To: Jakub Narebski
Cc: Johannes Schindelin, Nicolas Pitre, Junio C Hamano, git,
Stephan Hennig, Andreas Ericsson
In-Reply-To: <m31w1wu1hc.fsf@localhost.localdomain>
Jakub Narebski <jnareb@gmail.com> wrote:
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> > On Mon, 14 Jul 2008, Shawn O. Pearce wrote:
>
> > > The only other alternative I can come up with is to change pack-objects
> > > (or at least its defaults) so we don't generate these massive delta
> > > chains. But there are already packs in the wild that use these chains,
> > > resulting in performance problems for clients.
> >
> > But the long chains make the pack actually as efficient as it is...
>
> Perhaps Shawn thought here about limiting delta chain not by its
> *length*, but by its *size* (as required when unpacking last object
> in a delta chanin).
>
> What do you think about this idea?
I was talking about that. Or at least thinking it. But its not a
good solution, as Dscho points out those long chains is what makes
the pack file such a powerful source code compressor.
IMHO the right solution is to continue to allow these long chains,
especially since they are typically used for the older, less often
accessed objects, and use bounded caching where necessary in the
readers to avoid unpacking costs. We already have a bounded cache
for the random access case used by most programs. What we missed
was the bounded cache in index-pack, and my 4 patch series is an
attempt to define that.
--
Shawn.
^ permalink raw reply
* Re: [PATCH] git-svn: find-rev and rebase for SVN::Mirror repositories
From: Eric Wong @ 2008-07-15 4:25 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, João Abecasis
In-Reply-To: <7bf6f1d20807140828ve04bc16u96d0245209491b2e@mail.gmail.com>
João Abecasis <joao@abecasis.name> wrote:
> find-rev and rebase error out on svm because git-svn doesn't trace the
> original svn revision numbers back to git commits. The updated test
> case, included in the patch, shows the issue and passes with the rest of
> the patch applied.
>
> This fixes Git::SVN::find_by_url to find branches based on the
> svm:source URL, where useSvmProps is set. Also makes sure cmd_find_rev
> and working_head_info use the information they have to correctly track
> the source repository. This is enough to get find-rev and rebase
> working.
>
> Signed-off-by: João Abecasis <joao@abecasis.name>
Thanks João,
Acked-by: Eric Wong <normalperson@yhbt.net>
> ---
> git-svn.perl | 39 ++++++++++++++++++++++++++++++++++---
> t/t9110-git-svn-use-svm-props.sh | 9 ++++++++
> 2 files changed, 44 insertions(+), 4 deletions(-)
>
> diff --git a/git-svn.perl b/git-svn.perl
> index a366c89..0aa994a 100755
> --- a/git-svn.perl
> +++ b/git-svn.perl
> @@ -537,13 +537,13 @@ sub cmd_find_rev {
> my $head = shift;
> $head ||= 'HEAD';
> my @refs;
> - my (undef, undef, undef, $gs) = working_head_info($head, \@refs);
> + my (undef, undef, $uuid, $gs) = working_head_info($head, \@refs);
> unless ($gs) {
> die "Unable to determine upstream SVN information from ",
> "$head history\n";
> }
> my $desired_revision = substr($revision_or_hash, 1);
> - $result = $gs->rev_map_get($desired_revision);
> + $result = $gs->rev_map_get($desired_revision, $uuid);
> } else {
> my (undef, $rev, undef) = cmt_metadata($revision_or_hash);
> $result = $rev;
> @@ -1162,7 +1162,7 @@ sub working_head_info {
> if (defined $url && defined $rev) {
> next if $max{$url} and $max{$url} < $rev;
> if (my $gs = Git::SVN->find_by_url($url)) {
> - my $c = $gs->rev_map_get($rev);
> + my $c = $gs->rev_map_get($rev, $uuid);
> if ($c && $c eq $hash) {
> close $fh; # break the pipe
> return ($url, $rev, $uuid, $gs);
> @@ -1416,11 +1416,17 @@ sub fetch_all {
>
> sub read_all_remotes {
> my $r = {};
> + my $use_svm_props = eval { command_oneline(qw/config --bool
> + svn.useSvmProps/) };
> + $use_svm_props = $use_svm_props eq 'true' if $use_svm_props;
> foreach (grep { s/^svn-remote\.// } command(qw/config -l/)) {
> if (m!^(.+)\.fetch=\s*(.*)\s*:\s*refs/remotes/(.+)\s*$!) {
> my ($remote, $local_ref, $remote_ref) = ($1, $2, $3);
> $local_ref =~ s{^/}{};
> $r->{$remote}->{fetch}->{$local_ref} = $remote_ref;
> + $r->{$remote}->{svm} = {} if $use_svm_props;
> + } elsif (m!^(.+)\.usesvmprops=\s*(.*)\s*$!) {
> + $r->{$1}->{svm} = {};
> } elsif (m!^(.+)\.url=\s*(.*)\s*$!) {
> $r->{$1}->{url} = $2;
> } elsif (m!^(.+)\.(branches|tags)=
> @@ -1437,6 +1443,23 @@ sub read_all_remotes {
> }
> }
> }
> +
> + map {
> + if (defined $r->{$_}->{svm}) {
> + my $svm;
> + eval {
> + my $section = "svn-remote.$_";
> + $svm = {
> + source => tmp_config('--get',
> + "$section.svm-source"),
> + replace => tmp_config('--get',
> + "$section.svm-replace"),
> + }
> + };
> + $r->{$_}->{svm} = $svm;
> + }
> + } keys %$r;
> +
> $r;
> }
>
> @@ -1563,13 +1586,21 @@ sub find_by_url { # repos_root and, path are optional
> }
> my $p = $path;
> my $rwr = rewrite_root({repo_id => $repo_id});
> + my $svm = $remotes->{$repo_id}->{svm}
> + if defined $remotes->{$repo_id}->{svm};
> unless (defined $p) {
> $p = $full_url;
> my $z = $u;
> + my $prefix = '';
> if ($rwr) {
> $z = $rwr;
> + } elsif (defined $svm) {
> + $z = $svm->{source};
> + $prefix = $svm->{replace};
> + $prefix =~ s#^\Q$u\E(?:/|$)##;
> + $prefix =~ s#/$##;
> }
> - $p =~ s#^\Q$z\E(?:/|$)## or next;
> + $p =~ s#^\Q$z\E(?:/|$)#$prefix# or next;
> }
> foreach my $f (keys %$fetch) {
> next if $f ne $p;
> diff --git a/t/t9110-git-svn-use-svm-props.sh b/t/t9110-git-svn-use-svm-props.sh
> index 047659f..04d2a65 100755
> --- a/t/t9110-git-svn-use-svm-props.sh
> +++ b/t/t9110-git-svn-use-svm-props.sh
> @@ -49,4 +49,13 @@ test_expect_success 'verify metadata for /dir' "
> grep '^git-svn-id: $dir_url@1 $uuid$'
> "
>
> +test_expect_success 'find commit based on SVN revision number' "
> + git-svn find-rev r12 |
> + grep `git rev-parse HEAD`
> + "
> +
> +test_expect_success 'empty rebase' "
> + git-svn rebase
> + "
> +
> test_done
> --
> 1.5.6
^ permalink raw reply
* Re: [PATCH] bash completion: Fix the . -> .. revision range completion
From: Shawn O. Pearce @ 2008-07-15 4:25 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Junio C Hamano, Petr Baudis, git
In-Reply-To: <alpine.LFD.1.10.0807140741580.3305@woody.linux-foundation.org>
Linus Torvalds <torvalds@linux-foundation.org> wrote:
> On Mon, 14 Jul 2008, Shawn O. Pearce wrote:
> >
> > What is $COMP_WORDBREAKS set to in your shell? In mine it
> > appears to be:
> >
> > " \"'@><=;|&(:"
>
> Ahhah. Indeed. I don't have the ':'.
...
> Umm, if so, git should just set it in the completion script, no?
OK, so it turns out not having : in COMP_WORDBREAKS is a very common
case that we should somehow deal with, to aid our users.
I'm concerned about just setting COMP_WORDBREAKS back to the default
in the git completion script because then we get into an ordering
game with the profile scripts, don't we? If git completion sources
before the gvfs script we don't get our COMP_WORDBREAKS setting.
I think we may need to do two things.
If COMP_WORDBREAKS doesn't contain a :, try to reset it to include
one when the script is sourced. This may "fix" git completion but
make gvfs completion act differently, resulting in a thread on the
gvfs lists. ;-)
If COMP_WORDBREAKS doesn't contain : during a completion event than
we need to do what your original patch asked, which is to include
"$ref:" in the prefix, so the ref isn't lost.
At least we understand the problem now, finally. I'll try to write
up a patch for it tomorrow. Unfortunately packing to move has been
really sucking up my time lately.
--
Shawn.
^ permalink raw reply
* Re: [PATCH] bash: Add long option completion for 'git send-email'
From: Shawn O. Pearce @ 2008-07-15 4:38 UTC (permalink / raw)
To: Teemu Likonen; +Cc: git, gitster
In-Reply-To: <1216023662-9109-1-git-send-email-tlikonen@iki.fi>
Teemu Likonen <tlikonen@iki.fi> wrote:
> Add the following long options to be completed with 'git send-email':
...
> Short ones like --to and --cc are not usable for actual completion
I agree, these are worth including.
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index d268e6f..b15f3a9 100755
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -905,6 +905,24 @@ _git_rebase ()
> __gitcomp "$(__git_refs)"
> }
>
> +_git_send_email ()
> +{
> + local cur="${COMP_WORDS[COMP_CWORD]}"
> + case "$cur" in
> + --*)
> + __gitcomp "--bcc --cc --cc-cmd --chain-reply-to --compose
> + --dry-run --envelope-sender --from --identity
> + --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
> + --no-suppress-from --no-thread --quiet
> + --signed-off-by-cc --smtp-pass --smtp-server
> + --smtp-server-port --smtp-ssl --smtp-user --subject
> + --suppress-cc --suppress-from --thread --to"
> + return
> + ;;
> + esac
> + __git_complete_file
Don't use __git_complete_file here. As far as I remember,
git-send-email does not accept "origin/maint:some.patch"
as an email to extract from Git prior to sending. It looks
for files in the local filesystem. So you want standard bash
completion for anything not starting with --.
Just use COMPREPLY=() at the end. See _git_am for an example.
> @@ -1435,6 +1454,7 @@ complete -o default -o nospace -F _git_rebase git-rebase
> complete -o default -o nospace -F _git_config git-config
> complete -o default -o nospace -F _git_remote git-remote
> complete -o default -o nospace -F _git_reset git-reset
> +complete -o default -o nospace -F _git_send_email git-send-email
> complete -o default -o nospace -F _git_shortlog git-shortlog
> complete -o default -o nospace -F _git_show git-show
> complete -o default -o nospace -F _git_stash git-stash
Hmm. With dash form commands gone in 1.6 we should remove these.
But I suspect this completion patch could be shipped in the next
1.5.6 maint release as its really quite trivial. Junio, any comment
on that?
--
Shawn.
^ permalink raw reply
* [PATCH v2] index-pack: Honor core.deltaBaseCacheLimit when resolving deltas
From: Shawn O. Pearce @ 2008-07-15 4:45 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Nicolas Pitre, Stephan Hennig, Andreas Ericsson
In-Reply-To: <20080715031800.GD1700@spearce.org>
If we are trying to resolve deltas for a long delta chain composed
of multi-megabyte objects we can easily run into requiring 500M+
of memory to hold each object in the chain on the call stack while
we recurse into the dependent objects and resolve them.
We now use a simple delta cache that discards objects near the
bottom of the call stack first, as they are the most least recently
used objects in this current delta chain. If we recurse out of a
chain we may find the base object is no longer available, as it was
free'd to keep memory under the deltaBaseCacheLimit. In such cases
we must unpack the base object again, which will require recursing
back to the root of the top of the delta chain as we released that
root first.
The astute reader will probably realize that we can still exceed
the delta base cache limit, but this happens only if the most
recent base plus the delta plus the inflated dependent sum up to
more than the base cache limit. Due to the way patch_delta is
currently implemented we cannot operate in less memory anyway.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
Version 2 plugs the case Nico noticed, where the patch was causing
the exact behavior it was trying to prevent while recovering from
what it did to avoid the excessive memory usage in the first place.
The change was in get_base_data() where we now unpack the delta
after we have unpacked the base. Nico and I both missed that we
must also bump base_cache_used when we restore the base, and we
must also prune the bases in case this base has caused us to go
over the limit.
:-)
index-pack.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 46 insertions(+), 2 deletions(-)
diff --git a/index-pack.c b/index-pack.c
index 7239e89..b4ec736 100644
--- a/index-pack.c
+++ b/index-pack.c
@@ -52,6 +52,7 @@ struct delta_entry
static struct object_entry *objects;
static struct delta_entry *deltas;
static struct base_data *base_cache;
+static size_t base_cache_used;
static int nr_objects;
static int nr_deltas;
static int nr_resolved_deltas;
@@ -220,6 +221,20 @@ static void bad_object(unsigned long offset, const char *format, ...)
die("pack has bad object at offset %lu: %s", offset, buf);
}
+static void prune_base_data(struct base_data *retain)
+{
+ struct base_data *b = base_cache;
+ for (b = base_cache;
+ base_cache_used > delta_base_cache_limit && b;
+ b = b->child) {
+ if (b->data && b != retain) {
+ free(b->data);
+ b->data = NULL;
+ base_cache_used -= b->size;
+ }
+ }
+}
+
static void link_base_data(struct base_data *base, struct base_data *c)
{
if (base)
@@ -229,6 +244,8 @@ static void link_base_data(struct base_data *base, struct base_data *c)
c->base = base;
c->child = NULL;
+ base_cache_used += c->size;
+ prune_base_data(c);
}
static void unlink_base_data(struct base_data *c)
@@ -238,7 +255,10 @@ static void unlink_base_data(struct base_data *c)
base->child = NULL;
else
base_cache = NULL;
- free(c->data);
+ if (c->data) {
+ free(c->data);
+ base_cache_used -= c->size;
+ }
}
static void *unpack_entry_data(unsigned long offset, unsigned long size)
@@ -456,6 +476,30 @@ static void sha1_object(const void *data, unsigned long size,
}
}
+static void *get_base_data(struct base_data *c)
+{
+ if (!c->data) {
+ struct object_entry *obj = c->obj;
+
+ if (obj->type == OBJ_REF_DELTA || obj->type == OBJ_OFS_DELTA) {
+ void *base = get_base_data(c->base);
+ void *raw = get_data_from_pack(obj);
+ c->data = patch_delta(
+ base, c->base->size,
+ raw, obj->size,
+ &c->size);
+ free(raw);
+ if (!c->data)
+ bad_object(obj->idx.offset, "failed to apply delta");
+ } else
+ c->data = get_data_from_pack(obj);
+
+ base_cache_used += c->size;
+ prune_base_data(c);
+ }
+ return c->data;
+}
+
static void resolve_delta(struct object_entry *delta_obj,
struct base_data *base_obj, enum object_type type)
{
@@ -468,7 +512,7 @@ static void resolve_delta(struct object_entry *delta_obj,
delta_obj->real_type = type;
delta_data = get_data_from_pack(delta_obj);
delta_size = delta_obj->size;
- result.data = patch_delta(base_obj->data, base_obj->size,
+ result.data = patch_delta(get_base_data(base_obj), base_obj->size,
delta_data, delta_size,
&result.size);
free(delta_data);
--
1.5.6.2.393.g45096
^ permalink raw reply related
* Re: [PATCH] bash: Add long option completion for 'git send-email'
From: Junio C Hamano @ 2008-07-15 4:49 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: Teemu Likonen, git
In-Reply-To: <20080715043839.GE2432@spearce.org>
"Shawn O. Pearce" <spearce@spearce.org> writes:
> Hmm. With dash form commands gone in 1.6 we should remove these.
>
> But I suspect this completion patch could be shipped in the next
> 1.5.6 maint release as its really quite trivial. Junio, any comment
> on that?
Yeah, it is trivial but does it deserve "bugfix -- we need to deliver this
change to the end users, otherwise they will suffer" label? Probably not.
^ permalink raw reply
* Re: [PATCH] bash: Add long option completion for 'git send-email'
From: Shawn O. Pearce @ 2008-07-15 4:58 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Teemu Likonen, git
In-Reply-To: <7vmykjda5i.fsf@gitster.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> wrote:
> "Shawn O. Pearce" <spearce@spearce.org> writes:
>
> > Hmm. With dash form commands gone in 1.6 we should remove these.
> >
> > But I suspect this completion patch could be shipped in the next
> > 1.5.6 maint release as its really quite trivial. Junio, any comment
> > on that?
>
> Yeah, it is trivial but does it deserve "bugfix -- we need to deliver this
> change to the end users, otherwise they will suffer" label? Probably not.
Not really, but we have shipped new completion functionality (missing
--graph option to git-log) in maint releases in recent history.
If it was me maintaining git.git, I'd probably toss this into maint.
But I think I have a more aggressive personality than you, and am
more willing to take a risk. Users frequently don't like such risk.
I defer to your wise judgement. Given prior statements about what
goes where, you are being consistent to say this should go in 1.6.
In which case I suggest Teemu should drop that last hunk as we
should really drop that entire block of code from the script.
--
Shawn.
^ permalink raw reply
* Re: [PATCH v2] index-pack: Honor core.deltaBaseCacheLimit when resolving deltas
From: Nicolas Pitre @ 2008-07-15 5:05 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: Junio C Hamano, git, Stephan Hennig, Andreas Ericsson
In-Reply-To: <20080715044534.GA2794@spearce.org>
On Tue, 15 Jul 2008, Shawn O. Pearce wrote:
> If we are trying to resolve deltas for a long delta chain composed
> of multi-megabyte objects we can easily run into requiring 500M+
> of memory to hold each object in the chain on the call stack while
> we recurse into the dependent objects and resolve them.
>
> We now use a simple delta cache that discards objects near the
> bottom of the call stack first, as they are the most least recently
> used objects in this current delta chain. If we recurse out of a
> chain we may find the base object is no longer available, as it was
> free'd to keep memory under the deltaBaseCacheLimit. In such cases
> we must unpack the base object again, which will require recursing
> back to the root of the top of the delta chain as we released that
> root first.
>
> The astute reader will probably realize that we can still exceed
> the delta base cache limit, but this happens only if the most
> recent base plus the delta plus the inflated dependent sum up to
> more than the base cache limit. Due to the way patch_delta is
> currently implemented we cannot operate in less memory anyway.
You may also set the limit lower than the size of the largest object
which is going to bust it too. Same goes for the cache in sha1_file.c.
There is simply a limit to how tight we can sanely make memory usage.
> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
ACK
> ---
>
> Version 2 plugs the case Nico noticed, where the patch was causing
> the exact behavior it was trying to prevent while recovering from
> what it did to avoid the excessive memory usage in the first place.
>
> The change was in get_base_data() where we now unpack the delta
> after we have unpacked the base. Nico and I both missed that we
> must also bump base_cache_used when we restore the base, and we
> must also prune the bases in case this base has caused us to go
> over the limit.
>
> :-)
>
> index-pack.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++--
> 1 files changed, 46 insertions(+), 2 deletions(-)
>
> diff --git a/index-pack.c b/index-pack.c
> index 7239e89..b4ec736 100644
> --- a/index-pack.c
> +++ b/index-pack.c
> @@ -52,6 +52,7 @@ struct delta_entry
> static struct object_entry *objects;
> static struct delta_entry *deltas;
> static struct base_data *base_cache;
> +static size_t base_cache_used;
> static int nr_objects;
> static int nr_deltas;
> static int nr_resolved_deltas;
> @@ -220,6 +221,20 @@ static void bad_object(unsigned long offset, const char *format, ...)
> die("pack has bad object at offset %lu: %s", offset, buf);
> }
>
> +static void prune_base_data(struct base_data *retain)
> +{
> + struct base_data *b = base_cache;
> + for (b = base_cache;
> + base_cache_used > delta_base_cache_limit && b;
> + b = b->child) {
> + if (b->data && b != retain) {
> + free(b->data);
> + b->data = NULL;
> + base_cache_used -= b->size;
> + }
> + }
> +}
> +
> static void link_base_data(struct base_data *base, struct base_data *c)
> {
> if (base)
> @@ -229,6 +244,8 @@ static void link_base_data(struct base_data *base, struct base_data *c)
>
> c->base = base;
> c->child = NULL;
> + base_cache_used += c->size;
> + prune_base_data(c);
> }
>
> static void unlink_base_data(struct base_data *c)
> @@ -238,7 +255,10 @@ static void unlink_base_data(struct base_data *c)
> base->child = NULL;
> else
> base_cache = NULL;
> - free(c->data);
> + if (c->data) {
> + free(c->data);
> + base_cache_used -= c->size;
> + }
> }
>
> static void *unpack_entry_data(unsigned long offset, unsigned long size)
> @@ -456,6 +476,30 @@ static void sha1_object(const void *data, unsigned long size,
> }
> }
>
> +static void *get_base_data(struct base_data *c)
> +{
> + if (!c->data) {
> + struct object_entry *obj = c->obj;
> +
> + if (obj->type == OBJ_REF_DELTA || obj->type == OBJ_OFS_DELTA) {
> + void *base = get_base_data(c->base);
> + void *raw = get_data_from_pack(obj);
> + c->data = patch_delta(
> + base, c->base->size,
> + raw, obj->size,
> + &c->size);
> + free(raw);
> + if (!c->data)
> + bad_object(obj->idx.offset, "failed to apply delta");
> + } else
> + c->data = get_data_from_pack(obj);
> +
> + base_cache_used += c->size;
> + prune_base_data(c);
> + }
> + return c->data;
> +}
> +
> static void resolve_delta(struct object_entry *delta_obj,
> struct base_data *base_obj, enum object_type type)
> {
> @@ -468,7 +512,7 @@ static void resolve_delta(struct object_entry *delta_obj,
> delta_obj->real_type = type;
> delta_data = get_data_from_pack(delta_obj);
> delta_size = delta_obj->size;
> - result.data = patch_delta(base_obj->data, base_obj->size,
> + result.data = patch_delta(get_base_data(base_obj), base_obj->size,
> delta_data, delta_size,
> &result.size);
> free(delta_data);
> --
> 1.5.6.2.393.g45096
>
Nicolas
^ permalink raw reply
* unpack_entry (was: [BUG] commit walk machinery is dangerous !)
From: Shawn O. Pearce @ 2008-07-15 5:10 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Nicolas Pitre, git
In-Reply-To: <7vod50dote.fsf@gitster.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> wrote:
> This is unrelated to the issue at hand, but I also notice that there are
> few callsites outside sha1_file.c that bypasses cache_or_unpack_entry()
> and call unpack_entry() directly. I wonder if they should be using the
> cached version, making unpack_entry() static...
There are two such callsites that I found:
$ git grep -n --cached unpack_entry
fast-import.c:1201: return unpack_entry(p, oe->offset, &type, sizep);
pack-check.c:114: data = unpack_entry(p, entries[i].offset, &type,
Now the one in fast-import.c could be using the cached version.
This is simply fast-import trying to reuse sha1_file.c for reading
a previously written object to the pack.
Stuffing the item into the cache is perhaps pointless here as gfi
does its own sort of caching and only goes through this code path
when that caching has tossed the least-recently-used data and its
suddenly needed again.
So yea, it could be using the caching form, but it would maybe be
doing more work (and using more memory) than it really needs.
In pack-check.c we are looping through the objects in the order they
appear in the index so we can unpack them and verify each object's
SHA-1 signature. Please note this is perhaps the slowest way to
enumerate through the pack and is why you can clone a repository
over git:// faster than you can run `fsck --full`.
If you really want to verify every single object's SHA-1, run the
damn pack through index-pack and compare the new index to the old
index (hint they should be identical, bit-for-bit).
So again, in this case the caching may only cause us to do more
work (and use more memory) than we need as we are slamming the
delta base cache with all sorts of unrelated base objects. It
probably has a low hit ratio anyway during this loop. :-|
--
Shawn.
^ permalink raw reply
* Re: [PATCH 1/2] restore legacy behavior for read_sha1_file()
From: Nicolas Pitre @ 2008-07-15 5:12 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <alpine.LFD.1.10.0807142134450.12484@xanadu.home>
On Mon, 14 Jul 2008, Nicolas Pitre wrote:
> Since commit 8eca0b47ff1598a6d163df9358c0e0c9bd92d4c8, it is possible
> for read_sha1_file() to return NULL even with existing objects when they
> are corrupted. Previously a corrupted object would have terminated the
> program immediately, effectively making read_sha1_file() return NULL
> only when specified object is not found.
>
> Let's restore this behavior for all users of read_sha1_file() and
> provide a separate function with the ability to not terminate when
> bad objects are encountered.
>
> Signed-off-by: Nicolas Pitre <nico@cam.org>
Grrrr. Forgot to 'git add' one file. So this goes with the same
commit:
diff --git a/cache.h b/cache.h
index 4a8b125..bc52af6 100644
--- a/cache.h
+++ b/cache.h
@@ -540,6 +540,9 @@ extern int write_sha1_file(void *buf, unsigned long len, const char *type, unsig
extern int pretend_sha1_file(void *, unsigned long, enum object_type, unsigned char *);
extern int force_object_loose(const unsigned char *sha1, time_t mtime);
+/* just like read_sha1_file(), but non fatal in presence of bad objects */
+extern void *read_object(const unsigned char *sha1, enum object_type *type, unsigned long *size);
+
extern int check_sha1_signature(const unsigned char *sha1, void *buf, unsigned long size, const char *type);
extern int move_temp_to_file(const char *tmpfile, const char *filename);
^ permalink raw reply related
* [PATCH] bash completion: Resolve git show ref:path<tab> losing ref: portion
From: Shawn O. Pearce @ 2008-07-15 5:39 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Linus Torvalds
Linus reported that the bash completion for git show often dropped
the ref portion of the argument (stuff before the :) when trying
to complete a file name of a file in another branch or tag.
Bj?rn Steinbrink tracked it down to the gvfs completion script
which comes standard on many Fedora Core based systems. That is
removing : from COMP_WORDBREAKS, making readline treat the entire
argument (including the ref) as the name that must be completed.
When the git completion routines supplied a completion of just
the filename, readline replaced everything.
Since Git users often need to use "ref:path" or "ref:ref" sort of
arguments, and expect completion support on both sides of the :
we really want the : in COMP_WORDBREAKS to provide a good user
experience. This is also the default that ships with bash as it
can be useful in other contexts, such as rcp/scp.
We now try to add : back to COMP_WORDBREAKS if it has been removed
by a script that loaded before us. However if this doesn't work
(as the : is stripped after we load) we fallback in the completion
routines to include "ref:" as part of the prefix for completions,
allowing readine to fully insert the argument the user wanted.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
contrib/completion/git-completion.bash | 27 +++++++++++++++++++++++++--
1 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index c03230a..5844804 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -45,6 +45,11 @@
# git@vger.kernel.org
#
+case "$COMP_WORDBREAKS" in
+*:*) : great ;;
+*) COMP_WORDBREAKS="$COMP_WORDBREAKS:"
+esac
+
__gitdir ()
{
if [ -z "$1" ]; then
@@ -294,6 +299,12 @@ __git_complete_file ()
ls="$ref"
;;
esac
+
+ case "$COMP_WORDBREAKS" in
+ *:*) : great ;;
+ *) pfx="$ref:$pfx" ;;
+ esac
+
local IFS=$'\n'
COMPREPLY=($(compgen -P "$pfx" \
-W "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \
@@ -700,7 +711,12 @@ _git_fetch ()
*)
case "$cur" in
*:*)
- __gitcomp "$(__git_refs)" "" "${cur#*:}"
+ local pfx=""
+ case "$COMP_WORDBREAKS" in
+ *:*) : great ;;
+ *) pfx="${cur%%:*}:" ;;
+ esac
+ __gitcomp "$(__git_refs)" "$pfx" "${cur#*:}"
;;
*)
local remote
@@ -876,7 +892,14 @@ _git_push ()
git-push) remote="${COMP_WORDS[1]}" ;;
git) remote="${COMP_WORDS[2]}" ;;
esac
- __gitcomp "$(__git_refs "$remote")" "" "${cur#*:}"
+
+ local pfx=""
+ case "$COMP_WORDBREAKS" in
+ *:*) : great ;;
+ *) pfx="${cur%%:*}:" ;;
+ esac
+
+ __gitcomp "$(__git_refs "$remote")" "$pfx" "${cur#*:}"
;;
+*)
__gitcomp "$(__git_refs)" + "${cur#+}"
--
1.5.6.2.393.g45096
^ permalink raw reply related
* [PATCH] bash completion: Resolve git show ref:path<tab> losing ref: portion
From: Shawn O. Pearce @ 2008-07-15 5:52 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <20080715053907.GA3254@spearce.org>
Linus reported that the bash completion for git show often dropped
the ref portion of the argument (stuff before the :) when trying
to complete a file name of a file in another branch or tag.
Björn Steinbrink tracked it down to the gvfs completion script
which comes standard on many Fedora Core based systems. That is
removing : from COMP_WORDBREAKS, making readline treat the entire
argument (including the ref) as the name that must be completed.
When the git completion routines supplied a completion of just the
filename, readline replaced everything.
Since Git users often need to use "ref:path" or "ref:ref" sort of
arguments, and expect completion support on both sides of the :
we really want the : in COMP_WORDBREAKS to provide a good user
experience. This is also the default that ships with bash as it
can be useful in other contexts, such as rcp/scp.
We now try to add : back to COMP_WORDBREAKS if it has been removed
by a script that loaded before us. However if this doesn't work
(as the : is stripped after we load) we fallback in the completion
routines to include "ref:" as part of the prefix for completions,
allowing readine to fully insert the argument the user wanted.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
Second time's the charm? The prior version had a mangled commit
message, due to character encoding stupidity between my keyboard
and my chair.
contrib/completion/git-completion.bash | 27 +++++++++++++++++++++++++--
1 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index c03230a..5844804 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -45,6 +45,11 @@
# git@vger.kernel.org
#
+case "$COMP_WORDBREAKS" in
+*:*) : great ;;
+*) COMP_WORDBREAKS="$COMP_WORDBREAKS:"
+esac
+
__gitdir ()
{
if [ -z "$1" ]; then
@@ -294,6 +299,12 @@ __git_complete_file ()
ls="$ref"
;;
esac
+
+ case "$COMP_WORDBREAKS" in
+ *:*) : great ;;
+ *) pfx="$ref:$pfx" ;;
+ esac
+
local IFS=$'\n'
COMPREPLY=($(compgen -P "$pfx" \
-W "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \
@@ -700,7 +711,12 @@ _git_fetch ()
*)
case "$cur" in
*:*)
- __gitcomp "$(__git_refs)" "" "${cur#*:}"
+ local pfx=""
+ case "$COMP_WORDBREAKS" in
+ *:*) : great ;;
+ *) pfx="${cur%%:*}:" ;;
+ esac
+ __gitcomp "$(__git_refs)" "$pfx" "${cur#*:}"
;;
*)
local remote
@@ -876,7 +892,14 @@ _git_push ()
git-push) remote="${COMP_WORDS[1]}" ;;
git) remote="${COMP_WORDS[2]}" ;;
esac
- __gitcomp "$(__git_refs "$remote")" "" "${cur#*:}"
+
+ local pfx=""
+ case "$COMP_WORDBREAKS" in
+ *:*) : great ;;
+ *) pfx="${cur%%:*}:" ;;
+ esac
+
+ __gitcomp "$(__git_refs "$remote")" "$pfx" "${cur#*:}"
;;
+*)
__gitcomp "$(__git_refs)" + "${cur#+}"
--
1.5.6.2.393.g45096
^ permalink raw reply related
* [PATCH] bash completion: Remove dashed command completion support
From: Shawn O. Pearce @ 2008-07-15 5:58 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
Since only 'git' and 'gitk' are in the user's $PATH now we do not
expect users to need completion support for git-fetch, and expect
they will instead rely upon the completion support for 'git fetch'.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
contrib/completion/git-completion.bash | 53 --------------------------------
1 files changed, 0 insertions(+), 53 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 5844804..0e493a4 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1440,64 +1440,11 @@ _gitk ()
complete -o default -o nospace -F _git git
complete -o default -o nospace -F _gitk gitk
-complete -o default -o nospace -F _git_am git-am
-complete -o default -o nospace -F _git_apply git-apply
-complete -o default -o nospace -F _git_bisect git-bisect
-complete -o default -o nospace -F _git_branch git-branch
-complete -o default -o nospace -F _git_bundle git-bundle
-complete -o default -o nospace -F _git_checkout git-checkout
-complete -o default -o nospace -F _git_cherry git-cherry
-complete -o default -o nospace -F _git_cherry_pick git-cherry-pick
-complete -o default -o nospace -F _git_commit git-commit
-complete -o default -o nospace -F _git_describe git-describe
-complete -o default -o nospace -F _git_diff git-diff
-complete -o default -o nospace -F _git_fetch git-fetch
-complete -o default -o nospace -F _git_format_patch git-format-patch
-complete -o default -o nospace -F _git_gc git-gc
-complete -o default -o nospace -F _git_log git-log
-complete -o default -o nospace -F _git_ls_remote git-ls-remote
-complete -o default -o nospace -F _git_ls_tree git-ls-tree
-complete -o default -o nospace -F _git_merge git-merge
-complete -o default -o nospace -F _git_merge_base git-merge-base
-complete -o default -o nospace -F _git_name_rev git-name-rev
-complete -o default -o nospace -F _git_pull git-pull
-complete -o default -o nospace -F _git_push git-push
-complete -o default -o nospace -F _git_rebase git-rebase
-complete -o default -o nospace -F _git_config git-config
-complete -o default -o nospace -F _git_remote git-remote
-complete -o default -o nospace -F _git_reset git-reset
-complete -o default -o nospace -F _git_shortlog git-shortlog
-complete -o default -o nospace -F _git_show git-show
-complete -o default -o nospace -F _git_stash git-stash
-complete -o default -o nospace -F _git_submodule git-submodule
-complete -o default -o nospace -F _git_svn git-svn
-complete -o default -o nospace -F _git_log git-show-branch
-complete -o default -o nospace -F _git_tag git-tag
-complete -o default -o nospace -F _git_log git-whatchanged
# The following are necessary only for Cygwin, and only are needed
# when the user has tab-completed the executable name and consequently
# included the '.exe' suffix.
#
if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
-complete -o default -o nospace -F _git_add git-add.exe
-complete -o default -o nospace -F _git_apply git-apply.exe
complete -o default -o nospace -F _git git.exe
-complete -o default -o nospace -F _git_branch git-branch.exe
-complete -o default -o nospace -F _git_bundle git-bundle.exe
-complete -o default -o nospace -F _git_cherry git-cherry.exe
-complete -o default -o nospace -F _git_describe git-describe.exe
-complete -o default -o nospace -F _git_diff git-diff.exe
-complete -o default -o nospace -F _git_format_patch git-format-patch.exe
-complete -o default -o nospace -F _git_log git-log.exe
-complete -o default -o nospace -F _git_ls_tree git-ls-tree.exe
-complete -o default -o nospace -F _git_merge_base git-merge-base.exe
-complete -o default -o nospace -F _git_name_rev git-name-rev.exe
-complete -o default -o nospace -F _git_push git-push.exe
-complete -o default -o nospace -F _git_config git-config
-complete -o default -o nospace -F _git_shortlog git-shortlog.exe
-complete -o default -o nospace -F _git_show git-show.exe
-complete -o default -o nospace -F _git_log git-show-branch.exe
-complete -o default -o nospace -F _git_tag git-tag.exe
-complete -o default -o nospace -F _git_log git-whatchanged.exe
fi
--
1.5.6.2.393.g45096
^ 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