Skip to content

Commit f3bd35f

Browse files
Stephen P. Smithgitster
authored andcommitted
wt-status.c: set the committable flag in the collect phase
In an update to fix a bug with "commit --dry-run" it was found that the committable flag was broken. The update was, at the time, accepted as it was better than the previous version. [1] Since the setting of the committable flag had been done in wt_longstatus_print_updated, move it to wt_status_collect_updated_cb. Set the committable flag in wt_status_collect_changes_initial to keep from introducing a rebase regression. Instead of setting the committable flag in show_merge_in_progress, in wt_status_cllect check for a merge that has not been committed. If present then set the committable flag. Change the tests to expect success since updates to the wt-status broken code section is being fixed. [1] https://public-inbox.org/git/[email protected]/ Signed-off-by: Stephen P. Smith <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8282f59 commit f3bd35f

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

t/t7501-commit.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,12 @@ test_expect_success '--dry-run with stuff to commit returns ok' '
9999
git commit -m next -a --dry-run
100100
'
101101

102-
test_expect_failure '--short with stuff to commit returns ok' '
102+
test_expect_success '--short with stuff to commit returns ok' '
103103
echo bongo bongo bongo >>file &&
104104
git commit -m next -a --short
105105
'
106106

107-
test_expect_failure '--porcelain with stuff to commit returns ok' '
107+
test_expect_success '--porcelain with stuff to commit returns ok' '
108108
echo bongo bongo bongo >>file &&
109109
git commit -m next -a --porcelain
110110
'
@@ -682,7 +682,7 @@ test_expect_success '--dry-run with conflicts fixed from a merge' '
682682
git commit -m "conflicts fixed from merge."
683683
'
684684

685-
test_expect_failure '--dry-run --short' '
685+
test_expect_success '--dry-run --short' '
686686
>test-file &&
687687
git add test-file &&
688688
git commit --dry-run --short

wt-status.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,10 +540,12 @@ static void wt_status_collect_updated_cb(struct diff_queue_struct *q,
540540
/* Leave {mode,oid}_head zero for an add. */
541541
d->mode_index = p->two->mode;
542542
oidcpy(&d->oid_index, &p->two->oid);
543+
s->committable = 1;
543544
break;
544545
case DIFF_STATUS_DELETED:
545546
d->mode_head = p->one->mode;
546547
oidcpy(&d->oid_head, &p->one->oid);
548+
s->committable = 1;
547549
/* Leave {mode,oid}_index zero for a delete. */
548550
break;
549551

@@ -561,6 +563,7 @@ static void wt_status_collect_updated_cb(struct diff_queue_struct *q,
561563
d->mode_index = p->two->mode;
562564
oidcpy(&d->oid_head, &p->one->oid);
563565
oidcpy(&d->oid_index, &p->two->oid);
566+
s->committable = 1;
564567
break;
565568
case DIFF_STATUS_UNMERGED:
566569
d->stagemask = unmerged_mask(p->two->path);
@@ -665,11 +668,13 @@ static void wt_status_collect_changes_initial(struct wt_status *s)
665668
* code will output the stage values directly and not use the
666669
* values in these fields.
667670
*/
671+
s->committable = 1;
668672
} else {
669673
d->index_status = DIFF_STATUS_ADDED;
670674
/* Leave {mode,oid}_head zero for adds. */
671675
d->mode_index = ce->ce_mode;
672676
oidcpy(&d->oid_index, &ce->oid);
677+
s->committable = 1;
673678
}
674679
}
675680
}
@@ -739,13 +744,19 @@ static int has_unmerged(struct wt_status *s)
739744

740745
void wt_status_collect(struct wt_status *s)
741746
{
747+
struct wt_status_state state;
742748
wt_status_collect_changes_worktree(s);
743749

744750
if (s->is_initial)
745751
wt_status_collect_changes_initial(s);
746752
else
747753
wt_status_collect_changes_index(s);
748754
wt_status_collect_untracked(s);
755+
756+
memset(&state, 0, sizeof(state));
757+
wt_status_get_state(&state, s->branch && !strcmp(s->branch, "HEAD"));
758+
if (state.merge_in_progress && !has_unmerged(s))
759+
s->committable = 1;
749760
}
750761

751762
static void wt_longstatus_print_unmerged(struct wt_status *s)
@@ -786,7 +797,6 @@ static void wt_longstatus_print_updated(struct wt_status *s)
786797
continue;
787798
if (!shown_header) {
788799
wt_longstatus_print_cached_header(s);
789-
s->committable = 1;
790800
shown_header = 1;
791801
}
792802
wt_longstatus_print_change_data(s, WT_STATUS_UPDATED, it);
@@ -1089,7 +1099,6 @@ static void show_merge_in_progress(struct wt_status *s,
10891099
_(" (use \"git merge --abort\" to abort the merge)"));
10901100
}
10911101
} else {
1092-
s-> committable = 1;
10931102
status_printf_ln(s, color,
10941103
_("All conflicts fixed but you are still merging."));
10951104
if (s->hints)

0 commit comments

Comments
 (0)