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 <karthik.188@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Karthik Nayak committed
Jul 15, 2025 at 13:28 UTC
526530a16a3c345643afb324107b4a216b8d37ff
1 file changed
+30
-30
ref-filter.c
+30
-30
@@ -3199,37 +3199,37 @@ static int do_filter_refs(struct ref_filter *filter, unsigned int type, each_ref
3199
/* Simple per-ref filtering */
3200
if (!filter->kind)
3201
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);
3202
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
+
3233
3234
clear_contains_cache(&filter->internal.contains_cache);
3235
clear_contains_cache(&filter->internal.no_contains_cache);