Hi, On Mon, 15 Jan 2007, Eric Wong wrote:A bit shorter (and gets the booleans right, plus being even easier towards --python extension): --- builtin-repo-config.c | 19 +++++++++++++++++-- 1 files changed, 17 insertions(+), 2 deletions(-) diff --git a/builtin-repo-config.c b/builtin-repo-config.c index 9063311..8ebf436 100644 --- a/builtin-repo-config.c +++ b/builtin-repo-config.c @@ -1,5 +1,6 @@ #include "builtin.h" #include "cache.h" +#include "quote.h" static const char git_config_set_usage[] = "git-repo-config [ --global ] [ --bool | --int ] [--get | --get-all | --get-regexp | --replace-all | --add | --unset | --unset-all] name [value [value_regex]] | --rename-section old_name new_name | --list"; @@ -12,11 +13,18 @@ static int use_key_regexp; static int do_all; static int do_not_match; static int seen; +static const char *perl_prefix = NULL; static enum { T_RAW, T_INT, T_BOOL } type = T_RAW; static int show_all_config(const char *key_, const char *value_) { - if (value_) + if (perl_prefix) { + printf("%s", perl_prefix); + perl_quote_print(stdout, key_); + printf(" => "); + perl_quote_print(stdout, value_ ? value_ : "true"); + perl_prefix = ",\n\t"; + } else if (value_) printf("%s=%s\n", key_, value_); else printf("%s\n", key_); @@ -138,7 +146,14 @@ int cmd_repo_config(int argc, const char **argv, const char *prefix) type = T_BOOL; else if (!strcmp(argv[1], "--list") || !strcmp(argv[1], "-l")) return git_config(show_all_config); - else if (!strcmp(argv[1], "--global")) { + else if (!strcmp(argv[1], "--perl")) { + int ret; + perl_prefix = "\n\t"; + printf("%%git_config = ("); + ret = git_config(show_all_config); + printf("\n);\n"); + return ret; + } else if (!strcmp(argv[1], "--global")) { char *home = getenv("HOME"); if (home) { char *user_config = xstrdup(mkpath("%s/.gitconfig", home)); - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
| Ingo Molnar | Re: [PATCH 6/6] sched: disabled rt-bandwidth by default |
| Maciej W. Rozycki | [PATCH 2/2] acpi: Disable IRQ 0 through I/O APIC for some HP systems |
| Greg Kroah-Hartman | [PATCH 001/196] Chinese: Add the known_regression URI to the HOWTO |
| Ryan Hope | reiser4 for 2.6.27-rc1 |
git: | |
| Johannes Schindelin | Re: [PATCH] use natural ordering to display list of branches. |
| David Kastrup | Terminology question about remote branches. |
| David Kastrup | Re: If you would write git from scratch now, what would you change? |
| Johannes Schindelin | [PATCH 1/2] clone: Add an option to set up a mirror |
| Martin Toft | Mysterious transfer speed differences |
| Joachim Schipper | Re: OpenBSD/alpha Status |
| Richard Daemon | OpenBSD 4.3 running in VirtualBox? Anyone have it working properly? |
| Diana Eichert | Re: In Memoriam: Jun-ichiro Hagino |
| binto | Before & After Under The Giant Lock |
| Florent Thoumie | Re: New wpi driver |
| Peter Jeremy | Re: repeatedly opening the same .so(s) is slow? |
| Dirk Engling | Re: Strange keyboard (viral?) behaviour |
