diff options
author | Stefan Beller <sbeller@google.com> | 2018-05-17 22:51:43 (GMT) |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-05-17 23:13:10 (GMT) |
commit | 6a2df51c848c86e5620dcdf1a0ee2de637937b77 (patch) | |
tree | e154a0df4bc19db9eb45efa9143d92d2e73601b9 | |
parent | 1f93ecd1ab15800fa98a0ce3efa5166fa642ab80 (diff) | |
download | git-6a2df51c848c86e5620dcdf1a0ee2de637937b77.zip git-6a2df51c848c86e5620dcdf1a0ee2de637937b77.tar.gz git-6a2df51c848c86e5620dcdf1a0ee2de637937b77.tar.bz2 |
shallow: add repository argument to set_alternate_shallow_file
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>
-rw-r--r-- | commit.h | 3 | ||||
-rw-r--r-- | environment.c | 2 | ||||
-rw-r--r-- | git.c | 2 | ||||
-rw-r--r-- | shallow.c | 2 |
4 files changed, 5 insertions, 4 deletions
@@ -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, diff --git a/environment.c b/environment.c index b991fc0..87d9e52 100644 --- a/environment.c +++ b/environment.c @@ -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) @@ -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")) { @@ -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"); |