[PATCH 108/194] alternates: add repository argument to add_to_alternates_memory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Jonathan Nieder <jrnieder@xxxxxxxxx>

Add a repository argument to allow callers of add_to_alternates_memory
to be more specific about which repository to handle. This is a small
mechanical change; it doesn't change the implementation to handle
repositories other than the_repository yet.

As with the previous commits, use a macro to catch callers passing a
repository other than the_repository at compile time.

Signed-off-by: Jonathan Nieder <jrnieder@xxxxxxxxx>
Signed-off-by: Stefan Beller <sbeller@xxxxxxxxxx>
---
 alternates.h              | 3 ++-
 builtin/grep.c            | 2 +-
 sha1_file.c               | 2 +-
 submodule.c               | 2 +-
 t/helper/test-ref-store.c | 2 +-
 tmp-objdir.c              | 2 +-
 6 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/alternates.h b/alternates.h
index 2d06b71e50..e4520ae5c7 100644
--- a/alternates.h
+++ b/alternates.h
@@ -56,7 +56,8 @@ extern void add_to_alternates_file_the_repository(const char *dir);
  * recursive alternates it points to), but do not modify the on-disk alternates
  * file.
  */
-extern void add_to_alternates_memory(const char *dir);
+#define add_to_alternates_memory(r, d) add_to_alternates_memory_##r(d)
+extern void add_to_alternates_memory_the_repository(const char *dir);
 
 /*
  * Returns a scratch strbuf pre-filled with the alternate object directory,
diff --git a/builtin/grep.c b/builtin/grep.c
index a9a908d92a..a83e87a676 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -433,7 +433,7 @@ static int grep_submodule(struct grep_opt *opt, struct repository *superproject,
 	 * object.
 	 */
 	grep_read_lock();
-	add_to_alternates_memory(submodule.objectdir);
+	add_to_alternates_memory(the_repository, submodule.objectdir);
 	grep_read_unlock();
 
 	if (oid) {
diff --git a/sha1_file.c b/sha1_file.c
index 066aa187a1..aa564e3ad4 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -581,7 +581,7 @@ void add_to_alternates_file_the_repository(const char *reference)
 	free(alts);
 }
 
-void add_to_alternates_memory(const char *reference)
+void add_to_alternates_memory_the_repository(const char *reference)
 {
 	/*
 	 * Make sure alternates are initialized, or else our entry may be
diff --git a/submodule.c b/submodule.c
index 9c4c01ba73..f9426beff1 100644
--- a/submodule.c
+++ b/submodule.c
@@ -165,7 +165,7 @@ static int add_submodule_odb(const char *path)
 		ret = -1;
 		goto done;
 	}
-	add_to_alternates_memory(objects_directory.buf);
+	add_to_alternates_memory(the_repository, objects_directory.buf);
 done:
 	strbuf_release(&objects_directory);
 	return ret;
diff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c
index 93ea6f781e..8442ee8146 100644
--- a/t/helper/test-ref-store.c
+++ b/t/helper/test-ref-store.c
@@ -31,7 +31,7 @@ static const char **get_store(const char **argv, struct ref_store **refs)
 		ret = strbuf_git_path_submodule(&sb, gitdir, "objects/");
 		if (ret)
 			die("strbuf_git_path_submodule failed: %d", ret);
-		add_to_alternates_memory(sb.buf);
+		add_to_alternates_memory(the_repository, sb.buf);
 		strbuf_release(&sb);
 
 		*refs = get_submodule_ref_store(gitdir);
diff --git a/tmp-objdir.c b/tmp-objdir.c
index bf34315adf..a9334d3fc5 100644
--- a/tmp-objdir.c
+++ b/tmp-objdir.c
@@ -288,5 +288,5 @@ const char **tmp_objdir_env(const struct tmp_objdir *t)
 
 void tmp_objdir_add_as_alternate(const struct tmp_objdir *t)
 {
-	add_to_alternates_memory(t->path.buf);
+	add_to_alternates_memory(the_repository, t->path.buf);
 }
-- 
2.15.1.433.g936d1b9894.dirty




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux