sha1dc: update from upstream
[gitweb.git] / wt-status.c
index cc446f26ba40a6813c69b649656210bc6e3f98ae..03754849626d1bf117e3821fb7cdffcd594f694f 100644 (file)
@@ -407,6 +407,16 @@ static void wt_longstatus_print_change_data(struct wt_status *s,
        strbuf_release(&twobuf);
 }
 
+static char short_submodule_status(struct wt_status_change_data *d) {
+       if (d->new_submodule_commits)
+               return 'M';
+       if (d->dirty_submodule & DIRTY_SUBMODULE_MODIFIED)
+               return 'm';
+       if (d->dirty_submodule & DIRTY_SUBMODULE_UNTRACKED)
+               return '?';
+       return d->worktree_status;
+}
+
 static void wt_status_collect_changed_cb(struct diff_queue_struct *q,
                                         struct diff_options *options,
                                         void *data)
@@ -431,10 +441,13 @@ static void wt_status_collect_changed_cb(struct diff_queue_struct *q,
                }
                if (!d->worktree_status)
                        d->worktree_status = p->status;
-               d->dirty_submodule = p->two->dirty_submodule;
-               if (S_ISGITLINK(p->two->mode))
+               if (S_ISGITLINK(p->two->mode)) {
+                       d->dirty_submodule = p->two->dirty_submodule;
                        d->new_submodule_commits = !!oidcmp(&p->one->oid,
                                                            &p->two->oid);
+                       if (s->status_format == STATUS_FORMAT_SHORT)
+                               d->worktree_status = short_submodule_status(d);
+               }
 
                switch (p->status) {
                case DIFF_STATUS_ADDED:
@@ -1785,34 +1798,24 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)
 
 static void wt_shortstatus_print(struct wt_status *s)
 {
-       int i;
+       struct string_list_item *it;
 
        if (s->show_branch)
                wt_shortstatus_print_tracking(s);
 
-       for (i = 0; i < s->change.nr; i++) {
-               struct wt_status_change_data *d;
-               struct string_list_item *it;
+       for_each_string_list_item(it, &s->change) {
+               struct wt_status_change_data *d = it->util;
 
-               it = &(s->change.items[i]);
-               d = it->util;
                if (d->stagemask)
                        wt_shortstatus_unmerged(it, s);
                else
                        wt_shortstatus_status(it, s);
        }
-       for (i = 0; i < s->untracked.nr; i++) {
-               struct string_list_item *it;
-
-               it = &(s->untracked.items[i]);
+       for_each_string_list_item(it, &s->untracked)
                wt_shortstatus_other(it, s, "??");
-       }
-       for (i = 0; i < s->ignored.nr; i++) {
-               struct string_list_item *it;
 
-               it = &(s->ignored.items[i]);
+       for_each_string_list_item(it, &s->ignored)
                wt_shortstatus_other(it, s, "!!");
-       }
 }
 
 static void wt_porcelain_print(struct wt_status *s)