git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Heiko Voigt <hvoigt@hvoigt.net>
Cc: git@vger.kernel.org, jens.lehmann@web.de, jherland@gmail.com
Subject: Re: [PATCH v2 3/4] extent setup_revisions() so it works with submodules
Date: Tue, 06 Jul 2010 22:28:20 -0700	[thread overview]
Message-ID: <7veiff274b.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: ab9c0f88b30060401d99735cb78eec7cc1e95b86.1278444110.git.hvoigt@hvoigt.net

Heiko Voigt <hvoigt@hvoigt.net> writes:

> Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>

This needs a bit more explanation.  "Exten_d_ setup_revisions()" is fine,
but "works with submodules"???  How? and what do the caller need to do?

Something like...

    Subject: setup_revisions(): allow walking history in a submodule

    By passing the path to a submodule in opt->submodule, the function can
    be used to walk history in the named submodule repository, instead of
    the toplevel repository.



> ---
>  refs.c     |   31 +++++++++++++++++++++++++++++++
>  refs.h     |    8 ++++++++
>  revision.c |   32 ++++++++++++++++++--------------
>  revision.h |    1 +
>  4 files changed, 58 insertions(+), 14 deletions(-)
>
> diff --git a/refs.c b/refs.c
> index c8649b1..37e2794 100644
> --- a/refs.c
> +++ b/refs.c
> @@ -721,31 +721,62 @@ int head_ref(each_ref_fn fn, void *cb_data)
>  	return do_head_ref(NULL, fn, cb_data);
>  }
>  
> +int head_ref_submodule(const char *submodule, each_ref_fn fn, void *cb_data)
> +{
> +	return do_head_ref(submodule, fn, cb_data);
> +}
> +
>  int for_each_ref(each_ref_fn fn, void *cb_data)
>  {
>  	return do_for_each_ref(NULL, "refs/", fn, 0, 0, cb_data);
>  }
>  
> +int for_each_ref_submodule(const char *submodule, each_ref_fn fn, void *cb_data)
> +{
> +	return do_for_each_ref(submodule, "refs/", fn, 0, 0, cb_data);
> +}
> +
>  int for_each_ref_in(const char *prefix, each_ref_fn fn, void *cb_data)
>  {
>  	return do_for_each_ref(NULL, prefix, fn, strlen(prefix), 0, cb_data);
>  }
>  
> +int for_each_ref_in_submodule(const char *submodule, const char *prefix,
> +		each_ref_fn fn, void *cb_data)
> +{
> +	return do_for_each_ref(submodule, prefix, fn, strlen(prefix), 0, cb_data);
> +}
> +
>  int for_each_tag_ref(each_ref_fn fn, void *cb_data)
>  {
>  	return for_each_ref_in("refs/tags/", fn, cb_data);
>  }
>  
> +int for_each_tag_ref_submodule(const char *submodule, each_ref_fn fn, void *cb_data)
> +{
> +	return for_each_ref_in_submodule(submodule, "refs/tags/", fn, cb_data);
> +}
> +
>  int for_each_branch_ref(each_ref_fn fn, void *cb_data)
>  {
>  	return for_each_ref_in("refs/heads/", fn, cb_data);
>  }
>  
> +int for_each_branch_ref_submodule(const char *submodule, each_ref_fn fn, void *cb_data)
> +{
> +	return for_each_ref_in_submodule(submodule, "refs/heads/", fn, cb_data);
> +}
> +
>  int for_each_remote_ref(each_ref_fn fn, void *cb_data)
>  {
>  	return for_each_ref_in("refs/remotes/", fn, cb_data);
>  }
>  
> +int for_each_remote_ref_submodule(const char *submodule, each_ref_fn fn, void *cb_data)
> +{
> +	return for_each_ref_in_submodule(submodule, "refs/remotes/", fn, cb_data);
> +}
> +
>  int for_each_replace_ref(each_ref_fn fn, void *cb_data)
>  {
>  	return do_for_each_ref(NULL, "refs/replace/", fn, 13, 0, cb_data);
> diff --git a/refs.h b/refs.h
> index 762ce50..5e7a9a5 100644
> --- a/refs.h
> +++ b/refs.h
> @@ -28,6 +28,14 @@ extern int for_each_replace_ref(each_ref_fn, void *);
>  extern int for_each_glob_ref(each_ref_fn, const char *pattern, void *);
>  extern int for_each_glob_ref_in(each_ref_fn, const char *pattern, const char* prefix, void *);
>  
> +extern int head_ref_submodule(const char *submodule, each_ref_fn fn, void *cb_data);
> +extern int for_each_ref_submodule(const char *submodule, each_ref_fn fn, void *cb_data);
> +extern int for_each_ref_in_submodule(const char *submodule, const char *prefix,
> +		each_ref_fn fn, void *cb_data);
> +extern int for_each_tag_ref_submodule(const char *submodule, each_ref_fn fn, void *cb_data);
> +extern int for_each_branch_ref_submodule(const char *submodule, each_ref_fn fn, void *cb_data);
> +extern int for_each_remote_ref_submodule(const char *submodule, each_ref_fn fn, void *cb_data);
> +
>  static inline const char *has_glob_specials(const char *pattern)
>  {
>  	return strpbrk(pattern, "?*[");
> diff --git a/revision.c b/revision.c
> index 7e82efd..5f2cf1e 100644
> --- a/revision.c
> +++ b/revision.c
> @@ -820,12 +820,12 @@ static void init_all_refs_cb(struct all_refs_cb *cb, struct rev_info *revs,
>  	cb->all_flags = flags;
>  }
>  
> -static void handle_refs(struct rev_info *revs, unsigned flags,
> -		int (*for_each)(each_ref_fn, void *))
> +static void handle_refs(const char *submodule, struct rev_info *revs, unsigned flags,
> +		int (*for_each)(const char *, each_ref_fn, void *))
>  {
>  	struct all_refs_cb cb;
>  	init_all_refs_cb(&cb, revs, flags);
> -	for_each(handle_one_ref, &cb);
> +	for_each(submodule, handle_one_ref, &cb);
>  }
>  
>  static void handle_one_reflog_commit(unsigned char *sha1, void *cb_data)
> @@ -1417,14 +1417,14 @@ void parse_revision_opt(struct rev_info *revs, struct parse_opt_ctx_t *ctx,
>  	ctx->argc -= n;
>  }
>  
> -static int for_each_bad_bisect_ref(each_ref_fn fn, void *cb_data)
> +static int for_each_bad_bisect_ref(const char *submodule, each_ref_fn fn, void *cb_data)
>  {
> -	return for_each_ref_in("refs/bisect/bad", fn, cb_data);
> +	return for_each_ref_in_submodule(submodule, "refs/bisect/bad", fn, cb_data);
>  }
>  
> -static int for_each_good_bisect_ref(each_ref_fn fn, void *cb_data)
> +static int for_each_good_bisect_ref(const char *submodule, each_ref_fn fn, void *cb_data)
>  {
> -	return for_each_ref_in("refs/bisect/good", fn, cb_data);
> +	return for_each_ref_in_submodule(submodule, "refs/bisect/good", fn, cb_data);
>  }
>  
>  static void append_prune_data(const char ***prune_data, const char **av)
> @@ -1466,6 +1466,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
>  {
>  	int i, flags, left, seen_dashdash, read_from_stdin, got_rev_arg = 0;
>  	const char **prune_data = NULL;
> +	const char *submodule = NULL;
> +
> +	if (opt)
> +		submodule = opt->submodule;
>  
>  	/* First, search for "--" */
>  	seen_dashdash = 0;
> @@ -1490,26 +1494,26 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
>  			int opts;
>  
>  			if (!strcmp(arg, "--all")) {
> -				handle_refs(revs, flags, for_each_ref);
> -				handle_refs(revs, flags, head_ref);
> +				handle_refs(submodule, revs, flags, for_each_ref_submodule);
> +				handle_refs(submodule, revs, flags, head_ref_submodule);
>  				continue;
>  			}
>  			if (!strcmp(arg, "--branches")) {
> -				handle_refs(revs, flags, for_each_branch_ref);
> +				handle_refs(submodule, revs, flags, for_each_branch_ref_submodule);
>  				continue;
>  			}
>  			if (!strcmp(arg, "--bisect")) {
> -				handle_refs(revs, flags, for_each_bad_bisect_ref);
> -				handle_refs(revs, flags ^ UNINTERESTING, for_each_good_bisect_ref);
> +				handle_refs(submodule, revs, flags, for_each_bad_bisect_ref);
> +				handle_refs(submodule, revs, flags ^ UNINTERESTING, for_each_good_bisect_ref);
>  				revs->bisect = 1;
>  				continue;
>  			}
>  			if (!strcmp(arg, "--tags")) {
> -				handle_refs(revs, flags, for_each_tag_ref);
> +				handle_refs(submodule, revs, flags, for_each_tag_ref_submodule);
>  				continue;
>  			}
>  			if (!strcmp(arg, "--remotes")) {
> -				handle_refs(revs, flags, for_each_remote_ref);
> +				handle_refs(submodule, revs, flags, for_each_remote_ref_submodule);
>  				continue;
>  			}
>  			if (!prefixcmp(arg, "--glob=")) {
> diff --git a/revision.h b/revision.h
> index 36fdf22..05659c6 100644
> --- a/revision.h
> +++ b/revision.h
> @@ -151,6 +151,7 @@ extern volatile show_early_output_fn_t show_early_output;
>  struct setup_revision_opt {
>  	const char *def;
>  	void (*tweak)(struct rev_info *, struct setup_revision_opt *);
> +	const char *submodule;
>  };
>  
>  extern void init_revisions(struct rev_info *revs, const char *prefix);
> -- 
> 1.7.2.rc1.217.g7dc0db.dirty

  reply	other threads:[~2010-07-07  5:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-06 19:34 [PATCH v2 0/4] implement automatic submodule merge strategy when possible Heiko Voigt
2010-07-06 19:34 ` [PATCH v2 1/4] add missing && to submodule-merge testcase Heiko Voigt
2010-07-06 19:34 ` [PATCH v2 2/4] teach ref iteration module about submodules Heiko Voigt
2010-07-06 19:34 ` [PATCH v2 3/4] extent setup_revisions() so it works with submodules Heiko Voigt
2010-07-07  5:28   ` Junio C Hamano [this message]
2010-07-07 13:37     ` Heiko Voigt
2010-07-06 19:34 ` [PATCH v2 4/4] implement automatic fast forward merge for submodules Heiko Voigt
2010-07-06 23:52   ` Johan Herland
2010-07-07 13:35     ` Heiko Voigt
2010-07-08  0:34       ` Junio C Hamano
2010-07-06 23:53 ` [PATCH v2 0/4] implement automatic submodule merge strategy when possible Johan Herland

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7veiff274b.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=hvoigt@hvoigt.net \
    --cc=jens.lehmann@web.de \
    --cc=jherland@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).