10 #include "run-command.h"
14 static char default_wt_status_colors[][COLOR_MAXLEN] = {
15 GIT_COLOR_NORMAL, /* WT_STATUS_HEADER */
16 GIT_COLOR_GREEN, /* WT_STATUS_UPDATED */
17 GIT_COLOR_RED, /* WT_STATUS_CHANGED */
18 GIT_COLOR_RED, /* WT_STATUS_UNTRACKED */
19 GIT_COLOR_RED, /* WT_STATUS_NOBRANCH */
20 GIT_COLOR_RED, /* WT_STATUS_UNMERGED */
21 GIT_COLOR_GREEN, /* WT_STATUS_LOCAL_BRANCH */
22 GIT_COLOR_RED, /* WT_STATUS_REMOTE_BRANCH */
25 static const char *color(int slot, struct wt_status *s)
27 return s->use_color > 0 ? s->color_palette[slot] : "";
30 void wt_status_prepare(struct wt_status *s)
32 unsigned char sha1[20];
35 memset(s, 0, sizeof(*s));
36 memcpy(s->color_palette, default_wt_status_colors,
37 sizeof(default_wt_status_colors));
38 s->show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;
40 s->relative_paths = 1;
41 head = resolve_ref("HEAD", sha1, 0, NULL);
42 s->branch = head ? xstrdup(head) : NULL;
43 s->reference = "HEAD";
45 s->index_file = get_index_file();
46 s->change.strdup_strings = 1;
47 s->untracked.strdup_strings = 1;
48 s->ignored.strdup_strings = 1;
51 static void wt_status_print_unmerged_header(struct wt_status *s)
53 const char *c = color(WT_STATUS_HEADER, s);
55 color_fprintf_ln(s->fp, c, "# Unmerged paths:");
56 if (!advice_status_hints)
60 else if (!s->is_initial)
61 color_fprintf_ln(s->fp, c, "# (use \"git reset %s <file>...\" to unstage)", s->reference);
63 color_fprintf_ln(s->fp, c, "# (use \"git rm --cached <file>...\" to unstage)");
64 color_fprintf_ln(s->fp, c, "# (use \"git add/rm <file>...\" as appropriate to mark resolution)");
65 color_fprintf_ln(s->fp, c, "#");
68 static void wt_status_print_cached_header(struct wt_status *s)
70 const char *c = color(WT_STATUS_HEADER, s);
72 color_fprintf_ln(s->fp, c, "# Changes to be committed:");
73 if (!advice_status_hints)
76 ; /* NEEDSWORK: use "git reset --unresolve"??? */
77 else if (!s->is_initial)
78 color_fprintf_ln(s->fp, c, "# (use \"git reset %s <file>...\" to unstage)", s->reference);
80 color_fprintf_ln(s->fp, c, "# (use \"git rm --cached <file>...\" to unstage)");
81 color_fprintf_ln(s->fp, c, "#");
84 static void wt_status_print_dirty_header(struct wt_status *s,
86 int has_dirty_submodules)
88 const char *c = color(WT_STATUS_HEADER, s);
90 color_fprintf_ln(s->fp, c, "# Changed but not updated:");
91 if (!advice_status_hints)
94 color_fprintf_ln(s->fp, c, "# (use \"git add <file>...\" to update what will be committed)");
96 color_fprintf_ln(s->fp, c, "# (use \"git add/rm <file>...\" to update what will be committed)");
97 color_fprintf_ln(s->fp, c, "# (use \"git checkout -- <file>...\" to discard changes in working directory)");
98 if (has_dirty_submodules)
99 color_fprintf_ln(s->fp, c, "# (commit or discard the untracked or modified content in submodules)");
100 color_fprintf_ln(s->fp, c, "#");
103 static void wt_status_print_other_header(struct wt_status *s,
107 const char *c = color(WT_STATUS_HEADER, s);
108 color_fprintf_ln(s->fp, c, "# %s files:", what);
109 if (!advice_status_hints)
111 color_fprintf_ln(s->fp, c, "# (use \"git %s <file>...\" to include in what will be committed)", how);
112 color_fprintf_ln(s->fp, c, "#");
115 static void wt_status_print_trailer(struct wt_status *s)
117 color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "#");
120 #define quote_path quote_path_relative
122 static void wt_status_print_unmerged_data(struct wt_status *s,
123 struct string_list_item *it)
125 const char *c = color(WT_STATUS_UNMERGED, s);
126 struct wt_status_change_data *d = it->util;
127 struct strbuf onebuf = STRBUF_INIT;
128 const char *one, *how = "bug";
130 one = quote_path(it->string, -1, &onebuf, s->prefix);
131 color_fprintf(s->fp, color(WT_STATUS_HEADER, s), "#\t");
132 switch (d->stagemask) {
133 case 1: how = "both deleted:"; break;
134 case 2: how = "added by us:"; break;
135 case 3: how = "deleted by them:"; break;
136 case 4: how = "added by them:"; break;
137 case 5: how = "deleted by us:"; break;
138 case 6: how = "both added:"; break;
139 case 7: how = "both modified:"; break;
141 color_fprintf(s->fp, c, "%-20s%s\n", how, one);
142 strbuf_release(&onebuf);
145 static void wt_status_print_change_data(struct wt_status *s,
147 struct string_list_item *it)
149 struct wt_status_change_data *d = it->util;
150 const char *c = color(change_type, s);
154 const char *one, *two;
155 struct strbuf onebuf = STRBUF_INIT, twobuf = STRBUF_INIT;
156 struct strbuf extra = STRBUF_INIT;
158 one_name = two_name = it->string;
159 switch (change_type) {
160 case WT_STATUS_UPDATED:
161 status = d->index_status;
163 one_name = d->head_path;
165 case WT_STATUS_CHANGED:
166 if (d->new_submodule_commits || d->dirty_submodule) {
167 strbuf_addstr(&extra, " (");
168 if (d->new_submodule_commits)
169 strbuf_addf(&extra, "new commits, ");
170 if (d->dirty_submodule & DIRTY_SUBMODULE_MODIFIED)
171 strbuf_addf(&extra, "modified content, ");
172 if (d->dirty_submodule & DIRTY_SUBMODULE_UNTRACKED)
173 strbuf_addf(&extra, "untracked content, ");
174 strbuf_setlen(&extra, extra.len - 2);
175 strbuf_addch(&extra, ')');
177 status = d->worktree_status;
181 one = quote_path(one_name, -1, &onebuf, s->prefix);
182 two = quote_path(two_name, -1, &twobuf, s->prefix);
184 color_fprintf(s->fp, color(WT_STATUS_HEADER, s), "#\t");
186 case DIFF_STATUS_ADDED:
187 color_fprintf(s->fp, c, "new file: %s", one);
189 case DIFF_STATUS_COPIED:
190 color_fprintf(s->fp, c, "copied: %s -> %s", one, two);
192 case DIFF_STATUS_DELETED:
193 color_fprintf(s->fp, c, "deleted: %s", one);
195 case DIFF_STATUS_MODIFIED:
196 color_fprintf(s->fp, c, "modified: %s", one);
198 case DIFF_STATUS_RENAMED:
199 color_fprintf(s->fp, c, "renamed: %s -> %s", one, two);
201 case DIFF_STATUS_TYPE_CHANGED:
202 color_fprintf(s->fp, c, "typechange: %s", one);
204 case DIFF_STATUS_UNKNOWN:
205 color_fprintf(s->fp, c, "unknown: %s", one);
207 case DIFF_STATUS_UNMERGED:
208 color_fprintf(s->fp, c, "unmerged: %s", one);
211 die("bug: unhandled diff status %c", status);
214 color_fprintf(s->fp, color(WT_STATUS_HEADER, s), "%s", extra.buf);
215 strbuf_release(&extra);
217 fprintf(s->fp, "\n");
218 strbuf_release(&onebuf);
219 strbuf_release(&twobuf);
222 static void wt_status_collect_changed_cb(struct diff_queue_struct *q,
223 struct diff_options *options,
226 struct wt_status *s = data;
231 s->workdir_dirty = 1;
232 for (i = 0; i < q->nr; i++) {
233 struct diff_filepair *p;
234 struct string_list_item *it;
235 struct wt_status_change_data *d;
238 it = string_list_insert(&s->change, p->one->path);
241 d = xcalloc(1, sizeof(*d));
244 if (!d->worktree_status)
245 d->worktree_status = p->status;
246 d->dirty_submodule = p->two->dirty_submodule;
247 if (S_ISGITLINK(p->two->mode))
248 d->new_submodule_commits = !!hashcmp(p->one->sha1, p->two->sha1);
252 static int unmerged_mask(const char *path)
255 struct cache_entry *ce;
257 pos = cache_name_pos(path, strlen(path));
263 while (pos < active_nr) {
264 ce = active_cache[pos++];
265 if (strcmp(ce->name, path) || !ce_stage(ce))
267 mask |= (1 << (ce_stage(ce) - 1));
272 static void wt_status_collect_updated_cb(struct diff_queue_struct *q,
273 struct diff_options *options,
276 struct wt_status *s = data;
279 for (i = 0; i < q->nr; i++) {
280 struct diff_filepair *p;
281 struct string_list_item *it;
282 struct wt_status_change_data *d;
285 it = string_list_insert(&s->change, p->two->path);
288 d = xcalloc(1, sizeof(*d));
291 if (!d->index_status)
292 d->index_status = p->status;
294 case DIFF_STATUS_COPIED:
295 case DIFF_STATUS_RENAMED:
296 d->head_path = xstrdup(p->one->path);
298 case DIFF_STATUS_UNMERGED:
299 d->stagemask = unmerged_mask(p->two->path);
305 static void wt_status_collect_changes_worktree(struct wt_status *s)
309 init_revisions(&rev, NULL);
310 setup_revisions(0, NULL, &rev, NULL);
311 rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;
312 DIFF_OPT_SET(&rev.diffopt, DIRTY_SUBMODULES);
313 if (!s->show_untracked_files)
314 DIFF_OPT_SET(&rev.diffopt, IGNORE_UNTRACKED_IN_SUBMODULES);
315 rev.diffopt.format_callback = wt_status_collect_changed_cb;
316 rev.diffopt.format_callback_data = s;
317 rev.prune_data = s->pathspec;
318 run_diff_files(&rev, 0);
321 static void wt_status_collect_changes_index(struct wt_status *s)
324 struct setup_revision_opt opt;
326 init_revisions(&rev, NULL);
327 memset(&opt, 0, sizeof(opt));
328 opt.def = s->is_initial ? EMPTY_TREE_SHA1_HEX : s->reference;
329 setup_revisions(0, NULL, &rev, &opt);
331 rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;
332 rev.diffopt.format_callback = wt_status_collect_updated_cb;
333 rev.diffopt.format_callback_data = s;
334 rev.diffopt.detect_rename = 1;
335 rev.diffopt.rename_limit = 200;
336 rev.diffopt.break_opt = 0;
337 rev.prune_data = s->pathspec;
338 run_diff_index(&rev, 1);
341 static void wt_status_collect_changes_initial(struct wt_status *s)
345 for (i = 0; i < active_nr; i++) {
346 struct string_list_item *it;
347 struct wt_status_change_data *d;
348 struct cache_entry *ce = active_cache[i];
350 if (!ce_path_match(ce, s->pathspec))
352 it = string_list_insert(&s->change, ce->name);
355 d = xcalloc(1, sizeof(*d));
359 d->index_status = DIFF_STATUS_UNMERGED;
360 d->stagemask |= (1 << (ce_stage(ce) - 1));
363 d->index_status = DIFF_STATUS_ADDED;
367 static void wt_status_collect_untracked(struct wt_status *s)
370 struct dir_struct dir;
372 if (!s->show_untracked_files)
374 memset(&dir, 0, sizeof(dir));
375 if (s->show_untracked_files != SHOW_ALL_UNTRACKED_FILES)
377 DIR_SHOW_OTHER_DIRECTORIES | DIR_HIDE_EMPTY_DIRECTORIES;
378 setup_standard_excludes(&dir);
380 fill_directory(&dir, s->pathspec);
381 for (i = 0; i < dir.nr; i++) {
382 struct dir_entry *ent = dir.entries[i];
383 if (!cache_name_is_other(ent->name, ent->len))
385 if (!match_pathspec(s->pathspec, ent->name, ent->len, 0, NULL))
387 string_list_insert(&s->untracked, ent->name);
391 if (s->show_ignored_files) {
393 dir.flags = DIR_SHOW_IGNORED | DIR_SHOW_OTHER_DIRECTORIES;
394 fill_directory(&dir, s->pathspec);
395 for (i = 0; i < dir.nr; i++) {
396 struct dir_entry *ent = dir.entries[i];
397 if (!cache_name_is_other(ent->name, ent->len))
399 if (!match_pathspec(s->pathspec, ent->name, ent->len, 0, NULL))
401 string_list_insert(&s->ignored, ent->name);
409 void wt_status_collect(struct wt_status *s)
411 wt_status_collect_changes_worktree(s);
414 wt_status_collect_changes_initial(s);
416 wt_status_collect_changes_index(s);
417 wt_status_collect_untracked(s);
420 static void wt_status_print_unmerged(struct wt_status *s)
422 int shown_header = 0;
425 for (i = 0; i < s->change.nr; i++) {
426 struct wt_status_change_data *d;
427 struct string_list_item *it;
428 it = &(s->change.items[i]);
433 wt_status_print_unmerged_header(s);
436 wt_status_print_unmerged_data(s, it);
439 wt_status_print_trailer(s);
443 static void wt_status_print_updated(struct wt_status *s)
445 int shown_header = 0;
448 for (i = 0; i < s->change.nr; i++) {
449 struct wt_status_change_data *d;
450 struct string_list_item *it;
451 it = &(s->change.items[i]);
453 if (!d->index_status ||
454 d->index_status == DIFF_STATUS_UNMERGED)
457 wt_status_print_cached_header(s);
461 wt_status_print_change_data(s, WT_STATUS_UPDATED, it);
464 wt_status_print_trailer(s);
470 * 1 : some change but no delete
472 static int wt_status_check_worktree_changes(struct wt_status *s,
473 int *dirty_submodules)
478 *dirty_submodules = 0;
480 for (i = 0; i < s->change.nr; i++) {
481 struct wt_status_change_data *d;
482 d = s->change.items[i].util;
483 if (!d->worktree_status ||
484 d->worktree_status == DIFF_STATUS_UNMERGED)
488 if (d->dirty_submodule)
489 *dirty_submodules = 1;
490 if (d->worktree_status == DIFF_STATUS_DELETED)
496 static void wt_status_print_changed(struct wt_status *s)
498 int i, dirty_submodules;
499 int worktree_changes = wt_status_check_worktree_changes(s, &dirty_submodules);
501 if (!worktree_changes)
504 wt_status_print_dirty_header(s, worktree_changes < 0, dirty_submodules);
506 for (i = 0; i < s->change.nr; i++) {
507 struct wt_status_change_data *d;
508 struct string_list_item *it;
509 it = &(s->change.items[i]);
511 if (!d->worktree_status ||
512 d->worktree_status == DIFF_STATUS_UNMERGED)
514 wt_status_print_change_data(s, WT_STATUS_CHANGED, it);
516 wt_status_print_trailer(s);
519 static void wt_status_print_submodule_summary(struct wt_status *s, int uncommitted)
521 struct child_process sm_summary;
522 char summary_limit[64];
523 char index[PATH_MAX];
524 const char *env[] = { NULL, NULL };
528 argv[0] = "submodule";
530 argv[2] = uncommitted ? "--files" : "--cached";
531 argv[3] = "--for-status";
532 argv[4] = "--summary-limit";
533 argv[5] = summary_limit;
534 argv[6] = uncommitted ? NULL : (s->amend ? "HEAD^" : "HEAD");
537 sprintf(summary_limit, "%d", s->submodule_summary);
538 snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", s->index_file);
540 memset(&sm_summary, 0, sizeof(sm_summary));
541 sm_summary.argv = argv;
542 sm_summary.env = env;
543 sm_summary.git_cmd = 1;
544 sm_summary.no_stdin = 1;
546 sm_summary.out = dup(fileno(s->fp)); /* run_command closes it */
547 run_command(&sm_summary);
550 static void wt_status_print_other(struct wt_status *s,
551 struct string_list *l,
556 struct strbuf buf = STRBUF_INIT;
558 if (!s->untracked.nr)
561 wt_status_print_other_header(s, what, how);
563 for (i = 0; i < l->nr; i++) {
564 struct string_list_item *it;
566 color_fprintf(s->fp, color(WT_STATUS_HEADER, s), "#\t");
567 color_fprintf_ln(s->fp, color(WT_STATUS_UNTRACKED, s), "%s",
568 quote_path(it->string, strlen(it->string),
571 strbuf_release(&buf);
574 static void wt_status_print_verbose(struct wt_status *s)
577 struct setup_revision_opt opt;
579 init_revisions(&rev, NULL);
580 DIFF_OPT_SET(&rev.diffopt, ALLOW_TEXTCONV);
582 memset(&opt, 0, sizeof(opt));
583 opt.def = s->is_initial ? EMPTY_TREE_SHA1_HEX : s->reference;
584 setup_revisions(0, NULL, &rev, &opt);
586 rev.diffopt.output_format |= DIFF_FORMAT_PATCH;
587 rev.diffopt.detect_rename = 1;
588 rev.diffopt.file = s->fp;
589 rev.diffopt.close_file = 0;
591 * If we're not going to stdout, then we definitely don't
592 * want color, since we are going to the commit message
593 * file (and even the "auto" setting won't work, since it
594 * will have checked isatty on stdout).
597 DIFF_OPT_CLR(&rev.diffopt, COLOR_DIFF);
598 run_diff_index(&rev, 1);
601 static void wt_status_print_tracking(struct wt_status *s)
603 struct strbuf sb = STRBUF_INIT;
605 struct branch *branch;
607 assert(s->branch && !s->is_initial);
608 if (prefixcmp(s->branch, "refs/heads/"))
610 branch = branch_get(s->branch + 11);
611 if (!format_tracking_info(branch, &sb))
614 for (cp = sb.buf; (ep = strchr(cp, '\n')) != NULL; cp = ep + 1)
615 color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s),
616 "# %.*s", (int)(ep - cp), cp);
617 color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "#");
620 void wt_status_print(struct wt_status *s)
622 const char *branch_color = color(WT_STATUS_HEADER, s);
625 const char *on_what = "On branch ";
626 const char *branch_name = s->branch;
627 if (!prefixcmp(branch_name, "refs/heads/"))
629 else if (!strcmp(branch_name, "HEAD")) {
631 branch_color = color(WT_STATUS_NOBRANCH, s);
632 on_what = "Not currently on any branch.";
634 color_fprintf(s->fp, color(WT_STATUS_HEADER, s), "# ");
635 color_fprintf_ln(s->fp, branch_color, "%s%s", on_what, branch_name);
637 wt_status_print_tracking(s);
641 color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "#");
642 color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "# Initial commit");
643 color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "#");
646 wt_status_print_updated(s);
647 wt_status_print_unmerged(s);
648 wt_status_print_changed(s);
649 if (s->submodule_summary) {
650 wt_status_print_submodule_summary(s, 0); /* staged */
651 wt_status_print_submodule_summary(s, 1); /* unstaged */
653 if (s->show_untracked_files) {
654 wt_status_print_other(s, &s->untracked, "Untracked", "add");
655 if (s->show_ignored_files)
656 wt_status_print_other(s, &s->ignored, "Ignored", "add -f");
657 } else if (s->commitable)
658 fprintf(s->fp, "# Untracked files not listed%s\n",
660 ? " (use -u option to show untracked files)" : "");
663 wt_status_print_verbose(s);
664 if (!s->commitable) {
666 fprintf(s->fp, "# No changes\n");
669 else if (s->workdir_dirty)
670 printf("no changes added to commit%s\n",
672 ? " (use \"git add\" and/or \"git commit -a\")" : "");
673 else if (s->untracked.nr)
674 printf("nothing added to commit but untracked files present%s\n",
676 ? " (use \"git add\" to track)" : "");
677 else if (s->is_initial)
678 printf("nothing to commit%s\n", advice_status_hints
679 ? " (create/copy files and use \"git add\" to track)" : "");
680 else if (!s->show_untracked_files)
681 printf("nothing to commit%s\n", advice_status_hints
682 ? " (use -u to show untracked files)" : "");
684 printf("nothing to commit%s\n", advice_status_hints
685 ? " (working directory clean)" : "");
689 static void wt_shortstatus_unmerged(int null_termination, struct string_list_item *it,
692 struct wt_status_change_data *d = it->util;
693 const char *how = "??";
695 switch (d->stagemask) {
696 case 1: how = "DD"; break; /* both deleted */
697 case 2: how = "AU"; break; /* added by us */
698 case 3: how = "UD"; break; /* deleted by them */
699 case 4: how = "UA"; break; /* added by them */
700 case 5: how = "DU"; break; /* deleted by us */
701 case 6: how = "AA"; break; /* both added */
702 case 7: how = "UU"; break; /* both modified */
704 color_fprintf(s->fp, color(WT_STATUS_UNMERGED, s), "%s", how);
705 if (null_termination) {
706 fprintf(stdout, " %s%c", it->string, 0);
708 struct strbuf onebuf = STRBUF_INIT;
710 one = quote_path(it->string, -1, &onebuf, s->prefix);
711 printf(" %s\n", one);
712 strbuf_release(&onebuf);
716 static void wt_shortstatus_status(int null_termination, struct string_list_item *it,
719 struct wt_status_change_data *d = it->util;
722 color_fprintf(s->fp, color(WT_STATUS_UPDATED, s), "%c", d->index_status);
725 if (d->worktree_status)
726 color_fprintf(s->fp, color(WT_STATUS_CHANGED, s), "%c", d->worktree_status);
730 if (null_termination) {
731 fprintf(stdout, "%s%c", it->string, 0);
733 fprintf(stdout, "%s%c", d->head_path, 0);
735 struct strbuf onebuf = STRBUF_INIT;
738 one = quote_path(d->head_path, -1, &onebuf, s->prefix);
739 printf("%s -> ", one);
740 strbuf_release(&onebuf);
742 one = quote_path(it->string, -1, &onebuf, s->prefix);
744 strbuf_release(&onebuf);
748 static void wt_shortstatus_other(int null_termination, struct string_list_item *it,
749 struct wt_status *s, const char *sign)
751 if (null_termination) {
752 fprintf(stdout, "%s %s%c", sign, it->string, 0);
754 struct strbuf onebuf = STRBUF_INIT;
756 one = quote_path(it->string, -1, &onebuf, s->prefix);
757 color_fprintf(s->fp, color(WT_STATUS_UNTRACKED, s), "%s", sign);
758 printf(" %s\n", one);
759 strbuf_release(&onebuf);
763 static void wt_shortstatus_print_tracking(struct wt_status *s)
765 struct branch *branch;
766 const char *header_color = color(WT_STATUS_HEADER, s);
767 const char *branch_color_local = color(WT_STATUS_LOCAL_BRANCH, s);
768 const char *branch_color_remote = color(WT_STATUS_REMOTE_BRANCH, s);
771 const char *branch_name;
772 int num_ours, num_theirs;
774 color_fprintf(s->fp, color(WT_STATUS_HEADER, s), "## ");
778 branch_name = s->branch;
780 if (!prefixcmp(branch_name, "refs/heads/"))
782 else if (!strcmp(branch_name, "HEAD")) {
783 branch_name = "HEAD (no branch)";
784 branch_color_local = color(WT_STATUS_NOBRANCH, s);
787 branch = branch_get(s->branch + 11);
789 color_fprintf(s->fp, header_color, "Initial commit on ");
790 if (!stat_tracking_info(branch, &num_ours, &num_theirs)) {
791 color_fprintf_ln(s->fp, branch_color_local,
796 base = branch->merge[0]->dst;
797 base = shorten_unambiguous_ref(base, 0);
798 color_fprintf(s->fp, branch_color_local, "%s", branch_name);
799 color_fprintf(s->fp, header_color, "...");
800 color_fprintf(s->fp, branch_color_remote, "%s", base);
802 color_fprintf(s->fp, header_color, " [");
804 color_fprintf(s->fp, header_color, "behind ");
805 color_fprintf(s->fp, branch_color_remote, "%d", num_theirs);
806 } else if (!num_theirs) {
807 color_fprintf(s->fp, header_color, "ahead ");
808 color_fprintf(s->fp, branch_color_local, "%d", num_ours);
810 color_fprintf(s->fp, header_color, "ahead ");
811 color_fprintf(s->fp, branch_color_local, "%d", num_ours);
812 color_fprintf(s->fp, header_color, ", behind ");
813 color_fprintf(s->fp, branch_color_remote, "%d", num_theirs);
816 color_fprintf_ln(s->fp, header_color, "]");
819 void wt_shortstatus_print(struct wt_status *s, int null_termination, int show_branch)
824 wt_shortstatus_print_tracking(s);
826 for (i = 0; i < s->change.nr; i++) {
827 struct wt_status_change_data *d;
828 struct string_list_item *it;
830 it = &(s->change.items[i]);
833 wt_shortstatus_unmerged(null_termination, it, s);
835 wt_shortstatus_status(null_termination, it, s);
837 for (i = 0; i < s->untracked.nr; i++) {
838 struct string_list_item *it;
840 it = &(s->untracked.items[i]);
841 wt_shortstatus_other(null_termination, it, s, "??");
843 for (i = 0; i < s->ignored.nr; i++) {
844 struct string_list_item *it;
846 it = &(s->ignored.items[i]);
847 wt_shortstatus_other(null_termination, it, s, "!!");
851 void wt_porcelain_print(struct wt_status *s, int null_termination)
854 s->relative_paths = 0;
856 wt_shortstatus_print(s, null_termination, 0);