Skip to content

Commit c1e255b

Browse files
peffgitster
authored andcommitted
wt-status: refactor initial commit printing
When we showed the initial commit, we had no reference to diff against, so we went through the cache manually. Nowadays, however, we have a virtual empty tree commit, so we can simply diff against that to get the same results. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 14d9c57 commit c1e255b

File tree

1 file changed

+3
-25
lines changed

1 file changed

+3
-25
lines changed

wt-status.c

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -185,31 +185,12 @@ static void wt_status_print_changed_cb(struct diff_queue_struct *q,
185185
wt_status_print_trailer(s);
186186
}
187187

188-
static void wt_status_print_initial(struct wt_status *s)
189-
{
190-
int i;
191-
struct strbuf buf = STRBUF_INIT;
192-
193-
if (active_nr) {
194-
s->commitable = 1;
195-
wt_status_print_cached_header(s);
196-
}
197-
for (i = 0; i < active_nr; i++) {
198-
color_fprintf(s->fp, color(WT_STATUS_HEADER), "#\t");
199-
color_fprintf_ln(s->fp, color(WT_STATUS_UPDATED), "new file: %s",
200-
quote_path(active_cache[i]->name, -1,
201-
&buf, s->prefix));
202-
}
203-
if (active_nr)
204-
wt_status_print_trailer(s);
205-
strbuf_release(&buf);
206-
}
207-
208188
static void wt_status_print_updated(struct wt_status *s)
209189
{
210190
struct rev_info rev;
211191
init_revisions(&rev, NULL);
212-
setup_revisions(0, NULL, &rev, s->reference);
192+
setup_revisions(0, NULL, &rev,
193+
s->is_initial ? EMPTY_TREE_SHA1_HEX : s->reference);
213194
rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;
214195
rev.diffopt.format_callback = wt_status_print_updated_cb;
215196
rev.diffopt.format_callback_data = s;
@@ -351,12 +332,9 @@ void wt_status_print(struct wt_status *s)
351332
color_fprintf_ln(s->fp, color(WT_STATUS_HEADER), "#");
352333
color_fprintf_ln(s->fp, color(WT_STATUS_HEADER), "# Initial commit");
353334
color_fprintf_ln(s->fp, color(WT_STATUS_HEADER), "#");
354-
wt_status_print_initial(s);
355-
}
356-
else {
357-
wt_status_print_updated(s);
358335
}
359336

337+
wt_status_print_updated(s);
360338
wt_status_print_changed(s);
361339
if (wt_status_submodule_summary)
362340
wt_status_print_submodule_summary(s);

0 commit comments

Comments
 (0)