Skip to contentSkip to conversation

submodule--helper.c: Rename 'cb_foreach' to 'foreach_cb'

PATCH Superseded Shourya Shukla 2 participants 5 messages Mar 18, 2020

lore
Share & tools
lore
#0 lore raw

cover submodule--helper.c: Rename 'cb_foreach' to 'foreach_cb'

Subcommands in 'submodule--helper.c' which give a callback to other functions have structures and macros named in the format: 'subcommand_cb' and 'SUBCOMMAND_CB_INIT' respectively.

The subcommand 'foreach' did not follow this convention and therefore had the naming of the form: 'struct foreach_cb' and 'CB_FOREACH_INIT'. Rename these to: 'struct foreach_cb' and 'FOREACH_CB_INIT' respectively.

Shourya Shukla (1):
submodule--helper.c: Rename 'cb_foreach' to 'foreach_cb'

 builtin/submodule--helper.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/1 submodule--helper.c: Rename 'cb_foreach' to 'foreach_cb'

In 'submodule--helper.c', the structures and macros for callbacks belonging to any subcommand are named in the format: 'subcommand_cb' and 'SUBCOMMAND_CB_INIT' respectively.

This was an exception for the subcommand 'foreach' of the command 'submodule'. Rename the aforementioned structures and macros:
'struct foreach_cb' to 'struct cb_foreach' and 'CB_FOREACH_INIT' to 'FOREACH_CB_INIT'.

---
 builtin/submodule--helper.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
builtin/submodule--helper.c +4 -4
index 86a608eec1..1a4b391c88 100644
@@ -444,19 +444,19 @@ static void for_each_listed_submodule(const struct module_list *list,
 		fn(list->entries[i], cb_data);
 }
 
-struct cb_foreach {
+struct foreach_cb {
 	int argc;
 	const char **argv;
 	const char *prefix;
 	int quiet;
 	int recursive;
 };
-#define CB_FOREACH_INIT { 0 }
+#define FOREACH_CB_INIT { 0 }
 
 static void runcommand_in_submodule_cb(const struct cache_entry *list_item,
 				       void *cb_data)
 {
-	struct cb_foreach *info = cb_data;
+	struct foreach_cb *info = cb_data;
 	const char *path = list_item->name;
 	const struct object_id *ce_oid = &list_item->oid;
 
@@ -557,7 +557,7 @@ static void runcommand_in_submodule_cb(const struct cache_entry *list_item,
 
 static int module_foreach(int argc, const char **argv, const char *prefix)
 {
-	struct cb_foreach info = CB_FOREACH_INIT;
+	struct foreach_cb info = FOREACH_CB_INIT;
 	struct pathspec pathspec;
 	struct module_list list = MODULE_LIST_INIT;
 
Signature · 1 line
2.20.1
#2 lore raw
Quoted 8 lines · Shourya Shukla

In 'submodule--helper.c', the structures and macros for callbacks belonging to any subcommand are named in the format: 'subcommand_cb' and 'SUBCOMMAND_CB_INIT' respectively.

This was an exception for the subcommand 'foreach' of the command 'submodule'. Rename the aforementioned structures and macros:
'struct foreach_cb' to 'struct cb_foreach' and 'CB_FOREACH_INIT' to 'FOREACH_CB_INIT'.

I believe your "<before> to <after>" statements are reversed.

Quoted 33 lines
---
 builtin/submodule--helper.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
builtin/submodule--helper.c +3 -3
index 86a608eec1..1a4b391c88 100644
@@ -444,19 +444,19 @@ static void for_each_listed_submodule(const struct module_list *list,
 		fn(list->entries[i], cb_data);
 }
 
-struct cb_foreach {
+struct foreach_cb {
 	int argc;
 	const char **argv;
 	const char *prefix;
 	int quiet;
 	int recursive;
 };
-#define CB_FOREACH_INIT { 0 }
+#define FOREACH_CB_INIT { 0 }
 
 static void runcommand_in_submodule_cb(const struct cache_entry *list_item,
 				       void *cb_data)
 {
-	struct cb_foreach *info = cb_data;
+	struct foreach_cb *info = cb_data;
 	const char *path = list_item->name;
 	const struct object_id *ce_oid = &list_item->oid;
 

builtin/submodule--helper.c static void runcommand_in_submodule_cb(const struct cache_entry *list_item, · line 562

Quoted 7 lines
builtin/submodule--helper.c +1 -1
@@ -557,7 +557,7 @@ static void runcommand_in_submodule_cb(const struct cache_entry *list_item,
 
 static int module_foreach(int argc, const char **argv, const char *prefix)
 {
-	struct cb_foreach info = CB_FOREACH_INIT;
+	struct foreach_cb info = FOREACH_CB_INIT;
 	struct pathspec pathspec;
 	struct module_list list = MODULE_LIST_INIT;

Based on the description, I was worried this patch would be very large. The fact that the change is so small makes this reasonable in isolation.

Thanks,
-Stolee

#3 lore raw

v2 cover submodule--helper.c: Rename 'cb_foreach' to 'foreach_cb'

In reply to Shourya Shukla

Subcommands in 'submodule--helper.c' which give a callback to other functions have structures and macros named in the format: 'subcommand_cb' and 'SUBCOMMAND_CB_INIT' respectively.

The subcommand 'foreach' did not follow this convention and therefore had the naming of the form: 'struct foreach_cb' and 'CB_FOREACH_INIT'. Rename these to: 'struct foreach_cb' and 'FOREACH_CB_INIT' respectively.

Changes in v2:
Reworded the commit message. The last statement was wrong. Changed it from:
"Rename the aforementioned structures and macros:
'struct foreach_cb' to 'struct cb_foreach' and 'CB_FOREACH_INIT' to 'FOREACH_CB_INIT'."
;to:
"Rename the aforementioned structures and macros:
'struct cb_foreach' to 'struct foreach_cb' and 'CB_FOREACH_INIT' to 'FOREACH_CB_INIT'."

Shourya Shukla (1):
submodule--helper.c: Rename 'cb_foreach' to 'foreach_cb'

 builtin/submodule--helper.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
Signature · 1 line
2.20.1
#4 lore raw

PATCH v2 1/1 submodule--helper.c: Rename 'cb_foreach' to 'foreach_cb'

In 'submodule--helper.c', the structures and macros for callbacks belonging to any subcommand are named in the format: 'subcommand_cb' and 'SUBCOMMAND_CB_INIT' respectively.

This was an exception for the subcommand 'foreach' of the command 'submodule'. Rename the aforementioned structures and macros:
'struct cb_foreach' to 'struct foreach_cb' and 'CB_FOREACH_INIT' to 'FOREACH_CB_INIT'.

---
 builtin/submodule--helper.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
builtin/submodule--helper.c +4 -4
index 86a608eec1..1a4b391c88 100644
@@ -444,19 +444,19 @@ static void for_each_listed_submodule(const struct module_list *list,
 		fn(list->entries[i], cb_data);
 }
 
-struct cb_foreach {
+struct foreach_cb {
 	int argc;
 	const char **argv;
 	const char *prefix;
 	int quiet;
 	int recursive;
 };
-#define CB_FOREACH_INIT { 0 }
+#define FOREACH_CB_INIT { 0 }
 
 static void runcommand_in_submodule_cb(const struct cache_entry *list_item,
 				       void *cb_data)
 {
-	struct cb_foreach *info = cb_data;
+	struct foreach_cb *info = cb_data;
 	const char *path = list_item->name;
 	const struct object_id *ce_oid = &list_item->oid;
 
@@ -557,7 +557,7 @@ static void runcommand_in_submodule_cb(const struct cache_entry *list_item,
 
 static int module_foreach(int argc, const char **argv, const char *prefix)
 {
-	struct cb_foreach info = CB_FOREACH_INIT;
+	struct foreach_cb info = FOREACH_CB_INIT;
 	struct pathspec pathspec;
 	struct module_list list = MODULE_LIST_INIT;
 
Signature · 1 line
2.20.1