From: Heiko Voigt <hvoigt@hvoigt•net>
To: Junio C Hamano <gitster@pobox•com>
Cc: git@vger•kernel.org, Fredrik Gustafsson <iveqy@iveqy•com>,
Jens Lehmann <jens.lehmann@web•de>
Subject: Re: Re: [PATCH v5 1/3] Teach revision walking machinery to walk multiple times sequencially
Date: Mon, 26 Mar 2012 21:32:52 +0200 [thread overview]
Message-ID: <20120326193241.GA41087@book.hvoigt.net> (raw)
In-Reply-To: <7vfwee9p1t.fsf@alter.siamese.dyndns.org>
Hi,
sorry that my reply to this took quite some time.
On Mon, Feb 13, 2012 at 05:33:34PM -0800, Junio C Hamano wrote:
> Heiko Voigt <hvoigt@hvoigt•net> writes:
>
> > Previously it was not possible to iterate revisions twice using the
> > revision walking api. We add a reset_revision_walk() which clears the
> > used flags. This allows us to do multiple sequencial revision walks.
> >
> > Signed-off-by: Heiko Voigt <hvoigt@hvoigt•net>
>
> I am kind of surprised that this is already its 5th round.
Well, not this patch in particular but the series so I chose to it for
the whole series.
> Minimally,
>
> void clear_object_flags(unsigned flags)
> {
> int i;
>
> for (i = 0; i < obj_hash_size; i++) {
> struct object *obj = obj_hash[i];
> if (obj && (obj->flags & flags))
> obj->flags &= ~flags;
> }
> }
>
> I am not sure if the "If there is any bit set we care about, drop them"
> buys us anything, though.
Ok done. And also dropped the "if there is any bit set" condition.
> > +void reset_revision_walk()
>
> void reset_revision_walk(void)
Done.
> > +{
> > + clear_object_flags(SEEN | ADDED | SHOWN);
> > +}
>
> But is this really the right API? After a particular program finishes
> using the revision walker, wouldn't it want to clear both the set of these
> standard flag bits used by the traversal machinery, as well as whatever
> program specific bits it used to mark the objects with?
Well if a program uses extra flags on objects it should clear the flags
it set by using the clear_objects_flags() function itself. For example if
the program wants to reuse those extra flags in a second revision walk
it would not be possible if reset_revision_walk() would clear all flags.
> > diff --git a/revision.h b/revision.h
> > index b8e9223..3535733 100644
> > --- a/revision.h
> > +++ b/revision.h
> > @@ -192,6 +192,7 @@ extern void parse_revision_opt(struct rev_info *revs, struct parse_opt_ctx_t *ct
> > ...
> > +extern void reset_revision_walk();
>
> Likewise, "extern void reset_revision_walk(void);".
Done.
>
> > diff --git a/submodule.c b/submodule.c
> > index 9a28060..645ff5d 100644
> > --- a/submodule.c
> > +++ b/submodule.c
> > @@ -404,6 +404,7 @@ int check_submodule_needs_pushing(unsigned char new_sha1[20], const char *remote
> > while ((commit = get_revision(&rev)) && !needs_pushing)
> > commit_need_pushing(commit, &needs_pushing);
> >
> > + reset_revision_walk();
> > free(sha1_copy);
> > strbuf_release(&remotes_arg);
> >
> > @@ -741,6 +742,7 @@ static int find_first_merges(struct object_array *result, const char *path,
> > if (in_merge_bases(b, &commit, 1))
> > add_object_array(o, NULL, &merges);
> > }
> > + reset_revision_walk();
> >
> > /* Now we've got all merges that contain a and b. Prune all
> > * merges that contain another found merge and save them in
>
> These two hunk look like a *BUGFIX* to me (certainly it does not look like
> this is an addition of any new feature).
>
> What bug does this fix, and how is the current submodule code broken
> without this patch? Can you describe the problem in the log message, and
> add a test to demonstrate the existing breakage?
There is no breakage I know of. Its rather a cleanup which allows to
call these functions multiple times. I did this to avoid surprises.
Should I put these in a separate patch or just add an explanation into
the current one?
Cheers Heiko
next prev parent reply other threads:[~2012-03-26 19:33 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-13 9:25 [PATCH v5 0/3] push: submodule support Heiko Voigt
2012-02-13 9:27 ` [PATCH v5 1/3] Teach revision walking machinery to walk multiple times sequencially Heiko Voigt
2012-02-14 1:33 ` Junio C Hamano
2012-03-26 19:32 ` Heiko Voigt [this message]
2012-03-26 21:28 ` Junio C Hamano
2012-02-13 9:29 ` [PATCH v5 2/3] Refactor submodule push check to use string list instead of integer Heiko Voigt
2012-02-14 3:28 ` Junio C Hamano
2012-03-26 19:33 ` Heiko Voigt
2012-03-26 19:55 ` Heiko Voigt
2012-03-26 21:29 ` Junio C Hamano
2012-02-13 9:30 ` [PATCH v5 3/3] push: teach --recurse-submodules the on-demand option Heiko Voigt
2012-02-14 3:34 ` Junio C Hamano
2012-02-15 22:28 ` Jens Lehmann
2012-03-26 19:33 ` Heiko Voigt
2012-05-13 14:47 ` [RFC/PATCH] read from 2 filedescriptors simultaneously into one strbuf Heiko Voigt
2012-03-26 21:22 ` [PATCH v5 3/3] push: teach --recurse-submodules the on-demand option Zbigniew Jędrzejewski-Szmek
2012-03-28 15:30 ` Heiko Voigt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120326193241.GA41087@book.hvoigt.net \
--to=hvoigt@hvoigt$(echo .)net \
--cc=git@vger$(echo .)kernel.org \
--cc=gitster@pobox$(echo .)com \
--cc=iveqy@iveqy$(echo .)com \
--cc=jens.lehmann@web$(echo .)de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox