diff mbox series

[5/7,RFC] config: make `scope_name` global as `config_scope_name`

Message ID 04eb98389880c96e1dc18131031e9d6ad5830a40.1579598053.git.bert.wesarg@googlemail.com (mailing list archive)
State New, archived
Headers show
Series remote rename: improve handling of configuration values | expand

Commit Message

Bert Wesarg Jan. 21, 2020, 9:24 a.m. UTC
Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---
Will be replaced by Matthew Rogers.

Cc: Matthew Rogers <mattr94@gmail.com>
---
 config.c               | 16 ++++++++++++++++
 config.h               |  1 +
 t/helper/test-config.c | 17 +----------------
 3 files changed, 18 insertions(+), 16 deletions(-)

Comments

Matt Rogers Jan. 22, 2020, 12:12 a.m. UTC | #1
Logos good to me...

As I'm a bit new, what would be the best way for me to work this into
my workflow?

On Tue, Jan 21, 2020 at 4:25 AM Bert Wesarg <bert.wesarg@googlemail.com> wrote:
>
> Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
> ---
> Will be replaced by Matthew Rogers.
>
> Cc: Matthew Rogers <mattr94@gmail.com>
> ---
>  config.c               | 16 ++++++++++++++++
>  config.h               |  1 +
>  t/helper/test-config.c | 17 +----------------
>  3 files changed, 18 insertions(+), 16 deletions(-)
>
> diff --git a/config.c b/config.c
> index d75f88ca0c..4c461bb7a3 100644
> --- a/config.c
> +++ b/config.c
> @@ -3317,6 +3317,22 @@ enum config_scope current_config_scope(void)
>                 return current_parsing_scope;
>  }
>
> +const char *config_scope_name(enum config_scope scope)
> +{
> +       switch (scope) {
> +       case CONFIG_SCOPE_SYSTEM:
> +               return "system";
> +       case CONFIG_SCOPE_GLOBAL:
> +               return "global";
> +       case CONFIG_SCOPE_REPO:
> +               return "repo";
> +       case CONFIG_SCOPE_CMDLINE:
> +               return "cmdline";
> +       default:
> +               return "unknown";
> +       }
> +}
> +
>  int lookup_config(const char **mapping, int nr_mapping, const char *var)
>  {
>         int i;
> diff --git a/config.h b/config.h
> index 91fd4c5e96..c063f33ff6 100644
> --- a/config.h
> +++ b/config.h
> @@ -301,6 +301,7 @@ enum config_scope {
>         CONFIG_SCOPE_REPO,
>         CONFIG_SCOPE_CMDLINE,
>  };
> +const char *config_scope_name(enum config_scope scope);
>
>  enum config_scope current_config_scope(void);
>  const char *current_config_origin_type(void);
> diff --git a/t/helper/test-config.c b/t/helper/test-config.c
> index 214003d5b2..1e3bc7c8f4 100644
> --- a/t/helper/test-config.c
> +++ b/t/helper/test-config.c
> @@ -37,21 +37,6 @@
>   *
>   */
>
> -static const char *scope_name(enum config_scope scope)
> -{
> -       switch (scope) {
> -       case CONFIG_SCOPE_SYSTEM:
> -               return "system";
> -       case CONFIG_SCOPE_GLOBAL:
> -               return "global";
> -       case CONFIG_SCOPE_REPO:
> -               return "repo";
> -       case CONFIG_SCOPE_CMDLINE:
> -               return "cmdline";
> -       default:
> -               return "unknown";
> -       }
> -}
>  static int iterate_cb(const char *var, const char *value, void *data)
>  {
>         static int nr;
> @@ -63,7 +48,7 @@ static int iterate_cb(const char *var, const char *value, void *data)
>         printf("value=%s\n", value ? value : "(null)");
>         printf("origin=%s\n", current_config_origin_type());
>         printf("name=%s\n", current_config_name());
> -       printf("scope=%s\n", scope_name(current_config_scope()));
> +       printf("scope=%s\n", config_scope_name(current_config_scope()));
>
>         return 0;
>  }
> --
> 2.24.1.497.g9abd7b20b4.dirty
>
Bert Wesarg Jan. 22, 2020, 7:37 a.m. UTC | #2
On Wed, Jan 22, 2020 at 1:12 AM Matt Rogers <mattr94@gmail.com> wrote:
>
> Logos good to me...
>
> As I'm a bit new, what would be the best way for me to work this into
> my workflow?

if you have done that change already locally, then you can ignore my
patch. I will wait for your re-roll and put my changes on top of
yours. If not, you could replace your patch with this one in your
series. Your call.

Bert

>
> On Tue, Jan 21, 2020 at 4:25 AM Bert Wesarg <bert.wesarg@googlemail.com> wrote:
> >
> > Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
> > ---
> > Will be replaced by Matthew Rogers.
> >
> > Cc: Matthew Rogers <mattr94@gmail.com>
> > ---
> >  config.c               | 16 ++++++++++++++++
> >  config.h               |  1 +
> >  t/helper/test-config.c | 17 +----------------
> >  3 files changed, 18 insertions(+), 16 deletions(-)
> >
> > diff --git a/config.c b/config.c
> > index d75f88ca0c..4c461bb7a3 100644
> > --- a/config.c
> > +++ b/config.c
> > @@ -3317,6 +3317,22 @@ enum config_scope current_config_scope(void)
> >                 return current_parsing_scope;
> >  }
> >
> > +const char *config_scope_name(enum config_scope scope)
> > +{
> > +       switch (scope) {
> > +       case CONFIG_SCOPE_SYSTEM:
> > +               return "system";
> > +       case CONFIG_SCOPE_GLOBAL:
> > +               return "global";
> > +       case CONFIG_SCOPE_REPO:
> > +               return "repo";
> > +       case CONFIG_SCOPE_CMDLINE:
> > +               return "cmdline";
> > +       default:
> > +               return "unknown";
> > +       }
> > +}
> > +
> >  int lookup_config(const char **mapping, int nr_mapping, const char *var)
> >  {
> >         int i;
> > diff --git a/config.h b/config.h
> > index 91fd4c5e96..c063f33ff6 100644
> > --- a/config.h
> > +++ b/config.h
> > @@ -301,6 +301,7 @@ enum config_scope {
> >         CONFIG_SCOPE_REPO,
> >         CONFIG_SCOPE_CMDLINE,
> >  };
> > +const char *config_scope_name(enum config_scope scope);
> >
> >  enum config_scope current_config_scope(void);
> >  const char *current_config_origin_type(void);
> > diff --git a/t/helper/test-config.c b/t/helper/test-config.c
> > index 214003d5b2..1e3bc7c8f4 100644
> > --- a/t/helper/test-config.c
> > +++ b/t/helper/test-config.c
> > @@ -37,21 +37,6 @@
> >   *
> >   */
> >
> > -static const char *scope_name(enum config_scope scope)
> > -{
> > -       switch (scope) {
> > -       case CONFIG_SCOPE_SYSTEM:
> > -               return "system";
> > -       case CONFIG_SCOPE_GLOBAL:
> > -               return "global";
> > -       case CONFIG_SCOPE_REPO:
> > -               return "repo";
> > -       case CONFIG_SCOPE_CMDLINE:
> > -               return "cmdline";
> > -       default:
> > -               return "unknown";
> > -       }
> > -}
> >  static int iterate_cb(const char *var, const char *value, void *data)
> >  {
> >         static int nr;
> > @@ -63,7 +48,7 @@ static int iterate_cb(const char *var, const char *value, void *data)
> >         printf("value=%s\n", value ? value : "(null)");
> >         printf("origin=%s\n", current_config_origin_type());
> >         printf("name=%s\n", current_config_name());
> > -       printf("scope=%s\n", scope_name(current_config_scope()));
> > +       printf("scope=%s\n", config_scope_name(current_config_scope()));
> >
> >         return 0;
> >  }
> > --
> > 2.24.1.497.g9abd7b20b4.dirty
> >
>
>
> --
> Matthew Rogers
Matt Rogers Jan. 23, 2020, 1:30 a.m. UTC | #3
I'll just put it into my local changes, and then reroll.  I should
have it up within a couple of days at the latest.
diff mbox series

Patch

diff --git a/config.c b/config.c
index d75f88ca0c..4c461bb7a3 100644
--- a/config.c
+++ b/config.c
@@ -3317,6 +3317,22 @@  enum config_scope current_config_scope(void)
 		return current_parsing_scope;
 }
 
+const char *config_scope_name(enum config_scope scope)
+{
+	switch (scope) {
+	case CONFIG_SCOPE_SYSTEM:
+		return "system";
+	case CONFIG_SCOPE_GLOBAL:
+		return "global";
+	case CONFIG_SCOPE_REPO:
+		return "repo";
+	case CONFIG_SCOPE_CMDLINE:
+		return "cmdline";
+	default:
+		return "unknown";
+	}
+}
+
 int lookup_config(const char **mapping, int nr_mapping, const char *var)
 {
 	int i;
diff --git a/config.h b/config.h
index 91fd4c5e96..c063f33ff6 100644
--- a/config.h
+++ b/config.h
@@ -301,6 +301,7 @@  enum config_scope {
 	CONFIG_SCOPE_REPO,
 	CONFIG_SCOPE_CMDLINE,
 };
+const char *config_scope_name(enum config_scope scope);
 
 enum config_scope current_config_scope(void);
 const char *current_config_origin_type(void);
diff --git a/t/helper/test-config.c b/t/helper/test-config.c
index 214003d5b2..1e3bc7c8f4 100644
--- a/t/helper/test-config.c
+++ b/t/helper/test-config.c
@@ -37,21 +37,6 @@ 
  *
  */
 
-static const char *scope_name(enum config_scope scope)
-{
-	switch (scope) {
-	case CONFIG_SCOPE_SYSTEM:
-		return "system";
-	case CONFIG_SCOPE_GLOBAL:
-		return "global";
-	case CONFIG_SCOPE_REPO:
-		return "repo";
-	case CONFIG_SCOPE_CMDLINE:
-		return "cmdline";
-	default:
-		return "unknown";
-	}
-}
 static int iterate_cb(const char *var, const char *value, void *data)
 {
 	static int nr;
@@ -63,7 +48,7 @@  static int iterate_cb(const char *var, const char *value, void *data)
 	printf("value=%s\n", value ? value : "(null)");
 	printf("origin=%s\n", current_config_origin_type());
 	printf("name=%s\n", current_config_name());
-	printf("scope=%s\n", scope_name(current_config_scope()));
+	printf("scope=%s\n", config_scope_name(current_config_scope()));
 
 	return 0;
 }