Code

test: fetch/receive with fsckobjects
[git.git] / wt-status.c
index 696c6b0bf1eac0282fbd6e140f5ddda66d7f5a93..5807fc3211a3aa8f886694776fe8c86b5bc5eb59 100644 (file)
@@ -47,24 +47,33 @@ void wt_status_prepare(struct wt_status *s)
 static void wt_status_print_unmerged_header(struct wt_status *s)
 {
        const char *c = color(WT_STATUS_HEADER, s);
+
        color_fprintf_ln(s->fp, c, "# Unmerged paths:");
-       if (!s->is_initial)
+       if (!advice_status_hints)
+               return;
+       if (s->in_merge)
+               ;
+       else if (!s->is_initial)
                color_fprintf_ln(s->fp, c, "#   (use \"git reset %s <file>...\" to unstage)", s->reference);
        else
                color_fprintf_ln(s->fp, c, "#   (use \"git rm --cached <file>...\" to unstage)");
-       color_fprintf_ln(s->fp, c, "#   (use \"git add <file>...\" to mark resolution)");
+       color_fprintf_ln(s->fp, c, "#   (use \"git add/rm <file>...\" as appropriate to mark resolution)");
        color_fprintf_ln(s->fp, c, "#");
 }
 
 static void wt_status_print_cached_header(struct wt_status *s)
 {
        const char *c = color(WT_STATUS_HEADER, s);
+
        color_fprintf_ln(s->fp, c, "# Changes to be committed:");
-       if (!s->is_initial) {
+       if (!advice_status_hints)
+               return;
+       if (s->in_merge)
+               ; /* NEEDSWORK: use "git reset --unresolve"??? */
+       else if (!s->is_initial)
                color_fprintf_ln(s->fp, c, "#   (use \"git reset %s <file>...\" to unstage)", s->reference);
-       } else {
+       else
                color_fprintf_ln(s->fp, c, "#   (use \"git rm --cached <file>...\" to unstage)");
-       }
        color_fprintf_ln(s->fp, c, "#");
 }
 
@@ -72,7 +81,10 @@ static void wt_status_print_dirty_header(struct wt_status *s,
                                         int has_deleted)
 {
        const char *c = color(WT_STATUS_HEADER, s);
+
        color_fprintf_ln(s->fp, c, "# Changed but not updated:");
+       if (!advice_status_hints)
+               return;
        if (!has_deleted)
                color_fprintf_ln(s->fp, c, "#   (use \"git add <file>...\" to update what will be committed)");
        else
@@ -85,6 +97,8 @@ static void wt_status_print_untracked_header(struct wt_status *s)
 {
        const char *c = color(WT_STATUS_HEADER, s);
        color_fprintf_ln(s->fp, c, "# Untracked files:");
+       if (!advice_status_hints)
+               return;
        color_fprintf_ln(s->fp, c, "#   (use \"git add <file>...\" to include in what will be committed)");
        color_fprintf_ln(s->fp, c, "#");
 }
@@ -329,8 +343,8 @@ static void wt_status_collect_untracked(struct wt_status *s)
                        DIR_SHOW_OTHER_DIRECTORIES | DIR_HIDE_EMPTY_DIRECTORIES;
        setup_standard_excludes(&dir);
 
-       fill_directory(&dir, NULL);
-       for(i = 0; i < dir.nr; i++) {
+       fill_directory(&dir, s->pathspec);
+       for (i = 0; i < dir.nr; i++) {
                struct dir_entry *ent = dir.entries[i];
                if (!cache_name_is_other(ent->name, ent->len))
                        continue;
@@ -445,7 +459,7 @@ static void wt_status_print_changed(struct wt_status *s)
        wt_status_print_trailer(s);
 }
 
-static void wt_status_print_submodule_summary(struct wt_status *s)
+static void wt_status_print_submodule_summary(struct wt_status *s, int uncommitted)
 {
        struct child_process sm_summary;
        char summary_limit[64];
@@ -454,11 +468,11 @@ static void wt_status_print_submodule_summary(struct wt_status *s)
        const char *argv[] = {
                "submodule",
                "summary",
-               "--cached",
+               uncommitted ? "--files" : "--cached",
                "--for-status",
                "--summary-limit",
                summary_limit,
-               s->amend ? "HEAD^" : "HEAD",
+               uncommitted ? NULL : (s->amend ? "HEAD^" : "HEAD"),
                NULL
        };
 
@@ -563,11 +577,13 @@ void wt_status_print(struct wt_status *s)
                color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "#");
        }
 
-       wt_status_print_unmerged(s);
        wt_status_print_updated(s);
+       wt_status_print_unmerged(s);
        wt_status_print_changed(s);
-       if (s->submodule_summary)
-               wt_status_print_submodule_summary(s);
+       if (s->submodule_summary) {
+               wt_status_print_submodule_summary(s, 0);  /* staged */
+               wt_status_print_submodule_summary(s, 1);  /* unstaged */
+       }
        if (s->show_untracked_files)
                wt_status_print_untracked(s);
        else if (s->commitable)
@@ -688,3 +704,11 @@ void wt_shortstatus_print(struct wt_status *s, int null_termination)
                wt_shortstatus_untracked(null_termination, it, s);
        }
 }
+
+void wt_porcelain_print(struct wt_status *s, int null_termination)
+{
+       s->use_color = 0;
+       s->relative_paths = 0;
+       s->prefix = NULL;
+       wt_shortstatus_print(s, null_termination);
+}