[PATCH 2/4] builtin-for-each-ref.c: check if we need to peel onion while parsing the format

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Instead of iterating over the parsed atoms that are used in the output
format after all the parsing is done, check it while parsing the
format string.

Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx>
---
 builtin-for-each-ref.c |    9 ++-------
 1 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/builtin-for-each-ref.c b/builtin-for-each-ref.c
index 3698e82..d68977e 100644
--- a/builtin-for-each-ref.c
+++ b/builtin-for-each-ref.c
@@ -133,6 +133,8 @@ static int parse_atom(const char *atom, const char *ep)
 				  (sizeof(*used_atom_type) * used_atom_cnt));
 	used_atom[at] = xmemdupz(atom, ep - atom);
 	used_atom_type[at] = valid_atom[i].cmp_type;
+	if (*atom == '*')
+		need_tagged = 1;
 	return at;
 }
 
@@ -944,13 +946,6 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)
 	refs = cbdata.grab_array;
 	num_refs = cbdata.grab_cnt;
 
-	for (i = 0; i < used_atom_cnt; i++) {
-		if (used_atom[i][0] == '*') {
-			need_tagged = 1;
-			break;
-		}
-	}
-
 	sort_refs(sort, refs, num_refs);
 
 	if (!maxcount || num_refs < maxcount)
-- 
1.7.0.169.g57c99

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]