Code

Remove --kept-pack-only option and associated infrastructure
[git.git] / wt-status.c
index e7d42d0491743d577f84dc262ead721eb82c4785..64cedfcbe14ab0448ab6225b50244a45492a546a 100644 (file)
@@ -9,6 +9,7 @@
 #include "diffcore.h"
 #include "quote.h"
 #include "run-command.h"
+#include "remote.h"
 
 int wt_status_relative_paths = 1;
 int wt_status_use_color = -1;
@@ -274,20 +275,9 @@ static void wt_status_print_untracked(struct wt_status *s)
 
        read_directory(&dir, ".", "", 0, NULL);
        for(i = 0; i < dir.nr; i++) {
-               /* check for matching entry, which is unmerged; lifted from
-                * builtin-ls-files:show_other_files */
                struct dir_entry *ent = dir.entries[i];
-               int pos = cache_name_pos(ent->name, ent->len);
-               struct cache_entry *ce;
-               if (0 <= pos)
-                       die("bug in wt_status_print_untracked");
-               pos = -pos - 1;
-               if (pos < active_nr) {
-                       ce = active_cache[pos];
-                       if (ce_namelen(ce) == ent->len &&
-                           !memcmp(ce->name, ent->name, ent->len))
-                               continue;
-               }
+               if (!cache_name_is_other(ent->name, ent->len))
+                       continue;
                if (!shown_header) {
                        s->workdir_untracked = 1;
                        wt_status_print_header(s, "Untracked files",
@@ -315,6 +305,25 @@ static void wt_status_print_verbose(struct wt_status *s)
        run_diff_index(&rev, 1);
 }
 
+static void wt_status_print_tracking(struct wt_status *s)
+{
+       struct strbuf sb = STRBUF_INIT;
+       const char *cp, *ep;
+       struct branch *branch;
+
+       assert(s->branch && !s->is_initial);
+       if (prefixcmp(s->branch, "refs/heads/"))
+               return;
+       branch = branch_get(s->branch + 11);
+       if (!format_tracking_info(branch, &sb))
+               return;
+
+       for (cp = sb.buf; (ep = strchr(cp, '\n')) != NULL; cp = ep + 1)
+               color_fprintf_ln(s->fp, color(WT_STATUS_HEADER),
+                                "# %.*s", (int)(ep - cp), cp);
+       color_fprintf_ln(s->fp, color(WT_STATUS_HEADER), "#");
+}
+
 void wt_status_print(struct wt_status *s)
 {
        unsigned char sha1[20];
@@ -333,6 +342,8 @@ void wt_status_print(struct wt_status *s)
                }
                color_fprintf(s->fp, color(WT_STATUS_HEADER), "# ");
                color_fprintf_ln(s->fp, branch_color, "%s%s", on_what, branch_name);
+               if (!s->is_initial)
+                       wt_status_print_tracking(s);
        }
 
        if (s->is_initial) {