Use "git_config_string" to simplify "builtin-gc.c" code where "prune_expire" is set
PATCH 1/1 Use "git_config_string" to simplify "builtin-gc.c" code where "prune_expire" is set
Hi all,
This is a quick janitor patch and my first patch sent to the git mailing list. Please let me know if I have done any process of the patch submission wrong, and if I got the Janitorial task done in the proper fashion.
--- builtin-gc.c | 7 ++----- 1 files changed, 2 insertions(+), 5 deletions(-)
builtin-gc.c +2 -5
@@ -57,15 +57,12 @@ static int gc_config(const char *var, const char *value, void *cb)return 0 ; }if (!strcmp (var,"gc.pruneexpire" )) { -if (!value) -return config_error_nonbool (var); -if (strcmp (value,"now" )) { +if (value &&strcmp (value,"now" )) {unsigned long now =approxidate ("now" );if (approxidate (value) >= now)return error ("Invalid %s: '%s'" , var, value); } - prune_expire =xstrdup (value); -return 0 ; +return git_config_string (&prune_expire, var, value); }return git_default_config (var, value, cb); }
Signature · 1 line
1.6.0.2
Quoted 5 lines · David Bryson
Hi all,
This is a quick janitor patch and my first patch sent to the git mailing list. Please let me know if I have done any process of the patch submission wrong, and if I got the Janitorial task done in the proper fashion.
This part of the message probably should go after the "---" line. Everything above "---" goes into the commit message, everything after it is automatically cut by git-am.
This sort of "Hi, I'm new" isn't very useful in the long term in the project logs, but its still useful to introduce yourself. ;-)
Quoted 27 lines
Signed-off-by David Bryson <[email protected]>--- builtin-gc.c | 7 ++----- 1 files changed, 2 insertions(+), 5 deletions(-)builtin-gc.c +2
-5@@ -57,15 +57,12 @@ static int gc_config(const char *var, const char *value, void *cb)return 0 ; }if (!strcmp (var,"gc.pruneexpire" )) { -if (!value) -return config_error_nonbool (var); -if (strcmp (value,"now" )) { +if (value &&strcmp (value,"now" )) {unsigned long now =approxidate ("now" );if (approxidate (value) >= now)return error ("Invalid %s: '%s'" , var, value); } - prune_expire =xstrdup (value); -return 0 ; +return git_config_string (&prune_expire, var, value); }return git_default_config (var, value, cb); }
Signature · 1 line
Shawn.
PATCH 1/1 Use "git_config_string" to simplify "builtin-gc.c" code where "prune_expire" is set
In reply to David Bryson--- builtin-gc.c | 7 ++----- 1 files changed, 2 insertions(+), 5 deletions(-)
builtin-gc.c +2 -5
@@ -57,15 +57,12 @@ static int gc_config(const char *var, const char *value, void *cb)return 0 ; }if (!strcmp (var,"gc.pruneexpire" )) { -if (!value) -return config_error_nonbool (var); -if (strcmp (value,"now" )) { +if (value &&strcmp (value,"now" )) {unsigned long now =approxidate ("now" );if (approxidate (value) >= now)return error ("Invalid %s: '%s'" , var, value); } - prune_expire =xstrdup (value); -return 0 ; +return git_config_string (&prune_expire, var, value); }return git_default_config (var, value, cb); }
Signature · 1 line
1.6.0.2
Quoted 9 lines · David Bryson
builtin-gc.c +0
-1@@ -57,15 +57,12 @@ static int gc_config(const char *var, const char *value, void *cb)return 0 ; }if (!strcmp (var,"gc.pruneexpire" )) { -if (!value)
builtin-gc.c static int gc_config(const char *var, const char *value, void *cb) · line 65
Quoted 10 lines
builtin-gc.c +2
-4-return config_error_nonbool (var); -if (strcmp (value,"now" )) { +if (value &&strcmp (value,"now" )) {unsigned long now =approxidate ("now" );if (approxidate (value) >= now)return error ("Invalid %s: '%s'" , var, value); } - prune_expire =xstrdup (value); -return 0 ; +return git_config_string (&prune_expire, var, value);
The message formatting was a lot better. But:
builtin-gc.c:65: warning: passing argument 1 of 'git_config_string' from incompatible pointer type
Quoted 1 line
This is because the first argument to "git_config_string" should be a "const char **", not a "char **". There will be a compile time warning if a "char **" is passed instead of a "const char **" and the patch will be rejected. (And no, casting the "char **" into a "const char **" is not a good solution either.)"
Signature · 1 line
Shawn.
PATCH 1/1 Use "git_config_string" to simplify "builtin-gc.c" code where "prune_expire" is set
In reply to David Bryson---
Manage to fix the const char ** compile error, third time is a harm(hopefully!)
builtin-gc.c | 9 +++------ 1 files changed, 3 insertions(+), 6 deletions(-)
builtin-gc.c +3 -6
@@ -26,7 +26,7 @@ static int pack_refs = 1;static int aggressive_window =-1 ;static int gc_auto_threshold =6700 ;static int gc_auto_pack_limit =50 ; -static char *prune_expire ="2.weeks.ago" ; +static const char *prune_expire ="2.weeks.ago" ;#define MAX_ADD 10static const char *argv_pack_refs[] = {"pack-refs" ,"--all" ,"--prune" ,NULL };
@@ -57,15 +57,12 @@ static int gc_config(const char *var, const char *value, void *cb)return 0 ; }if (!strcmp (var,"gc.pruneexpire" )) { -if (!value) -return config_error_nonbool (var); -if (strcmp (value,"now" )) { +if (value &&strcmp (value,"now" )) {unsigned long now =approxidate ("now" );if (approxidate (value) >= now)return error ("Invalid %s: '%s'" , var, value); } - prune_expire =xstrdup (value); -return 0 ; +return git_config_string (&prune_expire, var, value); }return git_default_config (var, value, cb); }
Signature · 1 line
1.6.0.2