@matheusbsbs / matheus-bagliano / commits / c1e255b719
Fork 0

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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Nov 12, 2008 at 03:21 UTC c1e255b71964e45cee571819c011fbcaaf18be41
1 file changed +3 -25
wt-status.c
+3 -25
@@ -185,31 +185,12 @@ static void wt_status_print_changed_cb(struct diff_queue_struct *q,
185 wt_status_print_trailer(s);
186 }
187
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 -
188 static void wt_status_print_updated(struct wt_status *s)
189 {
190 struct rev_info rev;
191 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);
194 rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;
195 rev.diffopt.format_callback = wt_status_print_updated_cb;
196 rev.diffopt.format_callback_data = s;
@@ -351,12 +332,9 @@ void wt_status_print(struct wt_status *s)
332 color_fprintf_ln(s->fp, color(WT_STATUS_HEADER), "#");
333 color_fprintf_ln(s->fp, color(WT_STATUS_HEADER), "# Initial commit");
334 color_fprintf_ln(s->fp, color(WT_STATUS_HEADER), "#");
354 - wt_status_print_initial(s);
355 - }
356 - else {
357 - wt_status_print_updated(s);
335 }
336
337 + wt_status_print_updated(s);
338 wt_status_print_changed(s);
339 if (wt_status_submodule_summary)
340 wt_status_print_submodule_summary(s);