git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[RFC/PATCH 1/3] remote: use a local variable in match_push_refs()

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Feb 17, 2012, 19:12 UTC
Message-ID
<1329505957-24595-2-git-send-email-felipe.contreras@gmail.com>
In-Reply-To
<1329505957-24595-1-git-send-email-felipe.contreras@gmail.com>
So that we can reuse src later on.
Will be useful in next patches.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 remote.c |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/remote.c b/remote.c
index 73a3809..55d68d1 100644
--- a/remote.c
+++ b/remote.c
@@ -1157,7 +1157,7 @@ int match_push_refs(struct ref *src, struct ref **dst,
 	int send_mirror = flags & MATCH_REFS_MIRROR;
 	int errs;
 	static const char *default_refspec[] = { ":", NULL };
-	struct ref **dst_tail = tail_ref(dst);
+	struct ref *ref, **dst_tail = tail_ref(dst);
 
 	if (!nr_refspec) {
 		nr_refspec = 1;
@@ -1167,14 +1167,14 @@ int match_push_refs(struct ref *src, struct ref **dst,
 	errs = match_explicit_refs(src, *dst, &dst_tail, rs, nr_refspec);
 
 	/* pick the remainder */
-	for ( ; src; src = src->next) {
+	for (ref = src; ref; ref = ref->next) {
 		struct ref *dst_peer;
 		const struct refspec *pat = NULL;
 		char *dst_name;
-		if (src->peer_ref)
+		if (ref->peer_ref)
 			continue;
 
-		pat = check_pattern_match(rs, nr_refspec, src);
+		pat = check_pattern_match(rs, nr_refspec, ref);
 		if (!pat)
 			continue;
 
@@ -1184,13 +1184,14 @@ int match_push_refs(struct ref *src, struct ref **dst,
 			 * including refs outside refs/heads/ hierarchy, but
 			 * that does not make much sense these days.
 			 */
-			if (!send_mirror && prefixcmp(src->name, "refs/heads/"))
+			if (!send_mirror && prefixcmp(ref->name, "refs/heads/"))
 				continue;
-			dst_name = xstrdup(src->name);
+			dst_name = xstrdup(ref->name);
+
 
 		} else {
 			const char *dst_side = pat->dst ? pat->dst : pat->src;
-			if (!match_name_with_pattern(pat->src, src->name,
+			if (!match_name_with_pattern(pat->src, ref->name,
 						     dst_side, &dst_name))
 				die("Didn't think it matches any more");
 		}
@@ -1211,9 +1212,9 @@ int match_push_refs(struct ref *src, struct ref **dst,
 
 			/* Create a new one and link it */
 			dst_peer = make_linked_ref(dst_name, &dst_tail);
-			hashcpy(dst_peer->new_sha1, src->new_sha1);
+			hashcpy(dst_peer->new_sha1, ref->new_sha1);
 		}
-		dst_peer->peer_ref = copy_ref(src);
+		dst_peer->peer_ref = copy_ref(ref);
 		dst_peer->force = pat->force;
 	free_name:
 		free(dst_name);
-- 
1.7.9.1
Previous: Felipe ContrerasNext: Junio C Hamano
Message 2 of 17 in “push: add 'prune' option”
  1. 0/3 push: add 'prune' optionFelipe Contreras, Feb 17, 2012
  2. 1/3 remote: use a local variable in match_push_refs()Felipe Contreras, Feb 17, 2012
  3. Junio C HamanoFeb 17, 2012
  4. 2/3 remote: reorganize check_pattern_match()Felipe Contreras, Feb 17, 2012
  5. Junio C HamanoFeb 17, 2012
  6. Felipe ContrerasFeb 22, 2012
  7. Junio C HamanoFeb 22, 2012
  8. 3/3 push: add 'prune' optionFelipe Contreras, Feb 17, 2012
  9. Jeff KingFeb 17, 2012
  10. Junio C HamanoFeb 17, 2012
  11. Felipe ContrerasFeb 22, 2012
  12. Junio C HamanoFeb 22, 2012
  13. Felipe ContrerasFeb 22, 2012
  14. Junio C HamanoFeb 22, 2012
  15. Nguyen Thai Ngoc DuyFeb 21, 2012
  16. Jeff KingFeb 21, 2012
  17. Nguyen Thai Ngoc DuyFeb 22, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.