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

[PATCH 09/19] shallow: add repository argument to register_shallow

From
Stefan Beller <sbeller@google.com>
Date
May 15, 2018, 23:42 UTC
Message-ID
<20180515234233.143708-10-sbeller@google.com>
In-Reply-To
<20180515234233.143708-1-sbeller@google.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
---
 builtin/pack-objects.c | 2 +-
 builtin/receive-pack.c | 2 +-
 commit.h               | 3 ++-
 fetch-pack.c           | 2 +-
 shallow.c              | 4 ++--
 upload-pack.c          | 7 ++++---
 6 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index d65eb4a9478..97a5963efb6 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -2875,7 +2875,7 @@ static void get_object_list(int ac, const char **av)
 				struct object_id oid;
 				if (get_oid_hex(line + 10, &oid))
 					die("not an SHA-1 '%s'", line + 10);
-				register_shallow(&oid);
+				register_shallow(the_repository, &oid);
 				use_bitmap_index = 0;
 				continue;
 			}
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index 36906fd5e98..c666820b69a 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -906,7 +906,7 @@ static int update_shallow_ref(struct command *cmd, struct shallow_info *si)
 	 * not lose these new roots..
 	 */
 	for (i = 0; i < extra.nr; i++)
-		register_shallow(&extra.oid[i]);
+		register_shallow(the_repository, &extra.oid[i]);
 
 	si->shallow_ref[cmd->index] = 0;
 	oid_array_clear(&extra);
diff --git a/commit.h b/commit.h
index f88c854e2f6..59346de5512 100644
--- a/commit.h
+++ b/commit.h
@@ -191,7 +191,8 @@ extern struct commit_list *get_merge_bases_many_dirty(struct commit *one, int n,
 
 struct oid_array;
 struct ref;
-extern int register_shallow(const struct object_id *oid);
+#define register_shallow(r, o) register_shallow_##r(o);
+extern int register_shallow_the_repository(const struct object_id *oid);
 extern int unregister_shallow(const struct object_id *oid);
 extern int for_each_commit_graft(each_commit_graft_fn, void *);
 extern int is_repository_shallow(void);
diff --git a/fetch-pack.c b/fetch-pack.c
index a1535b37b9b..e3e99e44962 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -428,7 +428,7 @@ static int find_common(struct fetch_pack_args *args,
 			if (skip_prefix(line, "shallow ", &arg)) {
 				if (get_oid_hex(arg, &oid))
 					die(_("invalid shallow line: %s"), line);
-				register_shallow(&oid);
+				register_shallow(the_repository, &oid);
 				continue;
 			}
 			if (skip_prefix(line, "unshallow ", &arg)) {
diff --git a/shallow.c b/shallow.c
index 73cb11a9162..0fadd5330d2 100644
--- a/shallow.c
+++ b/shallow.c
@@ -29,7 +29,7 @@ void set_alternate_shallow_file_the_repository(const char *path, int override)
 	alternate_shallow_file = xstrdup_or_null(path);
 }
 
-int register_shallow(const struct object_id *oid)
+int register_shallow_the_repository(const struct object_id *oid)
 {
 	struct commit_graft *graft =
 		xmalloc(sizeof(struct commit_graft));
@@ -70,7 +70,7 @@ int is_repository_shallow(void)
 		struct object_id oid;
 		if (get_oid_hex(buf, &oid))
 			die("bad shallow line: %s", buf);
-		register_shallow(&oid);
+		register_shallow(the_repository, &oid);
 	}
 	fclose(fp);
 	return is_shallow;
diff --git a/upload-pack.c b/upload-pack.c
index a11c6d192ce..4e4ac0f0d95 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -663,7 +663,7 @@ static void send_shallow(struct commit_list *result)
 		if (!(object->flags & (CLIENT_SHALLOW|NOT_SHALLOW))) {
 			packet_write_fmt(1, "shallow %s",
 					 oid_to_hex(&object->oid));
-			register_shallow(&object->oid);
+			register_shallow(the_repository, &object->oid);
 			shallow_nr++;
 		}
 		result = result->next;
@@ -700,7 +700,7 @@ static void send_unshallow(const struct object_array *shallows)
 			add_object_array(object, NULL, &extra_edge_obj);
 		}
 		/* make sure commit traversal conforms to client */
-		register_shallow(&object->oid);
+		register_shallow(the_repository, &object->oid);
 	}
 }
 
@@ -912,7 +912,8 @@ static void receive_needs(void)
 		if (shallows.nr > 0) {
 			int i;
 			for (i = 0; i < shallows.nr; i++)
-				register_shallow(&shallows.objects[i].item->oid);
+				register_shallow(the_repository,
+						 &shallows.objects[i].item->oid);
 		}
 
 	shallow_nr += shallows.nr;
-- 
2.17.0.582.gccdcbd54c44.dirty
Previous: Stefan BellerNext: Stefan Beller
Message 5 of 40 in “object store: grafts and shallow.”
  1. 00/19 object store: grafts and shallow.Stefan Beller, May 15, 2018
  2. 02/19 object: move grafts to object parserStefan Beller, May 15, 2018
  3. 05/19 commit: add repository argument to read_graft_fileStefan Beller, May 15, 2018
  4. 06/19 commit: add repository argument to prepare_commit_graftStefan Beller, May 15, 2018
  5. 09/19 shallow: add repository argument to register_shallowStefan Beller, May 15, 2018
  6. 11/19 shallow: add repository argument to is_repository_shallowStefan Beller, May 15, 2018
  7. 13/19 commit: convert register_commit_graft to handle arbitrary repositoriesStefan Beller, May 15, 2018
  8. 15/19 cache: convert get_graft_file to handle arbitrary repositoriesStefan Beller, May 15, 2018
  9. 16/19 path.c: migrate git_path_ to take a repository argumentStefan Beller, May 15, 2018
  10. 19/19 commit: allow lookup_commit_graft to handle arbitrary repositoriesStefan Beller, May 15, 2018
  11. 18/19 commit: allow prepare_commit_graft to handle arbitrary repositoriesStefan Beller, May 15, 2018
  12. 12/19 commit: convert commit_graft_pos() to handle arbitrary repositoriesStefan Beller, May 15, 2018
  13. 14/19 commit: convert read_graft_file to handle arbitrary repositoriesStefan Beller, May 15, 2018
  14. 17/19 shallow: migrate shallow information into the object parserStefan Beller, May 15, 2018
  15. 07/19 commit: add repository argument to lookup_commit_graftStefan Beller, May 15, 2018
  16. 10/19 shallow: add repository argument to check_shallow_file_for_updateStefan Beller, May 15, 2018
  17. 08/19 shallow: add repository argument to set_alternate_shallow_fileStefan Beller, May 15, 2018
  18. 03/19 commit: add repository argument to commit_graft_posStefan Beller, May 15, 2018
  19. 04/19 commit: add repository argument to register_commit_graftStefan Beller, May 15, 2018
  20. 01/19 object-store: move object access functions to object-store.hStefan Beller, May 15, 2018
  21. 00/19 object store: grafts and shallow.Stefan Beller, May 17, 2018
  22. 02/19 object: move grafts to object parserStefan Beller, May 17, 2018
  23. 04/19 commit: add repository argument to register_commit_graftStefan Beller, May 17, 2018
  24. 07/19 commit: add repository argument to lookup_commit_graftStefan Beller, May 17, 2018
  25. 08/19 shallow: add repository argument to set_alternate_shallow_fileStefan Beller, May 17, 2018
  26. 09/19 shallow: add repository argument to register_shallowStefan Beller, May 17, 2018
  27. 10/19 shallow: add repository argument to check_shallow_file_for_updateStefan Beller, May 17, 2018
  28. 12/19 commit: convert commit_graft_pos() to handle arbitrary repositoriesStefan Beller, May 17, 2018
  29. 14/19 commit: convert read_graft_file to handle arbitrary repositoriesStefan Beller, May 17, 2018
  30. 15/19 cache: convert get_graft_file to handle arbitrary repositoriesStefan Beller, May 17, 2018
  31. 19/19 commit: allow lookup_commit_graft to handle arbitrary repositoriesStefan Beller, May 17, 2018
  32. 17/19 shallow: migrate shallow information into the object parserStefan Beller, May 17, 2018
  33. 16/19 path.c: migrate global git_path_* to take a repository argumentStefan Beller, May 17, 2018
  34. 11/19 shallow: add repository argument to is_repository_shallowStefan Beller, May 17, 2018
  35. 13/19 commit: convert register_commit_graft to handle arbitrary repositoriesStefan Beller, May 17, 2018
  36. 18/19 commit: allow prepare_commit_graft to handle arbitrary repositoriesStefan Beller, May 17, 2018
  37. 01/19 object-store: move object access functions to object-store.hStefan Beller, May 17, 2018
  38. 06/19 commit: add repository argument to prepare_commit_graftStefan Beller, May 17, 2018
  39. 05/19 commit: add repository argument to read_graft_fileStefan Beller, May 17, 2018
  40. 03/19 commit: add repository argument to commit_graft_posStefan Beller, May 17, 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.