Merge branch 'mb/shortlog-nongit-stdin'
authorJunio C Hamano <gitster@pobox.com>
Sun, 7 Mar 2010 20:47:16 +0000 (12:47 -0800)
committerJunio C Hamano <gitster@pobox.com>
Sun, 7 Mar 2010 20:47:16 +0000 (12:47 -0800)
* mb/shortlog-nongit-stdin:
shortlog: warn the user when there is no input

1  2 
builtin-shortlog.c
diff --combined builtin-shortlog.c
index ecd2d45a00b1aacf9d3a19e2f934a14ca7e58c35,22668b4d3d01d112b185fba8ae7b3a4a6948b4cf..06320f5285988365b8340e110427866e68536b47
@@@ -295,6 -295,8 +295,8 @@@ parse_done
        if (!nongit && !rev.pending.nr && isatty(0))
                add_head_to_pending(&rev);
        if (rev.pending.nr == 0) {
+               if (isatty(0))
+                       fprintf(stderr, "(reading log message from standard input)\n");
                read_from_stdin(&log);
        }
        else
        return 0;
  }
  
 +static void add_wrapped_shortlog_msg(struct strbuf *sb, const char *s,
 +                                   const struct shortlog *log)
 +{
 +      int col = strbuf_add_wrapped_text(sb, s, log->in1, log->in2, log->wrap);
 +      if (col != log->wrap)
 +              strbuf_addch(sb, '\n');
 +}
 +
  void shortlog_output(struct shortlog *log)
  {
        int i, j;
 +      struct strbuf sb = STRBUF_INIT;
 +
        if (log->sort_by_number)
                qsort(log->list.items, log->list.nr, sizeof(struct string_list_item),
                        compare_by_number);
                                const char *msg = onelines->items[j].string;
  
                                if (log->wrap_lines) {
 -                                      int col = print_wrapped_text(msg, log->in1, log->in2, log->wrap);
 -                                      if (col != log->wrap)
 -                                              putchar('\n');
 +                                      strbuf_reset(&sb);
 +                                      add_wrapped_shortlog_msg(&sb, msg, log);
 +                                      fwrite(sb.buf, sb.len, 1, stdout);
                                }
                                else
                                        printf("      %s\n", msg);
                log->list.items[i].util = NULL;
        }
  
 +      strbuf_release(&sb);
        log->list.strdup_strings = 1;
        string_list_clear(&log->list, 1);
        clear_mailmap(&log->mailmap);