git-cvsserver runs hooks/post-receive
[gitweb.git] / wt-status.c
index d3c10b8b8d2fcb0421cde0589e2eb96e8f534c87..d35386dae19287a28ef7086d886bdfb3941d18b1 100644 (file)
@@ -82,12 +82,13 @@ static void wt_status_print_trailer(struct wt_status *s)
 }
 
 static char *quote_path(const char *in, int len,
-               struct strbuf *out, const char *prefix)
+                       struct strbuf *out, const char *prefix)
 {
-       if (len > 0)
-               strbuf_grow(out, len);
-       strbuf_setlen(out, 0);
+       if (len < 0)
+               len = strlen(in);
 
+       strbuf_grow(out, len);
+       strbuf_setlen(out, 0);
        if (prefix) {
                int off = 0;
                while (prefix[off] && off < len && prefix[off] == in[off])
@@ -104,7 +105,7 @@ static char *quote_path(const char *in, int len,
                                strbuf_addstr(out, "../");
        }
 
-       for (; (len < 0 && *in) || len > 0; in++, len--) {
+       for ( ; len > 0; in++, len--) {
                int ch = *in;
 
                switch (ch) {
@@ -250,6 +251,7 @@ static void wt_status_print_updated(struct wt_status *s)
        rev.diffopt.format_callback_data = s;
        rev.diffopt.detect_rename = 1;
        rev.diffopt.rename_limit = 100;
+       rev.diffopt.break_opt = 0;
        wt_read_cache(s);
        run_diff_index(&rev, 1);
 }
@@ -315,12 +317,28 @@ static void wt_status_print_untracked(struct wt_status *s)
 static void wt_status_print_verbose(struct wt_status *s)
 {
        struct rev_info rev;
+       int saved_stdout;
+
+       fflush(s->fp);
+
+       /* Sigh, the entire diff machinery is hardcoded to output to
+        * stdout.  Do the dup-dance...*/
+       saved_stdout = dup(STDOUT_FILENO);
+       if (saved_stdout < 0 ||dup2(fileno(s->fp), STDOUT_FILENO) < 0)
+               die("couldn't redirect stdout\n");
+
        init_revisions(&rev, NULL);
        setup_revisions(0, NULL, &rev, s->reference);
        rev.diffopt.output_format |= DIFF_FORMAT_PATCH;
        rev.diffopt.detect_rename = 1;
        wt_read_cache(s);
        run_diff_index(&rev, 1);
+
+       fflush(stdout);
+
+       if (dup2(saved_stdout, STDOUT_FILENO) < 0)
+               die("couldn't restore stdout\n");
+       close(saved_stdout);
 }
 
 void wt_status_print(struct wt_status *s)