@matheusbsbs / matheus-bagliano / commits / 8f5ff31f8e
Fork 0

repo-config: deconvolute logics

It was rightly noticed that the logic is quite convoluted. Fix that. Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>

Johannes Schindelin committed May 3, 2006 at 14:41 UTC 8f5ff31f8e74ac2f72c3c415beb2639bc36f7cb7
1 file changed +26 -24
repo-config.c
+26 -24
@@ -27,36 +27,38 @@ static int show_config(const char* key_, const char* value_)
27 {
28 char value[256];
29 const char *vptr = value;
30 + int dup_error = 0;
31
32 if (value_ == NULL)
33 value_ = "";
34
34 - if ((use_key_regexp || !strcmp(key_, key)) &&
35 - (!use_key_regexp ||
36 - !regexec(key_regexp, key_, 0, NULL, 0)) &&
37 - (regexp == NULL ||
35 + if (!use_key_regexp && strcmp(key_, key))
36 + return 0;
37 + if (use_key_regexp && regexec(key_regexp, key_, 0, NULL, 0))
38 + return 0;
39 + if (regexp != NULL &&
40 (do_not_match ^
39 - !regexec(regexp, value_, 0, NULL, 0)))) {
40 - int dup_error = 0;
41 - if (show_keys)
42 - printf("%s ", key_);
43 - if (seen && !do_all)
44 - dup_error = 1;
45 - if (type == T_INT)
46 - sprintf(value, "%d", git_config_int(key_, value_));
47 - else if (type == T_BOOL)
48 - sprintf(value, "%s", git_config_bool(key_, value_)
49 - ? "true" : "false");
50 - else
51 - vptr = value_;
52 - seen++;
53 - if (dup_error) {
54 - error("More than one value for the key %s: %s",
55 - key_, vptr);
56 - }
57 - else
58 - printf("%s\n", vptr);
41 + regexec(regexp, value_, 0, NULL, 0)))
42 + return 0;
43 +
44 + if (show_keys)
45 + printf("%s ", key_);
46 + if (seen && !do_all)
47 + dup_error = 1;
48 + if (type == T_INT)
49 + sprintf(value, "%d", git_config_int(key_, value_));
50 + else if (type == T_BOOL)
51 + vptr = git_config_bool(key_, value_) ? "true" : "false";
52 + else
53 + vptr = value_;
54 + seen++;
55 + if (dup_error) {
56 + error("More than one value for the key %s: %s",
57 + key_, vptr);
58 }
59 + else
60 + printf("%s\n", vptr);
61 +
62 return 0;
63 }
64