{"thread":{"id":"15730","subject":"[PATCH] Use \"git_config_string\" to simplify \"builtin-gc.c\" code where \"prune_expire\" is set","startedAt":"2008-09-30T19:05:49Z","lastAt":"2008-09-30T20:28:58Z","messageCount":5,"participants":["David Bryson","Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"91974","messageId":"20080930190549.GA9869@eratosthenes.cryptobackpack.org","threadId":"15730","inReplyTo":null,"subject":"[PATCH] Use \"git_config_string\" to simplify \"builtin-gc.c\" code where \"prune_expire\" is set","fromName":"David Bryson","fromEmail":"david@statichacks.org","sentAt":"2008-09-30T19:05:49Z","receivedAt":"2008-09-30T19:05:49Z","isPatch":true,"sender":{"key":"david@statichacks.org","avatar":"https://gravatar.com/avatar/b8796a0b286799d99dcbaea3fd3e8675648cc094ff10b07bae8fe3bc0ac40b9c?d=mp&s=160"},"body":"Hi all,\nThis is a quick janitor patch and my first patch sent to the git mailing\nlist.  Please let me know if I have done any process of the patch\nsubmission wrong, and if I got the Janitorial task done in the proper\nfashion.\n\nSigned-off-by: David Bryson <david@statichacks.org>\n---\n builtin-gc.c |    7 ++-----\n 1 files changed, 2 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin-gc.c b/builtin-gc.c\nindex fac200e..6260652 100644\n--- a/builtin-gc.c\n+++ b/builtin-gc.c\n@@ -57,15 +57,12 @@ static int gc_config(const char *var, const char *value, void *cb)\n \t\treturn 0;\n \t}\n \tif (!strcmp(var, \"gc.pruneexpire\")) {\n-\t\tif (!value)\n-\t\t\treturn config_error_nonbool(var);\n-\t\tif (strcmp(value, \"now\")) {\n+\t\tif (value && strcmp(value, \"now\")) {\n \t\t\tunsigned long now = approxidate(\"now\");\n \t\t\tif (approxidate(value) >= now)\n \t\t\t\treturn error(\"Invalid %s: '%s'\", var, value);\n \t\t}\n-\t\tprune_expire = xstrdup(value);\n-\t\treturn 0;\n+\t\treturn git_config_string(&prune_expire, var, value);\n \t}\n \treturn git_default_config(var, value, cb);\n }\n-- \n1.6.0.2\n"},{"id":"91976","messageId":"20080930193725.GJ21310@spearce.org","threadId":"15730","inReplyTo":"20080930190549.GA9869@eratosthenes.cryptobackpack.org","subject":"Re: [PATCH] Use \"git_config_string\" to simplify \"builtin-gc.c\" code where \"prune_expire\" is set","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-09-30T19:37:25Z","receivedAt":"2008-09-30T19:37:25Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"David Bryson <david@statichacks.org> wrote:\n> Hi all,\n> This is a quick janitor patch and my first patch sent to the git mailing\n> list.  Please let me know if I have done any process of the patch\n> submission wrong, and if I got the Janitorial task done in the proper\n> fashion.\n\nThis part of the message probably should go after the \"---\" line.\nEverything above \"---\" goes into the commit message, everything\nafter it is automatically cut by git-am.\n\nThis sort of \"Hi, I'm new\" isn't very useful in the long term in\nthe project logs, but its still useful to introduce yourself.  ;-)\n \n> Signed-off-by: David Bryson <david@statichacks.org>\n> ---\n>  builtin-gc.c |    7 ++-----\n>  1 files changed, 2 insertions(+), 5 deletions(-)\n> \n> diff --git a/builtin-gc.c b/builtin-gc.c\n> index fac200e..6260652 100644\n> --- a/builtin-gc.c\n> +++ b/builtin-gc.c\n> @@ -57,15 +57,12 @@ static int gc_config(const char *var, const char *value, void *cb)\n>  \t\treturn 0;\n>  \t}\n>  \tif (!strcmp(var, \"gc.pruneexpire\")) {\n> -\t\tif (!value)\n> -\t\t\treturn config_error_nonbool(var);\n> -\t\tif (strcmp(value, \"now\")) {\n> +\t\tif (value && strcmp(value, \"now\")) {\n>  \t\t\tunsigned long now = approxidate(\"now\");\n>  \t\t\tif (approxidate(value) >= now)\n>  \t\t\t\treturn error(\"Invalid %s: '%s'\", var, value);\n>  \t\t}\n> -\t\tprune_expire = xstrdup(value);\n> -\t\treturn 0;\n> +\t\treturn git_config_string(&prune_expire, var, value);\n>  \t}\n>  \treturn git_default_config(var, value, cb);\n>  }\n\n-- \nShawn.\n"},{"id":"91978","messageId":"20080930195355.GA14499@eratosthenes.cryptobackpack.org","threadId":"15730","inReplyTo":"20080930190549.GA9869@eratosthenes.cryptobackpack.org","subject":"[PATCH] Use \"git_config_string\" to simplify \"builtin-gc.c\" code where \"prune_expire\" is set","fromName":"David Bryson","fromEmail":"david@statichacks.org","sentAt":"2008-09-30T19:53:55Z","receivedAt":"2008-09-30T19:53:55Z","isPatch":true,"sender":{"key":"david@statichacks.org","avatar":"https://gravatar.com/avatar/b8796a0b286799d99dcbaea3fd3e8675648cc094ff10b07bae8fe3bc0ac40b9c?d=mp&s=160"},"body":"\nSigned-off-by: David Bryson <david@statichacks.org>\n---\n builtin-gc.c |    7 ++-----\n 1 files changed, 2 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin-gc.c b/builtin-gc.c\nindex fac200e..6260652 100644\n--- a/builtin-gc.c\n+++ b/builtin-gc.c\n@@ -57,15 +57,12 @@ static int gc_config(const char *var, const char *value, void *cb)\n \t\treturn 0;\n \t}\n \tif (!strcmp(var, \"gc.pruneexpire\")) {\n-\t\tif (!value)\n-\t\t\treturn config_error_nonbool(var);\n-\t\tif (strcmp(value, \"now\")) {\n+\t\tif (value && strcmp(value, \"now\")) {\n \t\t\tunsigned long now = approxidate(\"now\");\n \t\t\tif (approxidate(value) >= now)\n \t\t\t\treturn error(\"Invalid %s: '%s'\", var, value);\n \t\t}\n-\t\tprune_expire = xstrdup(value);\n-\t\treturn 0;\n+\t\treturn git_config_string(&prune_expire, var, value);\n \t}\n \treturn git_default_config(var, value, cb);\n }\n-- \n1.6.0.2\n"},{"id":"91981","messageId":"20080930200423.GL21310@spearce.org","threadId":"15730","inReplyTo":"20080930195355.GA14499@eratosthenes.cryptobackpack.org","subject":"Re: [PATCH] Use \"git_config_string\" to simplify \"builtin-gc.c\" code where \"prune_expire\" is set","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-09-30T20:04:23Z","receivedAt":"2008-09-30T20:04:23Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"David Bryson <david@statichacks.org> wrote:\n> diff --git a/builtin-gc.c b/builtin-gc.c\n> index fac200e..6260652 100644\n> --- a/builtin-gc.c\n> +++ b/builtin-gc.c\n> @@ -57,15 +57,12 @@ static int gc_config(const char *var, const char *value, void *cb)\n>  \t\treturn 0;\n>  \t}\n>  \tif (!strcmp(var, \"gc.pruneexpire\")) {\n> -\t\tif (!value)\n> -\t\t\treturn config_error_nonbool(var);\n> -\t\tif (strcmp(value, \"now\")) {\n> +\t\tif (value && strcmp(value, \"now\")) {\n>  \t\t\tunsigned long now = approxidate(\"now\");\n>  \t\t\tif (approxidate(value) >= now)\n>  \t\t\t\treturn error(\"Invalid %s: '%s'\", var, value);\n>  \t\t}\n> -\t\tprune_expire = xstrdup(value);\n> -\t\treturn 0;\n> +\t\treturn git_config_string(&prune_expire, var, value);\n\nThe message formatting was a lot better.  But:\n\nbuiltin-gc.c:65: warning: passing argument 1 of 'git_config_string' from incompatible pointer type\n\n>From http://git.or.cz/gitwiki/Janitor:\n\n  This is because the first argument to \"git_config_string\" should\n  be a \"const char **\", not a \"char **\". There will be a compile\n  time warning if a \"char **\" is passed instead of a \"const char **\"\n  and the patch will be rejected. (And no, casting the \"char **\"\n  into a \"const char **\" is not a good solution either.)\"\n\n-- \nShawn.\n"},{"id":"91985","messageId":"20080930202858.GA1953@eratosthenes.cryptobackpack.org","threadId":"15730","inReplyTo":"20080930190549.GA9869@eratosthenes.cryptobackpack.org","subject":"[PATCH] Use \"git_config_string\" to simplify \"builtin-gc.c\" code where \"prune_expire\" is set","fromName":"David Bryson","fromEmail":"david@statichacks.org","sentAt":"2008-09-30T20:28:58Z","receivedAt":"2008-09-30T20:28:58Z","isPatch":true,"sender":{"key":"david@statichacks.org","avatar":"https://gravatar.com/avatar/b8796a0b286799d99dcbaea3fd3e8675648cc094ff10b07bae8fe3bc0ac40b9c?d=mp&s=160"},"body":"\nSigned-off-by: David Bryson <david@statichacks.org>\n---\nManage to fix the const char ** compile error, third time is a\nharm(hopefully!)\n\n builtin-gc.c |    9 +++------\n 1 files changed, 3 insertions(+), 6 deletions(-)\n\ndiff --git a/builtin-gc.c b/builtin-gc.c\nindex fac200e..7af65bb 100644\n--- a/builtin-gc.c\n+++ b/builtin-gc.c\n@@ -26,7 +26,7 @@ static int pack_refs = 1;\n static int aggressive_window = -1;\n static int gc_auto_threshold = 6700;\n static int gc_auto_pack_limit = 50;\n-static char *prune_expire = \"2.weeks.ago\";\n+static const char *prune_expire = \"2.weeks.ago\";\n \n #define MAX_ADD 10\n static const char *argv_pack_refs[] = {\"pack-refs\", \"--all\", \"--prune\", NULL};\n@@ -57,15 +57,12 @@ static int gc_config(const char *var, const char *value, void *cb)\n \t\treturn 0;\n \t}\n \tif (!strcmp(var, \"gc.pruneexpire\")) {\n-\t\tif (!value)\n-\t\t\treturn config_error_nonbool(var);\n-\t\tif (strcmp(value, \"now\")) {\n+\t\tif (value && strcmp(value, \"now\")) {\n \t\t\tunsigned long now = approxidate(\"now\");\n \t\t\tif (approxidate(value) >= now)\n \t\t\t\treturn error(\"Invalid %s: '%s'\", var, value);\n \t\t}\n-\t\tprune_expire = xstrdup(value);\n-\t\treturn 0;\n+\t\treturn git_config_string(&prune_expire, var, value);\n \t}\n \treturn git_default_config(var, value, cb);\n }\n-- \n1.6.0.2\n"}]}