@matheusbsbs / matheus-bagliano / commits / 7950cda782
Fork 0

builtin-branch: factor out merge_filter matching

The logic for checking commits against merge_filter will be reused when we recalculate the maxwidth of refnames. Signed-off-by: Lars Hjemli <hjemli@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Lars Hjemli committed Jul 26, 2008 at 12:27 UTC 7950cda782fc313569a8a09be0bfab234689627a
1 file changed +13 -5
builtin-branch.c
+13 -5
@@ -294,6 +294,17 @@ static void fill_tracking_info(char *stat, const char *branch_name)
294 sprintf(stat, "[ahead %d, behind %d] ", ours, theirs);
295 }
296
297 +static int matches_merge_filter(struct commit *commit)
298 +{
299 + int is_merged;
300 +
301 + if (merge_filter == NO_FILTER)
302 + return 1;
303 +
304 + is_merged = !!(commit->object.flags & UNINTERESTING);
305 + return (is_merged == (merge_filter == SHOW_MERGED));
306 +}
307 +
308 static void print_ref_item(struct ref_item *item, int maxwidth, int verbose,
309 int abbrev, int current)
310 {
@@ -301,11 +312,8 @@ static void print_ref_item(struct ref_item *item, int maxwidth, int verbose,
312 int color;
313 struct commit *commit = item->commit;
314
304 - if (merge_filter != NO_FILTER) {
305 - int is_merged = !!(item->commit->object.flags & UNINTERESTING);
306 - if (is_merged != (merge_filter == SHOW_MERGED))
307 - return;
308 - }
315 + if (!matches_merge_filter(commit))
316 + return;
317
318 switch (item->kind) {
319 case REF_LOCAL_BRANCH: