diff options
author | Patrick Steinhardt <ps@pks.im> | 2017-07-07 12:27:43 +0200 |
---|---|---|
committer | Patrick Steinhardt <ps@pks.im> | 2017-08-25 18:00:34 +0200 |
commit | 4467543ea76a59b1e10f20028da7779050f4953f (patch) | |
tree | fceb74df73d1fbcd92e3541b82cc1138dd9d06f3 | |
parent | 9bd836225ec606acdc9898cbf80c36dfcc0b564a (diff) | |
download | libgit2-4467543ea76a59b1e10f20028da7779050f4953f.tar.gz |
ignore: return early to avoid useless indentation
-rw-r--r-- | src/ignore.c | 50 |
1 files changed, 24 insertions, 26 deletions
diff --git a/src/ignore.c b/src/ignore.c index 283f5af01..f42f625eb 100644 --- a/src/ignore.c +++ b/src/ignore.c @@ -51,35 +51,33 @@ static int does_negate_pattern(git_attr_fnmatch *rule, git_attr_fnmatch *neg) git_attr_fnmatch *longer, *shorter; char *p; - if ((rule->flags & GIT_ATTR_FNMATCH_NEGATIVE) == 0 - && (neg->flags & GIT_ATTR_FNMATCH_NEGATIVE) != 0) { - - /* If lengths match we need to have an exact match */ - if (rule->length == neg->length) { - return strcmp(rule->pattern, neg->pattern) == 0; - } else if (rule->length < neg->length) { - shorter = rule; - longer = neg; - } else { - shorter = neg; - longer = rule; - } - - /* Otherwise, we need to check if the shorter - * rule is a basename only (that is, it contains - * no path separator) and, if so, if it - * matches the tail of the longer rule */ - p = longer->pattern + longer->length - shorter->length; + if ((rule->flags & GIT_ATTR_FNMATCH_NEGATIVE) != 0 + || (neg->flags & GIT_ATTR_FNMATCH_NEGATIVE) == 0) + return false; + + /* If lengths match we need to have an exact match */ + if (rule->length == neg->length) { + return strcmp(rule->pattern, neg->pattern) == 0; + } else if (rule->length < neg->length) { + shorter = rule; + longer = neg; + } else { + shorter = neg; + longer = rule; + } - if (p[-1] != '/') - return false; - if (memchr(shorter->pattern, '/', shorter->length) != NULL) - return false; + /* Otherwise, we need to check if the shorter + * rule is a basename only (that is, it contains + * no path separator) and, if so, if it + * matches the tail of the longer rule */ + p = longer->pattern + longer->length - shorter->length; - return memcmp(p, shorter->pattern, shorter->length) == 0; - } + if (p[-1] != '/') + return false; + if (memchr(shorter->pattern, '/', shorter->length) != NULL) + return false; - return false; + return memcmp(p, shorter->pattern, shorter->length) == 0; } /** |