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

[PATCH 16/19] change all call sites that use the return value of read_cache to get the # of cache entries.

From
BRBrad Roberts <braddr@gameboy2.puremagic.com>
Date
Apr 21, 2005, 18:38 UTC
Message-ID
<200504211838.j3LIcahX027805@gameboy2.puremagic.com>

tree 6bce19032505c2939bf74eeca5e51aeefa4e1600 parent f07f7073f45a7f81e5b6cf26f5181e14fd051d81 author Brad Roberts <braddr@puremagic.com> 1114086602 -0700 committer Brad Roberts <braddr@gameboy2.puremagic.com> 1114086602 -0700

[PATCH] change all call sites that use the return value of read_cache to get the # of cache entries.

This patch somewhat breaks error handling for those call sites. I'll fix that in the next few patches.

Signed-off-by: Brad Roberts <braddr@puremagic.com>
---
 show-diff.c    |   13 ++++++++-----
 update-cache.c |    3 ++-
 write-tree.c   |    4 +++-
 3 files changed, 13 insertions(+), 7 deletions(-)
Index: show-diff.c
===================================================================
--- f07f7073f45a7f81e5b6cf26f5181e14fd051d81:1/show-diff.c  (mode:100644 sha1:e2642b65805b3e52a16c6309b44a92c2a2bd13c3)
+++ b965055600b8bf4927ea631446cd6cde714aef95:1/show-diff.c  (mode:100644 sha1:6e04e9182667cbb79afa4c878a31b685fdea3229)
@@ -126,10 +126,17 @@
 	int silent_on_nonexisting_files = 0;
 	int machine_readable = 0;
 	int reverse = 0;
-	int entries = read_cache();
+	int entries;
 	int matched = 0;
 	int i;
 
+	read_cache();
+	entries = get_num_cache_entries();
+	if (entries < 0) {
+		perror("read_cache");
+		exit(1);
+	}
+
 	while (1 < argc && argv[1][0] == '-') {
 		if  (!strcmp(argv[1], "-R"))
 			reverse = 1;
@@ -147,10 +154,6 @@
 	/* At this point, if argc == 1, then we are doing everything.
 	 * Otherwise argv[1] .. argv[argc-1] have the explicit paths.
 	 */
-	if (entries < 0) {
-		perror("read_cache");
-		exit(1);
-	}
 	prepare_diff_cmd();
 	for (i = 0; i < entries; i++) {
 		struct stat st;
Index: update-cache.c
===================================================================
--- f07f7073f45a7f81e5b6cf26f5181e14fd051d81:1/update-cache.c  (mode:100644 sha1:e741f593eb9c56c596fabed7eb6b79dee2d8cba9)
+++ b965055600b8bf4927ea631446cd6cde714aef95:1/update-cache.c  (mode:100644 sha1:8328975cb726f5e06a413a9f0099bfa2f81d3381)
@@ -299,7 +299,8 @@
 	atexit(remove_lock_file);
 	remove_lock = 1;
 
-	entries = read_cache();
+	read_cache();
+	entries = get_num_cache_entries();
 	if (entries < 0)
 		die("cache corrupted");
 
Index: write-tree.c
===================================================================
--- f07f7073f45a7f81e5b6cf26f5181e14fd051d81:1/write-tree.c  (mode:100644 sha1:f1b12cdde1bb446a134a121760007150008b251a)
+++ b965055600b8bf4927ea631446cd6cde714aef95:1/write-tree.c  (mode:100644 sha1:92e707fd4780805da160ce6fa282e75111ea67b9)
@@ -101,9 +101,11 @@
 int main(int argc, char **argv)
 {
 	int i, unmerged;
-	int entries = read_cache();
+	int entries;
 	unsigned char sha1[20];
 
+	read_cache();
+	entries = get_num_cache_entries();
 	if (entries <= 0)
 		die("write-tree: no cache contents to write");
 
Message 1 of 1 in “change all call sites that use the return value of read_cache to get the # of cache entries.”
  1. 16/19 change all call sites that use the return value of read_cache to get the # of cache entries.Brad Roberts, Apr 21, 2005

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.