Merge branch 'rs/strbuf-detach'
authorJunio C Hamano <gitster@pobox.com>
Mon, 30 Sep 2019 04:19:24 +0000 (13:19 +0900)
committerJunio C Hamano <gitster@pobox.com>
Mon, 30 Sep 2019 04:19:24 +0000 (13:19 +0900)
Straighten out the use of strbuf_detach() API function.

* rs/strbuf-detach:
grep: use return value of strbuf_detach()
log-tree: always use return value of strbuf_detach()

builtin/grep.c
log-tree.c
index 2699001fbd6dfe07f0338ee478454ec2b7325559..69ac053acc16be6b12e0743dfabf8a481e1f92cb 100644 (file)
@@ -1110,8 +1110,8 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
                        strbuf_addf(&buf, "+/%s%s",
                                        strcmp("less", pager) ? "" : "*",
                                        opt.pattern_list->pattern);
-                       string_list_append(&path_list, buf.buf);
-                       strbuf_detach(&buf, NULL);
+                       string_list_append(&path_list,
+                                          strbuf_detach(&buf, NULL));
                }
        }
 
index 1e56df62a79c0d221fa55ba351b6b16f8027d12b..109c212224ccf63facdcd5dd921b76e8068f9103 100644 (file)
@@ -677,9 +677,7 @@ void show_log(struct rev_info *opt)
                raw = (opt->commit_format == CMIT_FMT_USERFORMAT);
                format_display_notes(&commit->object.oid, &notebuf,
                                     get_log_output_encoding(), raw);
-               ctx.notes_message = notebuf.len
-                       ? strbuf_detach(&notebuf, NULL)
-                       : xcalloc(1, 1);
+               ctx.notes_message = strbuf_detach(&notebuf, NULL);
        }
 
        /*