Don't die in git-http-fetch when fetching packs.
[gitweb.git] / wt-status.c
index ca4690e86b8684eb38909d455f543cf5914e9098..c48127daca9b96ce43a86508705dbaa4c24059be 100644 (file)
@@ -41,8 +41,6 @@ void wt_status_prepare(struct wt_status *s)
        unsigned char sha1[20];
        const char *head;
 
-       s->is_initial = get_sha1("HEAD", sha1) ? 1 : 0;
-
        head = resolve_ref("HEAD", sha1, 0, NULL);
        s->branch = head ? xstrdup(head) : NULL;
 
@@ -55,6 +53,18 @@ void wt_status_prepare(struct wt_status *s)
        s->workdir_clean = 1;
 }
 
+static void wt_status_print_cached_header(const char *reference)
+{
+       const char *c = color(WT_STATUS_HEADER);
+       color_printf_ln(c, "# Changes to be committed:");
+       if (reference) {
+               color_printf_ln(c, "#   (use \"git reset %s <file>...\" to unstage)", reference);
+       } else {
+               color_printf_ln(c, "#   (use \"git rm --cached <file>...\" to unstage)");
+       }
+       color_printf_ln(c, "#");
+}
+
 static void wt_status_print_header(const char *main, const char *sub)
 {
        const char *c = color(WT_STATUS_HEADER);
@@ -149,8 +159,7 @@ static void wt_status_print_updated_cb(struct diff_queue_struct *q,
                if (q->queue[i]->status == 'U')
                        continue;
                if (!shown_header) {
-                       wt_status_print_header("Added but not yet committed",
-                                       "will commit");
+                       wt_status_print_cached_header(s->reference);
                        s->commitable = 1;
                        shown_header = 1;
                }
@@ -184,8 +193,7 @@ void wt_status_print_initial(struct wt_status *s)
        read_cache();
        if (active_nr) {
                s->commitable = 1;
-               wt_status_print_header("Added but not yet committed",
-                               "will commit");
+               wt_status_print_cached_header(NULL);
        }
        for (i = 0; i < active_nr; i++) {
                color_printf(color(WT_STATUS_HEADER), "#\t");
@@ -277,6 +285,9 @@ static void wt_status_print_verbose(struct wt_status *s)
 
 void wt_status_print(struct wt_status *s)
 {
+       unsigned char sha1[20];
+       s->is_initial = get_sha1(s->reference, sha1) ? 1 : 0;
+
        if (s->branch)
                color_printf_ln(color(WT_STATUS_HEADER),
                        "# On branch %s", s->branch);