@@ -280,6 +280,7 @@ struct ref_item {
280280 char * dest ;
281281 unsigned int kind , width ;
282282 struct commit * commit ;
283+ int ignore ;
283284};
284285
285286struct ref_list {
@@ -385,6 +386,7 @@ static int append_ref(const char *refname, const unsigned char *sha1, int flags,
385386 newitem -> commit = commit ;
386387 newitem -> width = utf8_strwidth (refname );
387388 newitem -> dest = resolve_symref (orig_refname , prefix );
389+ newitem -> ignore = 0 ;
388390 /* adjust for "remotes/" */
389391 if (newitem -> kind == REF_REMOTE_BRANCH &&
390392 ref_list -> kinds != REF_REMOTE_BRANCH )
@@ -484,17 +486,6 @@ static void fill_tracking_info(struct strbuf *stat, const char *branch_name,
484486 free (ref );
485487}
486488
487- static int matches_merge_filter (struct commit * commit )
488- {
489- int is_merged ;
490-
491- if (merge_filter == NO_FILTER )
492- return 1 ;
493-
494- is_merged = !!(commit -> object .flags & UNINTERESTING );
495- return (is_merged == (merge_filter == SHOW_MERGED ));
496- }
497-
498489static void add_verbose_info (struct strbuf * out , struct ref_item * item ,
499490 int verbose , int abbrev )
500491{
@@ -522,10 +513,9 @@ static void print_ref_item(struct ref_item *item, int maxwidth, int verbose,
522513{
523514 char c ;
524515 int color ;
525- struct commit * commit = item -> commit ;
526516 struct strbuf out = STRBUF_INIT , name = STRBUF_INIT ;
527517
528- if (! matches_merge_filter ( commit ) )
518+ if (item -> ignore )
529519 return ;
530520
531521 switch (item -> kind ) {
@@ -575,7 +565,7 @@ static int calc_maxwidth(struct ref_list *refs)
575565{
576566 int i , w = 0 ;
577567 for (i = 0 ; i < refs -> index ; i ++ ) {
578- if (! matches_merge_filter ( refs -> list [i ].commit ) )
568+ if (refs -> list [i ].ignore )
579569 continue ;
580570 if (refs -> list [i ].width > w )
581571 w = refs -> list [i ].width ;
@@ -618,6 +608,7 @@ static void show_detached(struct ref_list *ref_list)
618608 item .kind = REF_LOCAL_BRANCH ;
619609 item .dest = NULL ;
620610 item .commit = head_commit ;
611+ item .ignore = 0 ;
621612 if (item .width > ref_list -> maxwidth )
622613 ref_list -> maxwidth = item .width ;
623614 print_ref_item (& item , ref_list -> maxwidth , ref_list -> verbose , ref_list -> abbrev , 1 , "" );
@@ -656,6 +647,20 @@ static int print_ref_list(int kinds, int detached, int verbose, int abbrev, stru
656647
657648 if (prepare_revision_walk (& ref_list .revs ))
658649 die (_ ("revision walk setup failed" ));
650+
651+ for (i = 0 ; i < ref_list .index ; i ++ ) {
652+ struct ref_item * item = & ref_list .list [i ];
653+ struct commit * commit = item -> commit ;
654+ int is_merged = !!(commit -> object .flags & UNINTERESTING );
655+ item -> ignore = is_merged != (merge_filter == SHOW_MERGED );
656+ }
657+
658+ for (i = 0 ; i < ref_list .index ; i ++ ) {
659+ struct ref_item * item = & ref_list .list [i ];
660+ clear_commit_marks (item -> commit , ALL_REV_FLAGS );
661+ }
662+ clear_commit_marks (filter , ALL_REV_FLAGS );
663+
659664 if (verbose )
660665 ref_list .maxwidth = calc_maxwidth (& ref_list );
661666 }
0 commit comments