]> git.ipfire.org Git - thirdparty/git.git/commitdiff
shallow: add repository argument to set_alternate_shallow_file
authorStefan Beller <sbeller@google.com>
Thu, 17 May 2018 22:51:43 +0000 (15:51 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 17 May 2018 23:13:10 +0000 (08:13 +0900)
Add a repository argument to allow callers of set_alternate_shallow_file
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: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
commit.h
environment.c
git.c
shallow.c

index f674612576616a421a00fcd54bf9c7ae8fa66788..f88c854e2f6b8b73949e2676ad4e2c81b0fc3402 100644 (file)
--- a/commit.h
+++ b/commit.h
@@ -199,7 +199,8 @@ extern struct commit_list *get_shallow_commits(struct object_array *heads,
                int depth, int shallow_flag, int not_shallow_flag);
 extern struct commit_list *get_shallow_commits_by_rev_list(
                int ac, const char **av, int shallow_flag, int not_shallow_flag);
-extern void set_alternate_shallow_file(const char *path, int override);
+#define set_alternate_shallow_file(r, p, o) set_alternate_shallow_file_##r(p, o)
+extern void set_alternate_shallow_file_the_repository(const char *path, int override);
 extern int write_shallow_commits(struct strbuf *out, int use_pack_protocol,
                                 const struct oid_array *extra);
 extern void setup_alternate_shallow(struct lock_file *shallow_lock,
index b991fc0a87ce17b51a248a980cef34251fc032f6..87d9e52ffde897d4dd30b1346312c5217469b68f 100644 (file)
@@ -189,7 +189,7 @@ void setup_git_env(const char *git_dir)
        git_namespace = expand_namespace(getenv(GIT_NAMESPACE_ENVIRONMENT));
        shallow_file = getenv(GIT_SHALLOW_FILE_ENVIRONMENT);
        if (shallow_file)
-               set_alternate_shallow_file(shallow_file, 0);
+               set_alternate_shallow_file(the_repository, shallow_file, 0);
 }
 
 int is_bare_repository(void)
diff --git a/git.c b/git.c
index 3a89893712e6b327e714ad81d12d3e4ca354926c..5e8903681e6c4adb88c387cce7d54177d203a969 100644 (file)
--- a/git.c
+++ b/git.c
@@ -207,7 +207,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
                } else if (!strcmp(cmd, "--shallow-file")) {
                        (*argv)++;
                        (*argc)--;
-                       set_alternate_shallow_file((*argv)[0], 1);
+                       set_alternate_shallow_file(the_repository, (*argv)[0], 1);
                        if (envchanged)
                                *envchanged = 1;
                } else if (!strcmp(cmd, "-C")) {
index ca360c700c5714abcffc7e41f54e7ff025d21033..73cb11a91628784e6929f48be68f8de1020e1523 100644 (file)
--- a/shallow.c
+++ b/shallow.c
@@ -19,7 +19,7 @@ static int is_shallow = -1;
 static struct stat_validity shallow_stat;
 static char *alternate_shallow_file;
 
-void set_alternate_shallow_file(const char *path, int override)
+void set_alternate_shallow_file_the_repository(const char *path, int override)
 {
        if (is_shallow != -1)
                die("BUG: is_repository_shallow must not be called before set_alternate_shallow_file");