git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/4] fast-import.c: replace `git_config()` with `git_config_get_*()` family

From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Date
Aug 13, 2014, 11:24 UTC
Message-ID
<vpqppg4vdii.fsf@anie.imag.fr>
In-Reply-To
<1407918122-29973-1-git-send-email-tanayabh@gmail.com>
Tanay Abhra <tanayabh@gmail.com> writes:
>  fast-import.c | 42 +++++++++++++++++++-----------------------
>  1 file changed, 19 insertions(+), 23 deletions(-)
Only 4 lines less, how disappointing ;-).

More seriously, the old code was essentially dealing with special values, which your new code needs to do too, so you can hardly do any less.

Show 6 quoted lines
> +	if (!git_config_get_int("pack.compression", &pack_compression_level)) {
> +		if (pack_compression_level == -1)
> +			pack_compression_level = Z_DEFAULT_COMPRESSION;
> +		else if (pack_compression_level < 0 ||
> +			 pack_compression_level > Z_BEST_COMPRESSION)
> +			die("bad pack compression level %d", pack_compression_level);

That would be a good use for git_die_config(), to give a better error message, right?

> -	if (!strcmp(k, "pack.indexversion")) {
> -		pack_idx_opts.version = git_config_int(k, v);
> +	if (!git_config_get_int("pack.indexversion", &indexversion_value)) {
> +		pack_idx_opts.version = indexversion_value;

I wondered why you were not assigning to pack_idx_opts.version directly, but pack_idx_opts.version is uint32 and you don't have config_get_uint32, so it's OK.

Show 5 quoted lines
>  		if (pack_idx_opts.version > 2)
> -			die("bad pack.indexversion=%"PRIu32,
> -			    pack_idx_opts.version);
> -		return 0;
> +			die("bad pack.indexversion=%"PRIu32, pack_idx_opts.version);
One more opportunity for git_die_config()?

Not that it's terribly important, but I think it's good that your refactoring also brings a few end-users benefits. It will help you show off when you tell your friends what you did this summer (not "I did useless code churn" ;-) ), and helps everybody see the benefits of your GSoC ;-).

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Previous: Tanay AbhraNext: Tanay Abhra
Message 10 of 19 in “fast-import.c: replace `git_config()` with `git_config_get_*()` family”
  1. 1/4 fast-import.c: replace `git_config()` with `git_config_get_*()` familyTanay Abhra, Aug 13, 2014
  2. 2/4 ll-merge.c: refactor `read_merge_config()` to use `git_config_string()`Tanay Abhra, Aug 13, 2014
  3. Matthieu MoyAug 13, 2014
  4. 2/4 ll-merge.c: refactor `read_merge_config()` to use `git_config_string()`Tanay Abhra, Aug 13, 2014
  5. Matthieu MoyAug 13, 2014
  6. Junio C HamanoAug 13, 2014
  7. 3/4 merge-recursive.c: replace `git_config()` with `git_config_get_int()`Tanay Abhra, Aug 13, 2014
  8. Matthieu MoyAug 13, 2014
  9. 4/4 builtin/apply.c: replace `git_config()` with `git_config_get_string_const()`Tanay Abhra, Aug 13, 2014
  10. Matthieu MoyAug 13, 2014
  11. Tanay AbhraAug 13, 2014
  12. 1/5 fast-import.c: replace `git_config()` with `git_config_get_*()` familyTanay Abhra, Aug 13, 2014
  13. Matthieu MoyAug 13, 2014
  14. 1/2 git_default_config() rewritten using the config-set APITanay Abhra, Aug 13, 2014
  15. 2/2 use the new git_default_config()Tanay Abhra, Aug 13, 2014
  16. Matthieu MoyAug 13, 2014
  17. Junio C HamanoAug 13, 2014
  18. Matthieu MoyAug 13, 2014
  19. Junio C HamanoAug 13, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.