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

[PATCH 10/11] packfile: add repository argument to find_pack_entry

From
Stefan Beller <sbeller@google.com>
Date
Feb 28, 2018, 01:06 UTC
Message-ID
<20180228010608.215505-11-sbeller@google.com>
In-Reply-To
<20180228010608.215505-1-sbeller@google.com>

While at it move the documentation to the header and mention which pack files are searched.

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 packfile.c  | 8 ++------
 packfile.h  | 7 ++++++-
 sha1_file.c | 6 +++---
 3 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/packfile.c b/packfile.c
index b12fc0789e0..e16f8252233 100644
--- a/packfile.c
+++ b/packfile.c
@@ -1835,11 +1835,7 @@ static int fill_pack_entry(const unsigned char *sha1,
 	return 1;
 }
 
-/*
- * Iff a pack file contains the object named by sha1, return true and
- * store its location to e.
- */
-int find_pack_entry(const unsigned char *sha1, struct pack_entry *e)
+int find_pack_entry_the_repository(const unsigned char *sha1, struct pack_entry *e)
 {
 	struct list_head *pos;
 
@@ -1860,7 +1856,7 @@ int find_pack_entry(const unsigned char *sha1, struct pack_entry *e)
 int has_sha1_pack(const unsigned char *sha1)
 {
 	struct pack_entry e;
-	return find_pack_entry(sha1, &e);
+	return find_pack_entry(the_repository, sha1, &e);
 }
 
 int has_pack_index(const unsigned char *sha1)
diff --git a/packfile.h b/packfile.h
index 99f4741bd95..feeabd6f031 100644
--- a/packfile.h
+++ b/packfile.h
@@ -120,7 +120,12 @@ extern int packed_object_info(struct packed_git *pack, off_t offset, struct obje
 extern void mark_bad_packed_object(struct packed_git *p, const unsigned char *sha1);
 extern const struct packed_git *has_packed_and_bad(const unsigned char *sha1);
 
-extern int find_pack_entry(const unsigned char *sha1, struct pack_entry *e);
+/*
+ * Iff a pack file in the given repository contains the object named by sha1,
+ * return true and store its location to e.
+ */
+#define find_pack_entry(r, s, e) find_pack_entry_##r(s, e)
+extern int find_pack_entry_the_repository(const unsigned char *sha1, struct pack_entry *e);
 
 extern int has_sha1_pack(const unsigned char *sha1);
 
diff --git a/sha1_file.c b/sha1_file.c
index 0b9fefaaf02..d498b3e90b9 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -1273,7 +1273,7 @@ int sha1_object_info_extended(const unsigned char *sha1, struct object_info *oi,
 	}
 
 	while (1) {
-		if (find_pack_entry(real, &e))
+		if (find_pack_entry(the_repository, real, &e))
 			break;
 
 		/* Most likely it's a loose object. */
@@ -1282,7 +1282,7 @@ int sha1_object_info_extended(const unsigned char *sha1, struct object_info *oi,
 
 		/* Not a loose object; someone else may have just packed it. */
 		reprepare_packed_git(the_repository);
-		if (find_pack_entry(real, &e))
+		if (find_pack_entry(the_repository, real, &e))
 			break;
 
 		/* Check if it is a missing object */
@@ -1662,7 +1662,7 @@ static int freshen_loose_object(const unsigned char *sha1)
 static int freshen_packed_object(const unsigned char *sha1)
 {
 	struct pack_entry e;
-	if (!find_pack_entry(sha1, &e))
+	if (!find_pack_entry(the_repository, sha1, &e))
 		return 0;
 	if (e.p->freshened)
 		return 1;
-- 
2.16.2.395.g2e18187dfd-goog
Previous: Stefan BellerNext: Duy Nguyen
Message 13 of 23 in “Moving global state into the repository object (part 2)”
  1. 00/11 Moving global state into the repository object (part 2)Stefan Beller, Feb 28, 2018
  2. 01/11 packfile: allow prepare_packed_git_mru to handle arbitrary repositoriesStefan Beller, Feb 28, 2018
  3. 02/11 packfile: allow rearrange_packed_git to handle arbitrary repositoriesStefan Beller, Feb 28, 2018
  4. 03/11 packfile: allow install_packed_git to handle arbitrary repositoriesStefan Beller, Feb 28, 2018
  5. Derrick StoleeFeb 28, 2018
  6. 05/11 packfile: add repository argument to prepare_packed_gitStefan Beller, Feb 28, 2018
  7. 07/11 packfile: allow prepare_packed_git_one to handle arbitrary repositoriesStefan Beller, Feb 28, 2018
  8. 08/11 packfile: allow prepare_packed_git to handle arbitrary repositoriesStefan Beller, Feb 28, 2018
  9. 06/11 packfile: add repository argument to reprepare_packed_gitStefan Beller, Feb 28, 2018
  10. 11/11 packfile: allow find_pack_entry to handle arbitrary repositoriesStefan Beller, Feb 28, 2018
  11. 04/11 packfile: add repository argument to prepare_packed_git_oneStefan Beller, Feb 28, 2018
  12. 09/11 packfile: allow reprepare_packed_git to handle arbitrary repositoriesStefan Beller, Feb 28, 2018
  13. 10/11 packfile: add repository argument to find_pack_entryStefan Beller, Feb 28, 2018
  14. Duy NguyenFeb 28, 2018
  15. Derrick StoleeFeb 28, 2018
  16. Junio C HamanoFeb 28, 2018
  17. Stefan BellerFeb 28, 2018
  18. Junio C HamanoFeb 28, 2018
  19. Junio C HamanoFeb 28, 2018
  20. Stefan BellerFeb 28, 2018
  21. Jonathan NiederFeb 28, 2018
  22. Junio C HamanoFeb 28, 2018
  23. Stefan BellerFeb 28, 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.