Browse Source

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>
maint
Stefan Beller 7 years ago committed by Junio C Hamano
parent
commit
6a2df51c84
  1. 3
      commit.h
  2. 2
      environment.c
  3. 2
      git.c
  4. 2
      shallow.c

3
commit.h

@ -199,7 +199,8 @@ extern struct commit_list *get_shallow_commits(struct object_array *heads, @@ -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,

2
environment.c

@ -189,7 +189,7 @@ void setup_git_env(const char *git_dir) @@ -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)

2
git.c

@ -207,7 +207,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged) @@ -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")) {

2
shallow.c

@ -19,7 +19,7 @@ static int is_shallow = -1; @@ -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");

Loading…
Cancel
Save