git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
From: Olga Telezhnaya <olyatelezhnaya@gmail.com>
To: git@vger.kernel.org
Subject: [PATCH 03/20] cat-file: rename variables in ref-filter
Date: Tue, 9 Jan 2018 13:05:23 +0000	[thread overview]
Message-ID: <01020160db067bde-7f500636-b80e-4099-a84e-2613126c9aa1-000000@eu-west-1.amazonses.com> (raw)
In-Reply-To: <01020160db0679c9-799a0bc4-b6d1-43e2-ad3b-80be4e4c55e9-000000@eu-west-1.amazonses.com>

Rename some variables for easier reading.
They point not to values, but to arrays.
Added "s" ending so that it could be obvious.

Signed-off-by: Olga Telezhnaia <olyatelezhnaya@gmail.com>
Mentored-by: Christian Couder <christian.couder@gmail.com>
Mentored by: Jeff King <peff@peff.net>
---
 ref-filter.c | 60 ++++++++++++++++++++++++++++++------------------------------
 1 file changed, 30 insertions(+), 30 deletions(-)

diff --git a/ref-filter.c b/ref-filter.c
index 3f9161707e66b..1426f0c28bce7 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -98,7 +98,7 @@ static struct used_atom {
 		struct refname_atom refname;
 		char *head;
 	} u;
-} *used_atom;
+} *used_atoms;
 static int used_atom_cnt, need_tagged, need_symref;
 
 static void color_atom_parser(const struct ref_format *format, struct used_atom *atom, const char *color_value)
@@ -325,11 +325,11 @@ static void head_atom_parser(const struct ref_format *format, struct used_atom *
 	atom->u.head = resolve_refdup("HEAD", RESOLVE_REF_READING, NULL, NULL);
 }
 
-static struct {
+static struct valid_atom {
 	const char *name;
 	cmp_type cmp_type;
 	void (*parser)(const struct ref_format *format, struct used_atom *atom, const char *arg);
-} valid_atom[] = {
+} valid_atoms[] = {
 	{ "refname" , FIELD_STR, refname_atom_parser },
 	{ "objecttype" },
 	{ "objectsize", FIELD_ULONG },
@@ -410,38 +410,38 @@ static int parse_ref_filter_atom(const struct ref_format *format,
 
 	/* Do we have the atom already used elsewhere? */
 	for (i = 0; i < used_atom_cnt; i++) {
-		int len = strlen(used_atom[i].name);
-		if (len == ep - atom && !memcmp(used_atom[i].name, atom, len))
+		int len = strlen(used_atoms[i].name);
+		if (len == ep - atom && !memcmp(used_atoms[i].name, atom, len))
 			return i;
 	}
 
 	/*
 	 * If the atom name has a colon, strip it and everything after
 	 * it off - it specifies the format for this entry, and
-	 * shouldn't be used for checking against the valid_atom
+	 * shouldn't be used for checking against the valid_atoms
 	 * table.
 	 */
 	arg = memchr(sp, ':', ep - sp);
 	atom_len = (arg ? arg : ep) - sp;
 
 	/* Is the atom a valid one? */
-	for (i = 0; i < ARRAY_SIZE(valid_atom); i++) {
-		int len = strlen(valid_atom[i].name);
-		if (len == atom_len && !memcmp(valid_atom[i].name, sp, len))
+	for (i = 0; i < ARRAY_SIZE(valid_atoms); i++) {
+		int len = strlen(valid_atoms[i].name);
+		if (len == atom_len && !memcmp(valid_atoms[i].name, sp, len))
 			break;
 	}
 
-	if (ARRAY_SIZE(valid_atom) <= i)
+	if (ARRAY_SIZE(valid_atoms) <= i)
 		die(_("unknown field name: %.*s"), (int)(ep-atom), atom);
 
 	/* Add it in, including the deref prefix */
 	at = used_atom_cnt;
 	used_atom_cnt++;
-	REALLOC_ARRAY(used_atom, used_atom_cnt);
-	used_atom[at].name = xmemdupz(atom, ep - atom);
-	used_atom[at].type = valid_atom[i].cmp_type;
+	REALLOC_ARRAY(used_atoms, used_atom_cnt);
+	used_atoms[at].name = xmemdupz(atom, ep - atom);
+	used_atoms[at].type = valid_atoms[i].cmp_type;
 	if (arg) {
-		arg = used_atom[at].name + (arg - atom) + 1;
+		arg = used_atoms[at].name + (arg - atom) + 1;
 		if (!*arg) {
 			/*
 			 * Treat empty sub-arguments list as NULL (i.e.,
@@ -450,12 +450,12 @@ static int parse_ref_filter_atom(const struct ref_format *format,
 			arg = NULL;
 		}
 	}
-	memset(&used_atom[at].u, 0, sizeof(used_atom[at].u));
-	if (valid_atom[i].parser)
-		valid_atom[i].parser(format, &used_atom[at], arg);
+	memset(&used_atoms[at].u, 0, sizeof(used_atoms[at].u));
+	if (valid_atoms[i].parser)
+		valid_atoms[i].parser(format, &used_atoms[at], arg);
 	if (*atom == '*')
 		need_tagged = 1;
-	if (!strcmp(valid_atom[i].name, "symref"))
+	if (!strcmp(valid_atoms[i].name, "symref"))
 		need_symref = 1;
 	return at;
 }
@@ -711,7 +711,7 @@ int verify_ref_format(struct ref_format *format)
 		at = parse_ref_filter_atom(format, sp + 2, ep);
 		cp = ep + 1;
 
-		if (skip_prefix(used_atom[at].name, "color:", &color))
+		if (skip_prefix(used_atoms[at].name, "color:", &color))
 			format->need_color_reset_at_eol = !!strcmp(color, "reset");
 	}
 	if (format->need_color_reset_at_eol && !want_color(format->use_color))
@@ -762,7 +762,7 @@ static void grab_common_values(struct atom_value *val, int deref, struct object
 	int i;
 
 	for (i = 0; i < used_atom_cnt; i++) {
-		const char *name = used_atom[i].name;
+		const char *name = used_atoms[i].name;
 		struct atom_value *v = &val[i];
 		if (!!deref != (*name == '*'))
 			continue;
@@ -775,7 +775,7 @@ static void grab_common_values(struct atom_value *val, int deref, struct object
 			v->s = xstrfmt("%lu", sz);
 		}
 		else if (deref)
-			grab_objectname(name, obj->oid.hash, v, &used_atom[i]);
+			grab_objectname(name, obj->oid.hash, v, &used_atoms[i]);
 	}
 }
 
@@ -786,7 +786,7 @@ static void grab_tag_values(struct atom_value *val, int deref, struct object *ob
 	struct tag *tag = (struct tag *) obj;
 
 	for (i = 0; i < used_atom_cnt; i++) {
-		const char *name = used_atom[i].name;
+		const char *name = used_atoms[i].name;
 		struct atom_value *v = &val[i];
 		if (!!deref != (*name == '*'))
 			continue;
@@ -808,7 +808,7 @@ static void grab_commit_values(struct atom_value *val, int deref, struct object
 	struct commit *commit = (struct commit *) obj;
 
 	for (i = 0; i < used_atom_cnt; i++) {
-		const char *name = used_atom[i].name;
+		const char *name = used_atoms[i].name;
 		struct atom_value *v = &val[i];
 		if (!!deref != (*name == '*'))
 			continue;
@@ -938,7 +938,7 @@ static void grab_person(const char *who, struct atom_value *val, int deref, stru
 	const char *wholine = NULL;
 
 	for (i = 0; i < used_atom_cnt; i++) {
-		const char *name = used_atom[i].name;
+		const char *name = used_atoms[i].name;
 		struct atom_value *v = &val[i];
 		if (!!deref != (*name == '*'))
 			continue;
@@ -976,7 +976,7 @@ static void grab_person(const char *who, struct atom_value *val, int deref, stru
 	if (!wholine)
 		return;
 	for (i = 0; i < used_atom_cnt; i++) {
-		const char *name = used_atom[i].name;
+		const char *name = used_atoms[i].name;
 		struct atom_value *v = &val[i];
 		if (!!deref != (*name == '*'))
 			continue;
@@ -1066,7 +1066,7 @@ static void grab_sub_body_contents(struct atom_value *val, int deref, struct obj
 	unsigned long sublen = 0, bodylen = 0, nonsiglen = 0, siglen = 0;
 
 	for (i = 0; i < used_atom_cnt; i++) {
-		struct used_atom *atom = &used_atom[i];
+		struct used_atom *atom = &used_atoms[i];
 		const char *name = atom->name;
 		struct atom_value *v = &val[i];
 		if (!!deref != (*name == '*'))
@@ -1127,7 +1127,7 @@ static void fill_missing_values(struct atom_value *val)
 
 /*
  * val is a list of atom_value to hold returned values.  Extract
- * the values for atoms in used_atom array out of (obj, buf, sz).
+ * the values for atoms in used_atoms array out of (obj, buf, sz).
  * when deref is false, (obj, buf, sz) is the object that is
  * pointed at by the ref itself; otherwise it is the object the
  * ref (which is a tag) refers to.
@@ -1376,8 +1376,8 @@ static void populate_value(struct ref_array_item *ref)
 
 	/* Fill in specials first */
 	for (i = 0; i < used_atom_cnt; i++) {
-		struct used_atom *atom = &used_atom[i];
-		const char *name = used_atom[i].name;
+		struct used_atom *atom = &used_atoms[i];
+		const char *name = used_atoms[i].name;
 		struct atom_value *v = &ref->value[i];
 		int deref = 0;
 		const char *refname;
@@ -2059,7 +2059,7 @@ static int cmp_ref_sorting(struct ref_sorting *s, struct ref_array_item *a, stru
 {
 	struct atom_value *va, *vb;
 	int cmp;
-	cmp_type cmp_type = used_atom[s->atom].type;
+	cmp_type cmp_type = used_atoms[s->atom].type;
 	int (*cmp_fn)(const char *, const char *);
 
 	get_ref_atom_value(a, s->atom, &va);

--
https://github.com/git/git/pull/450

  parent reply	other threads:[~2018-01-09 13:06 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-09 13:05 [PATCH 01/20] cat-file: split expand_atom into 2 functions Olga Telezhnaya
2018-01-09 13:05 ` [PATCH 20/20] cat-file: make cat_file_info variable independent Olga Telezhnaya
2018-01-09 13:05 ` [PATCH 09/20] cat-file: get rid of goto in ref-filter Olga Telezhnaya
2018-01-09 13:05 ` [PATCH 02/20] cat-file: reuse struct ref_format Olga Telezhnaya
2018-01-09 13:05 ` [PATCH 07/20] cat-file: reuse parse_ref_filter_atom Olga Telezhnaya
2018-01-09 23:32   ` Junio C Hamano
2018-01-09 13:05 ` [PATCH 05/20] cat-file: move struct expand_data into ref-filter Olga Telezhnaya
2018-01-09 13:05 ` [PATCH 08/20] cat-file: remove unused code Olga Telezhnaya
2018-01-09 13:05 ` [PATCH 19/20] cat-file: move skip_object_info into ref-filter Olga Telezhnaya
2018-01-09 13:05 ` [PATCH 13/20] cat-file: start use ref_array_item struct Olga Telezhnaya
2018-01-09 13:05 ` [PATCH 12/20] cat-file: rename variable in ref-filter Olga Telezhnaya
2018-01-09 13:05 ` [PATCH 04/20] cat-file: make valid_atoms as a function parameter Olga Telezhnaya
2018-01-09 22:16   ` Junio C Hamano
2018-01-09 13:05 ` [PATCH 17/20] cat-file: add is_cat flag in ref-filter Olga Telezhnaya
2018-01-09 13:05 ` [PATCH 15/20] cat-file: start reusing populate_value Olga Telezhnaya
2018-01-09 13:05 ` [PATCH 14/20] cat-file: make populate_value global Olga Telezhnaya
2018-01-09 13:05 ` [PATCH 10/20] cat-file: simplify expand_atom function Olga Telezhnaya
2018-01-09 13:05 ` Olga Telezhnaya [this message]
2018-01-09 22:04   ` [PATCH 03/20] cat-file: rename variables in ref-filter Junio C Hamano
2018-01-10  7:07     ` Оля Тележная
2018-01-09 13:05 ` [PATCH 06/20] cat-file: start migrating to ref-filter Olga Telezhnaya
2018-01-09 13:05 ` [PATCH 18/20] cat-file: add split_on_whitespace flag Olga Telezhnaya
2018-01-09 13:05 ` [PATCH 11/20] cat-file: get rid of duplicate checking Olga Telezhnaya
2018-01-09 13:05 ` [PATCH 16/20] cat-file: get rid of expand_atom_into_fields Olga Telezhnaya
2018-01-10  9:36 ` [PATCH v2 01/18] cat-file: split expand_atom into 2 functions Olga Telezhnaya
2018-01-10  9:36   ` [PATCH v2 16/18] ref_format: add split_on_whitespace flag Olga Telezhnaya
2018-01-10  9:36   ` [PATCH v2 03/18] ref-filter: make valid_atom as function parameter Olga Telezhnaya
2018-01-15 21:42     ` Jeff King
2018-01-16  6:55       ` Оля Тележная
2018-01-17 21:43         ` Jeff King
2018-01-17 22:39           ` Christian Couder
2018-01-18  6:20             ` Оля Тележная
2018-01-18 11:49               ` Оля Тележная
2018-01-18 14:23                 ` Christian Couder
2018-01-19 12:24                   ` Оля Тележная
2018-01-19 15:48                     ` Christian Couder
2018-01-19 17:14               ` Christian Couder
2018-01-19 17:22                 ` Оля Тележная
2018-01-19 17:57                   ` Christian Couder
2018-01-19 17:23                 ` Jeff King
2018-01-19 17:31                   ` Christian Couder
2018-01-19 18:47                   ` Junio C Hamano
2018-01-19 20:12                     ` Jeff King
2018-01-10  9:36   ` [PATCH v2 07/18] cat-file: remove unused code Olga Telezhnaya
2018-01-10  9:36   ` [PATCH v2 06/18] ref-filter: reuse parse_ref_filter_atom Olga Telezhnaya
2018-01-10  9:36   ` [PATCH v2 02/18] cat-file: reuse struct ref_format Olga Telezhnaya
2018-01-15 21:37     ` Jeff King
2018-01-16  9:45       ` Оля Тележная
2018-01-10  9:36   ` [PATCH v2 08/18] ref-filter: get rid of goto Olga Telezhnaya
2018-01-10  9:36   ` [PATCH v2 13/18] cat-file: start reusing populate_value Olga Telezhnaya
2018-01-10  9:36   ` [PATCH v2 18/18] ref-filter: make cat_file_info independent Olga Telezhnaya
2018-01-10  9:36   ` [PATCH v2 12/18] ref-filter: make populate_value global Olga Telezhnaya
2018-01-10  9:36   ` [PATCH v2 09/18] cat-file: simplify expand_atom function Olga Telezhnaya
2018-01-10  9:36   ` [PATCH v2 05/18] cat-file: start migrating to ref-filter Olga Telezhnaya
2018-01-10  9:36   ` [PATCH v2 15/18] ref-filter: add is_cat flag Olga Telezhnaya
2018-01-10  9:36   ` [PATCH v2 14/18] ref-filter: get rid of expand_atom_into_fields Olga Telezhnaya
2018-01-10  9:36   ` [PATCH v2 04/18] cat-file: move struct expand_data into ref-filter Olga Telezhnaya
2018-01-15 21:44     ` Jeff King
2018-01-16  7:00       ` Оля Тележная
2018-01-17 21:45         ` Jeff King
2018-01-18  5:56           ` Оля Тележная
2018-01-10  9:36   ` [PATCH v2 17/18] cat-file: move skip_object_info " Olga Telezhnaya
2018-01-10  9:36   ` [PATCH v2 11/18] cat-file: start use ref_array_item struct Olga Telezhnaya
2018-01-10  9:36   ` [PATCH v2 10/18] cat-file: get rid of duplicate checking Olga Telezhnaya
2018-01-15 21:33   ` [PATCH v2 01/18] cat-file: split expand_atom into 2 functions Jeff King
2018-01-15 22:09     ` Jeff King
2018-01-16  7:22       ` Оля Тележная
2018-01-17 21:49         ` Jeff King
2018-01-17 23:04           ` Christian Couder
2018-01-18  6:22             ` Оля Тележная
2018-01-18  8:45               ` Christian Couder

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=01020160db067bde-7f500636-b80e-4099-a84e-2613126c9aa1-000000@eu-west-1.amazonses.com \
    --to=olyatelezhnaya@gmail.com \
    --cc=git@vger.kernel.org \
    --subject='Re: [PATCH 03/20] cat-file: rename variables in ref-filter' \
    /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

git@vger.kernel.org list mirror (unofficial, one of many)

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 git git/ https://public-inbox.org/git \
		git@vger.kernel.org
	public-inbox-index git

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.version-control.git
	nntp://ie5yzdi7fg72h7s4sdcztq5evakq23rdt33mfyfcddc5u3ndnw24ogqd.onion/inbox.comp.version-control.git
	nntp://4uok3hntl7oi7b4uf4rtfwefqeexfzil2w6kgk2jn5z2f764irre7byd.onion/inbox.comp.version-control.git
	nntp://news.gmane.io/gmane.comp.version-control.git
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

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

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git