Thread (3 messages) 3 messages, 2 authors, 2016-06-15

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

From: Matthieu Moy <hidden>
Date: 2016-06-15 23:02:15

Possibly related (same subject, not in this thread)

Tanay Abhra [off-list ref] 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.
+	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.
 		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/
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help