All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Haggerty <mhagger@alum.mit.edu>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Michael Haggerty <mhagger@alum.mit.edu>
Subject: [PATCH v2 32/33] refs: change do_for_each_*() functions to take ref_cache arguments
Date: Mon, 22 Apr 2013 21:52:40 +0200	[thread overview]
Message-ID: <1366660361-21831-33-git-send-email-mhagger@alum.mit.edu> (raw)
In-Reply-To: <1366660361-21831-1-git-send-email-mhagger@alum.mit.edu>

Change the callers convert submodule names into ref_cache pointers.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
 refs.c | 29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/refs.c b/refs.c
index b1cda1b..f246b77 100644
--- a/refs.c
+++ b/refs.c
@@ -1503,16 +1503,15 @@ void warn_dangling_symref(FILE *fp, const char *msg_fmt, const char *refname)
 }
 
 /*
- * Call fn for each reference in the specified submodule, omitting
+ * Call fn for each reference in the specified ref_cache, omitting
  * references not in the containing_dir of base.  fn is called for all
  * references, including broken ones.  If fn ever returns a non-zero
  * value, stop the iteration and return that value; otherwise, return
  * 0.
  */
-static int do_for_each_entry(const char *submodule, const char *base,
+static int do_for_each_entry(struct ref_cache *refs, const char *base,
 			     each_ref_entry_fn fn, void *cb_data)
 {
-	struct ref_cache *refs = get_ref_cache(submodule);
 	struct ref_dir *packed_dir = get_packed_refs(refs);
 	struct ref_dir *loose_dir = get_loose_refs(refs);
 	int retval = 0;
@@ -1541,7 +1540,7 @@ static int do_for_each_entry(const char *submodule, const char *base,
 }
 
 /*
- * Call fn for each reference in the specified submodule for which the
+ * Call fn for each reference in the specified ref_cache for which the
  * refname begins with base.  If trim is non-zero, then trim that many
  * characters off the beginning of each refname before passing the
  * refname to fn.  flags can be DO_FOR_EACH_INCLUDE_BROKEN to include
@@ -1549,8 +1548,8 @@ static int do_for_each_entry(const char *submodule, const char *base,
  * value, stop the iteration and return that value; otherwise, return
  * 0.
  */
-static int do_for_each_ref(const char *submodule, const char *base, each_ref_fn fn,
-			   int trim, int flags, void *cb_data)
+static int do_for_each_ref(struct ref_cache *refs, const char *base,
+			   each_ref_fn fn, int trim, int flags, void *cb_data)
 {
 	struct ref_entry_cb data;
 	data.base = base;
@@ -1559,7 +1558,7 @@ static int do_for_each_ref(const char *submodule, const char *base, each_ref_fn
 	data.fn = fn;
 	data.cb_data = cb_data;
 
-	return do_for_each_entry(submodule, base, do_one_ref, &data);
+	return do_for_each_entry(refs, base, do_one_ref, &data);
 }
 
 static int do_head_ref(const char *submodule, each_ref_fn fn, void *cb_data)
@@ -1592,23 +1591,23 @@ int head_ref_submodule(const char *submodule, each_ref_fn fn, void *cb_data)
 
 int for_each_ref(each_ref_fn fn, void *cb_data)
 {
-	return do_for_each_ref(NULL, "", fn, 0, 0, cb_data);
+	return do_for_each_ref(get_ref_cache(NULL), "", 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, "", fn, 0, 0, cb_data);
+	return do_for_each_ref(get_ref_cache(submodule), "", 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);
+	return do_for_each_ref(get_ref_cache(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);
+	return do_for_each_ref(get_ref_cache(submodule), prefix, fn, strlen(prefix), 0, cb_data);
 }
 
 int for_each_tag_ref(each_ref_fn fn, void *cb_data)
@@ -1643,7 +1642,7 @@ int for_each_remote_ref_submodule(const char *submodule, each_ref_fn fn, void *c
 
 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);
+	return do_for_each_ref(get_ref_cache(NULL), "refs/replace/", fn, 13, 0, cb_data);
 }
 
 int head_ref_namespaced(each_ref_fn fn, void *cb_data)
@@ -1666,7 +1665,7 @@ int for_each_namespaced_ref(each_ref_fn fn, void *cb_data)
 	struct strbuf buf = STRBUF_INIT;
 	int ret;
 	strbuf_addf(&buf, "%srefs/", get_git_namespace());
-	ret = do_for_each_ref(NULL, buf.buf, fn, 0, 0, cb_data);
+	ret = do_for_each_ref(get_ref_cache(NULL), buf.buf, fn, 0, 0, cb_data);
 	strbuf_release(&buf);
 	return ret;
 }
@@ -1708,7 +1707,7 @@ int for_each_glob_ref(each_ref_fn fn, const char *pattern, void *cb_data)
 
 int for_each_rawref(each_ref_fn fn, void *cb_data)
 {
-	return do_for_each_ref(NULL, "", fn, 0,
+	return do_for_each_ref(get_ref_cache(NULL), "", fn, 0,
 			       DO_FOR_EACH_INCLUDE_BROKEN, cb_data);
 }
 
@@ -2103,7 +2102,7 @@ int pack_refs(unsigned int flags)
 
 	write_or_die(cbdata.fd, PACKED_REFS_HEADER, strlen(PACKED_REFS_HEADER));
 
-	do_for_each_entry(NULL, "", pack_one_ref, &cbdata);
+	do_for_each_entry(get_ref_cache(NULL), "", pack_one_ref, &cbdata);
 	if (commit_lock_file(&packlock) < 0)
 		die_errno("unable to overwrite old ref-pack file");
 	prune_refs(cbdata.ref_to_prune);
-- 
1.8.2.1

  parent reply	other threads:[~2013-04-22 20:01 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-22 19:52 [PATCH v2 00/33] Various cleanups around reference packing and peeling Michael Haggerty
2013-04-22 19:52 ` [PATCH v2 01/33] refs: document flags constants REF_* Michael Haggerty
2013-04-22 19:52 ` [PATCH v2 02/33] refs: document the fields of struct ref_value Michael Haggerty
2013-04-22 19:52 ` [PATCH v2 03/33] refs: document do_for_each_ref() and do_one_ref() Michael Haggerty
2013-04-22 19:52 ` [PATCH v2 04/33] refs: document how current_ref is used Michael Haggerty
2013-04-22 19:52 ` [PATCH v2 05/33] refs: define constant PEELED_LINE_LENGTH Michael Haggerty
2013-04-22 19:52 ` [PATCH v2 06/33] do_for_each_ref_in_dirs(): remove dead code Michael Haggerty
2013-04-22 19:52 ` [PATCH v2 07/33] get_packed_ref(): return a ref_entry Michael Haggerty
2013-04-22 19:52 ` [PATCH v2 08/33] peel_ref(): use function get_packed_ref() Michael Haggerty
2013-04-22 19:52 ` [PATCH v2 09/33] repack_without_ref(): " Michael Haggerty
2013-04-22 19:52 ` [PATCH v2 10/33] refs: extract a function ref_resolves_to_object() Michael Haggerty
2013-04-22 19:52 ` [PATCH v2 11/33] refs: extract function peel_object() Michael Haggerty
2013-04-22 19:52 ` [PATCH v2 12/33] peel_object(): give more specific information in return value Michael Haggerty
2013-04-22 19:52 ` [PATCH v2 13/33] peel_ref(): fix return value for non-peelable, not-current reference Michael Haggerty
2013-04-22 19:52 ` [PATCH v2 14/33] refs: extract a function peel_entry() Michael Haggerty
2013-04-22 19:52 ` [PATCH v2 15/33] refs: change the internal reference-iteration API Michael Haggerty
2013-04-22 19:52 ` [PATCH v2 16/33] t3210: test for spurious error messages for dangling packed refs Michael Haggerty
2013-04-22 19:52 ` [PATCH v2 17/33] repack_without_ref(): silence errors " Michael Haggerty
2013-04-22 22:21   ` Junio C Hamano
2013-04-22 19:52 ` [PATCH v2 18/33] search_ref_dir(): return an index rather than a pointer Michael Haggerty
2013-04-22 19:52 ` [PATCH v2 19/33] refs: change how packed refs are deleted Michael Haggerty
2013-04-22 19:52 ` [PATCH v2 20/33] t3211: demonstrate loss of peeled refs if a packed ref is deleted Michael Haggerty
2013-04-22 19:52 ` [PATCH v2 21/33] repack_without_ref(): write peeled refs in the rewritten file Michael Haggerty
2013-04-22 19:52 ` [PATCH v2 22/33] refs: extract a function write_packed_entry() Michael Haggerty
2013-04-22 19:52 ` [PATCH v2 23/33] pack-refs: rename handle_one_ref() to pack_one_ref() Michael Haggerty
2013-04-22 19:52 ` [PATCH v2 24/33] pack-refs: merge code from pack-refs.{c,h} into refs.{c,h} Michael Haggerty
2013-04-22 19:52 ` [PATCH v2 25/33] pack_one_ref(): rename "path" parameter to "refname" Michael Haggerty
2013-04-22 19:52 ` [PATCH v2 26/33] refs: use same lock_file object for both ref-packing functions Michael Haggerty
2013-04-22 19:52 ` [PATCH v2 27/33] pack_refs(): change to use do_for_each_entry() Michael Haggerty
2013-04-22 19:52 ` [PATCH v2 28/33] refs: inline function do_not_prune() Michael Haggerty
2013-04-22 19:52 ` [PATCH v2 29/33] pack_one_ref(): use function peel_entry() Michael Haggerty
2013-04-22 19:52 ` [PATCH v2 30/33] pack_one_ref(): use write_packed_entry() to do the writing Michael Haggerty
2013-04-22 19:52 ` [PATCH v2 31/33] pack_one_ref(): do some cheap tests before a more expensive one Michael Haggerty
2013-04-22 19:52 ` Michael Haggerty [this message]
2013-04-22 19:52 ` [PATCH v2 33/33] refs: handle the main ref_cache specially Michael Haggerty
2013-04-22 22:23 ` [PATCH v2 00/33] Various cleanups around reference packing and peeling Junio C Hamano
2013-04-23  9:15   ` [PATCH] fixup! t3210: test for spurious error messages for dangling packed refs Michael Haggerty
2013-04-23 17:50     ` Junio C Hamano
2013-04-24 15:25       ` Michael Haggerty
2013-04-27  5:43         ` Michael Haggerty

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=1366660361-21831-33-git-send-email-mhagger@alum.mit.edu \
    --to=mhagger@alum.mit.edu \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.