@@ -718,6 +718,39 @@ static void wt_status_collect_untracked(struct wt_status *s)
718
718
s -> untracked_in_ms = (getnanotime () - t_begin ) / 1000000 ;
719
719
}
720
720
721
+ static int has_unmerged (const struct wt_status * s )
722
+ {
723
+ int i ;
724
+
725
+ for (i = 0 ; i < s -> change .nr ; i ++ ) {
726
+ struct wt_status_change_data * d ;
727
+ d = s -> change .items [i ].util ;
728
+ if (d -> stagemask )
729
+ return 1 ;
730
+ }
731
+ return 0 ;
732
+ }
733
+
734
+ static void wt_status_mark_committable (
735
+ struct wt_status * s , const struct wt_status_state * state )
736
+ {
737
+ int i ;
738
+
739
+ if (state -> merge_in_progress && !has_unmerged (s )) {
740
+ s -> committable = 1 ;
741
+ return ;
742
+ }
743
+
744
+ for (i = 0 ; i < s -> change .nr ; i ++ ) {
745
+ struct wt_status_change_data * d = (s -> change .items [i ]).util ;
746
+
747
+ if (d -> index_status && d -> index_status != DIFF_STATUS_UNMERGED ) {
748
+ s -> committable = 1 ;
749
+ return ;
750
+ }
751
+ }
752
+ }
753
+
721
754
void wt_status_collect (struct wt_status * s , const struct wt_status_state * state )
722
755
{
723
756
wt_status_collect_changes_worktree (s );
@@ -728,6 +761,8 @@ void wt_status_collect(struct wt_status *s, const struct wt_status_state *state)
728
761
wt_status_collect_changes_index (s );
729
762
730
763
wt_status_collect_untracked (s );
764
+
765
+ wt_status_mark_committable (s , state );
731
766
}
732
767
733
768
static void wt_longstatus_print_unmerged (const struct wt_status * s )
@@ -753,28 +788,28 @@ static void wt_longstatus_print_unmerged(const struct wt_status *s)
753
788
754
789
}
755
790
756
- static void wt_longstatus_print_updated (struct wt_status * s )
791
+ static void wt_longstatus_print_updated (const struct wt_status * s )
757
792
{
758
- int shown_header = 0 ;
759
793
int i ;
760
794
795
+ if (!s -> committable ) {
796
+ return ;
797
+ }
798
+
799
+ wt_longstatus_print_cached_header (s );
800
+
761
801
for (i = 0 ; i < s -> change .nr ; i ++ ) {
762
802
struct wt_status_change_data * d ;
763
803
struct string_list_item * it ;
764
804
it = & (s -> change .items [i ]);
765
805
d = it -> util ;
766
- if (!d -> index_status ||
767
- d -> index_status == DIFF_STATUS_UNMERGED )
768
- continue ;
769
- if (!shown_header ) {
770
- wt_longstatus_print_cached_header (s );
771
- s -> committable = 1 ;
772
- shown_header = 1 ;
806
+ if (d -> index_status &&
807
+ d -> index_status != DIFF_STATUS_UNMERGED ) {
808
+ wt_longstatus_print_change_data (s , WT_STATUS_UPDATED , it );
773
809
}
774
- wt_longstatus_print_change_data (s , WT_STATUS_UPDATED , it );
775
810
}
776
- if ( shown_header )
777
- wt_longstatus_print_trailer (s );
811
+
812
+ wt_longstatus_print_trailer (s );
778
813
}
779
814
780
815
/*
@@ -1056,21 +1091,7 @@ static void wt_longstatus_print_tracking(const struct wt_status *s)
1056
1091
strbuf_release (& sb );
1057
1092
}
1058
1093
1059
- static int has_unmerged (const struct wt_status * s )
1060
- {
1061
- int i ;
1062
-
1063
- for (i = 0 ; i < s -> change .nr ; i ++ ) {
1064
- struct wt_status_change_data * d ;
1065
- d = s -> change .items [i ].util ;
1066
- if (d -> stagemask )
1067
- return 1 ;
1068
- }
1069
- return 0 ;
1070
- }
1071
-
1072
- static void show_merge_in_progress (struct wt_status * s ,
1073
- const struct wt_status_state * state ,
1094
+ static void show_merge_in_progress (const struct wt_status * s ,
1074
1095
const char * color )
1075
1096
{
1076
1097
if (has_unmerged (s )) {
@@ -1082,7 +1103,6 @@ static void show_merge_in_progress(struct wt_status *s,
1082
1103
_ (" (use \"git merge --abort\" to abort the merge)" ));
1083
1104
}
1084
1105
} else {
1085
- s -> committable = 1 ;
1086
1106
status_printf_ln (s , color ,
1087
1107
_ ("All conflicts fixed but you are still merging." ));
1088
1108
if (s -> hints )
@@ -1576,12 +1596,12 @@ void wt_status_clear_state(struct wt_status_state *state)
1576
1596
free (state -> detached_from );
1577
1597
}
1578
1598
1579
- static void wt_longstatus_print_state (struct wt_status * s ,
1599
+ static void wt_longstatus_print_state (const struct wt_status * s ,
1580
1600
const struct wt_status_state * state )
1581
1601
{
1582
1602
const char * state_color = color (WT_STATUS_HEADER , s );
1583
1603
if (state -> merge_in_progress )
1584
- show_merge_in_progress (s , state , state_color );
1604
+ show_merge_in_progress (s , state_color );
1585
1605
else if (state -> am_in_progress )
1586
1606
show_am_in_progress (s , state , state_color );
1587
1607
else if (state -> rebase_in_progress || state -> rebase_interactive_in_progress )
@@ -1594,7 +1614,7 @@ static void wt_longstatus_print_state(struct wt_status *s,
1594
1614
show_bisect_in_progress (s , state , state_color );
1595
1615
}
1596
1616
1597
- static void wt_longstatus_print (struct wt_status * s , const struct wt_status_state * state )
1617
+ static void wt_longstatus_print (const struct wt_status * s , const struct wt_status_state * state )
1598
1618
{
1599
1619
const char * branch_color = color (WT_STATUS_ONBRANCH , s );
1600
1620
const char * branch_status_color = color (WT_STATUS_HEADER , s );
0 commit comments