name-rev.c: use strbuf_getline instead of limited size buffer

Using a buffer limited to 2048 is unnecessarily limiting. Switch to using a string buffer to read in stdin for annotation. Signed-off-by: "John Cai" <johncai86@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

John Cai committed Jan 5, 2022 at 23:29 UTC a2585719b347b57a4fb61a4ed24301cfa3cf19a7
1 file changed +5 -6
builtin/name-rev.c
+5 -6
@@ -623,14 +623,13 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)
623 name_tips();
624
625 if (annotate_stdin) {
626 - char buffer[2048];
626 + struct strbuf sb = STRBUF_INIT;
627
628 - while (!feof(stdin)) {
629 - char *p = fgets(buffer, sizeof(buffer), stdin);
630 - if (!p)
631 - break;
632 - name_rev_line(p, &data);
628 + while (strbuf_getline(&sb, stdin) != EOF) {
629 + strbuf_addch(&sb, '\n');
630 + name_rev_line(sb.buf, &data);
631 }
632 + strbuf_release(&sb);
633 } else if (all) {
634 int i, max;
635