git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] commit: drop uses of get_cached_commit_buffer()

From
Derrick Stolee <dstolee@microsoft.com>
Date
Feb 21, 2018, 19:17 UTC
Message-ID
<1519240631-221761-1-git-send-email-dstolee@microsoft.com>
In-Reply-To
<20180221185204.GA8476@sigill.intra.peff.net>

The get_cached_commit_buffer() method provides access to the buffer loaded for a struct commit, if it was ever loadead and was not freed.

Two places use this to inform how to output information about commits.

log-tree.c uses this method to short-circuit the output of commit information when the buffer is not cached. However, this leads to incorrect output in 'git log --oneline' where the short-OID is written but then the rest of the commit information is dropped and the next commit is written on the same line.

rev-list uses this method for two reasons:
- First, if the revision walk visits a commit twice, the buffer was
  freed by rev-list in the first write. The output then does not
  match the format expectations, since the OID is written without the
  rest of the content.
- Second, if the revision walk visits a commit that was marked
  UNINTERESTING, the walk may never load a buffer and hence rev-list
  will not output the verbose information.

These behaviors are undocumented, untested, and unlikely to be expected by users or other software attempting to parse this output.

Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
---
 builtin/rev-list.c | 2 +-
 log-tree.c         | 3 ---
 2 files changed, 1 insertion(+), 4 deletions(-)
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index 48300d9..d320b6f 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -134,7 +134,7 @@ static void show_commit(struct commit *commit, void *data)
 	else
 		putchar('\n');
 
-	if (revs->verbose_header && get_cached_commit_buffer(commit, NULL)) {
+	if (revs->verbose_header) {
 		struct strbuf buf = STRBUF_INIT;
 		struct pretty_print_context ctx = {0};
 		ctx.abbrev = revs->abbrev;
diff --git a/log-tree.c b/log-tree.c
index fc0cc0d..22b2fb6 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -659,9 +659,6 @@ void show_log(struct rev_info *opt)
 		show_mergetag(opt, commit);
 	}
 
-	if (!get_cached_commit_buffer(commit, NULL))
-		return;
-
 	if (opt->show_notes) {
 		int raw;
 		struct strbuf notebuf = STRBUF_INIT;
-- 
2.7.4
Previous: Jeff KingNext: Derrick Stolee
Message 6 of 17 in “Question about get_cached_commit_buffer()”
  1. Derrick StoleeFeb 20, 2018
  2. Jeff KingFeb 20, 2018
  3. Derrick StoleeFeb 21, 2018
  4. Jeff KingFeb 21, 2018
  5. Jeff KingFeb 21, 2018
  6. commit: drop uses of get_cached_commit_buffer()Derrick Stolee, Feb 21, 2018
  7. Derrick StoleeFeb 21, 2018
  8. Jeff KingFeb 21, 2018
  9. Jeff KingFeb 21, 2018
  10. Stefan BellerFeb 21, 2018
  11. Jeff KingFeb 21, 2018
  12. Derrick StoleeFeb 22, 2018
  13. Junio C HamanoFeb 21, 2018
  14. Jeff KingFeb 21, 2018
  15. Junio C HamanoFeb 21, 2018
  16. revision: drop --show-all optionJeff King, Feb 21, 2018
  17. Linus TorvaldsFeb 21, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.