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

[PATCH 1/4] builtin/pack-objects.c: remove unnecessary strbuf_reset()

From
Taylor Blau <me@ttaylorr.com>
Date
Aug 28, 2023, 22:49 UTC
Message-ID
<921a79c8bd6ab688fb9f403a59eeaed3176b630e.1693262936.git.me@ttaylorr.com>
In-Reply-To
<cover.1693262936.git.me@ttaylorr.com>

When reading input with the `--cruft` option, `git pack-objects` reads each line into a strbuf, and then moves it to either the list of discarded or fresh packs, depending on whether or not the input line starts with a '-' character.

At the beginning of each loop iteration, the next line of input is read with `strbuf_getline()`, which calls `strbuf_reset()` (as a part of `strbuf_getwholeline()`) before reading the next line of input.

Thus, the call to `strbuf_reset()` (added back in b757353676 (builtin/pack-objects.c: --cruft without expiration, 2022-05-20)) at the end of the loop is unnecessary, so let's remove it accordingly.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
---
 builtin/pack-objects.c | 1 -
 1 file changed, 1 deletion(-)
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index d2a162d528..868efe7e0f 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -3603,7 +3603,6 @@ static void read_cruft_objects(void)
 			string_list_append(&discard_packs, buf.buf + 1);
 		else
 			string_list_append(&fresh_packs, buf.buf);
-		strbuf_reset(&buf);
 	}
 
 	string_list_sort(&discard_packs);
-- 
2.42.0.49.g03c54e21ee
Previous: Taylor BlauNext: Junio C Hamano
Message 6 of 8 in “pack-objects: support `--max-pack-size` for cruft packs”
  1. 0/4 pack-objects: support `--max-pack-size` for cruft packsTaylor Blau, Aug 28, 2023
  2. 2/4 builtin/pack-objects.c: support `--max-pack-size` with `--cruft`Taylor Blau, Aug 28, 2023
  3. Junio C HamanoAug 29, 2023
  4. Taylor BlauAug 29, 2023
  5. 4/4 Documentation/gitformat-pack.txt: drop mixed version sectionTaylor Blau, Aug 28, 2023
  6. 1/4 builtin/pack-objects.c: remove unnecessary strbuf_reset()Taylor Blau, Aug 28, 2023
  7. Junio C HamanoAug 29, 2023
  8. 3/4 Documentation/gitformat-pack.txt: remove multi-cruft packs alternativeTaylor Blau, Aug 28, 2023

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.