Skip to content

Commit 526530a

Browse files
KarthikNayakgitster
authored andcommitted
ref-filter: remove unnecessary else clause
In 'ref-filter.c', there is an 'else' clause within `do_filter_refs()`. This is unnecessary since the 'if' clause calls `die()`, which would exit the program. So let's remove the unnecessary 'else' clause. This improves readability since the indentation is also reduced and flow is simpler. Signed-off-by: Karthik Nayak <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2b4648b commit 526530a

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

ref-filter.c

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3199,37 +3199,37 @@ static int do_filter_refs(struct ref_filter *filter, unsigned int type, each_ref
31993199
/* Simple per-ref filtering */
32003200
if (!filter->kind)
32013201
die("filter_refs: invalid type");
3202-
else {
3203-
/*
3204-
* For common cases where we need only branches or remotes or tags,
3205-
* we only iterate through those refs. If a mix of refs is needed,
3206-
* we iterate over all refs and filter out required refs with the help
3207-
* of filter_ref_kind().
3208-
*/
3209-
if (filter->kind == FILTER_REFS_BRANCHES)
3210-
ret = refs_for_each_fullref_in(get_main_ref_store(the_repository),
3211-
"refs/heads/", NULL,
3212-
fn, cb_data);
3213-
else if (filter->kind == FILTER_REFS_REMOTES)
3214-
ret = refs_for_each_fullref_in(get_main_ref_store(the_repository),
3215-
"refs/remotes/", NULL,
3216-
fn, cb_data);
3217-
else if (filter->kind == FILTER_REFS_TAGS)
3218-
ret = refs_for_each_fullref_in(get_main_ref_store(the_repository),
3219-
"refs/tags/", NULL, fn,
3220-
cb_data);
3221-
else if (filter->kind & FILTER_REFS_REGULAR)
3222-
ret = for_each_fullref_in_pattern(filter, fn, cb_data);
32233202

3224-
/*
3225-
* When printing all ref types, HEAD is already included,
3226-
* so we don't want to print HEAD again.
3227-
*/
3228-
if (!ret && !(filter->kind & FILTER_REFS_ROOT_REFS) &&
3229-
(filter->kind & FILTER_REFS_DETACHED_HEAD))
3230-
refs_head_ref(get_main_ref_store(the_repository), fn,
3231-
cb_data);
3232-
}
3203+
/*
3204+
* For common cases where we need only branches or remotes or tags,
3205+
* we only iterate through those refs. If a mix of refs is needed,
3206+
* we iterate over all refs and filter out required refs with the help
3207+
* of filter_ref_kind().
3208+
*/
3209+
if (filter->kind == FILTER_REFS_BRANCHES)
3210+
ret = refs_for_each_fullref_in(get_main_ref_store(the_repository),
3211+
"refs/heads/", NULL,
3212+
fn, cb_data);
3213+
else if (filter->kind == FILTER_REFS_REMOTES)
3214+
ret = refs_for_each_fullref_in(get_main_ref_store(the_repository),
3215+
"refs/remotes/", NULL,
3216+
fn, cb_data);
3217+
else if (filter->kind == FILTER_REFS_TAGS)
3218+
ret = refs_for_each_fullref_in(get_main_ref_store(the_repository),
3219+
"refs/tags/", NULL, fn,
3220+
cb_data);
3221+
else if (filter->kind & FILTER_REFS_REGULAR)
3222+
ret = for_each_fullref_in_pattern(filter, fn, cb_data);
3223+
3224+
/*
3225+
* When printing all ref types, HEAD is already included,
3226+
* so we don't want to print HEAD again.
3227+
*/
3228+
if (!ret && !(filter->kind & FILTER_REFS_ROOT_REFS) &&
3229+
(filter->kind & FILTER_REFS_DETACHED_HEAD))
3230+
refs_head_ref(get_main_ref_store(the_repository), fn,
3231+
cb_data);
3232+
32333233

32343234
clear_contains_cache(&filter->internal.contains_cache);
32353235
clear_contains_cache(&filter->internal.no_contains_cache);

0 commit comments

Comments
 (0)