mirror of
https://github.com/git/git.git
synced 2024-11-23 09:56:28 +08:00
Merge branch 'jc/a-commands-without-the-repo'
Commands that can also work outside Git have learned to take the repository instance "repo" when we know we are in a repository, and NULL when we are not, in a parameter. The uses of the_repository variable in a few of them have been removed using the new calling convention. * jc/a-commands-without-the-repo: archive: remove the_repository global variable annotate: remove usage of the_repository global git: pass in repo to builtin based on setup_git_directory_gently
This commit is contained in:
commit
0ab43ed95c
@ -385,7 +385,8 @@ int cmd_add(int argc,
|
||||
char *ps_matched = NULL;
|
||||
struct lock_file lock_file = LOCK_INIT;
|
||||
|
||||
repo_config(repo, add_config, NULL);
|
||||
if (repo)
|
||||
repo_config(repo, add_config, NULL);
|
||||
|
||||
argc = parse_options(argc, argv, prefix, builtin_add_options,
|
||||
builtin_add_usage, PARSE_OPT_KEEP_ARGV0);
|
||||
|
@ -4,7 +4,6 @@
|
||||
* Copyright (C) 2006 Ryan Anderson
|
||||
*/
|
||||
|
||||
#define USE_THE_REPOSITORY_VARIABLE
|
||||
#include "git-compat-util.h"
|
||||
#include "builtin.h"
|
||||
#include "strvec.h"
|
||||
@ -12,7 +11,7 @@
|
||||
int cmd_annotate(int argc,
|
||||
const char **argv,
|
||||
const char *prefix,
|
||||
struct repository *repo UNUSED)
|
||||
struct repository *repo)
|
||||
{
|
||||
struct strvec args = STRVEC_INIT;
|
||||
const char **args_copy;
|
||||
@ -29,7 +28,7 @@ int cmd_annotate(int argc,
|
||||
CALLOC_ARRAY(args_copy, args.nr + 1);
|
||||
COPY_ARRAY(args_copy, args.v, args.nr);
|
||||
|
||||
ret = cmd_blame(args.nr, args_copy, prefix, the_repository);
|
||||
ret = cmd_blame(args.nr, args_copy, prefix, repo);
|
||||
|
||||
strvec_clear(&args);
|
||||
free(args_copy);
|
||||
|
@ -2,7 +2,6 @@
|
||||
* Copyright (c) 2006 Franck Bui-Huu
|
||||
* Copyright (c) 2006 Rene Scharfe
|
||||
*/
|
||||
#define USE_THE_REPOSITORY_VARIABLE
|
||||
#include "builtin.h"
|
||||
#include "archive.h"
|
||||
#include "gettext.h"
|
||||
@ -79,7 +78,7 @@ static int run_remote_archiver(int argc, const char **argv,
|
||||
int cmd_archive(int argc,
|
||||
const char **argv,
|
||||
const char *prefix,
|
||||
struct repository *repo UNUSED)
|
||||
struct repository *repo)
|
||||
{
|
||||
const char *exec = "git-upload-archive";
|
||||
char *output = NULL;
|
||||
@ -110,7 +109,7 @@ int cmd_archive(int argc,
|
||||
|
||||
setvbuf(stderr, NULL, _IOLBF, BUFSIZ);
|
||||
|
||||
ret = write_archive(argc, argv, prefix, the_repository, output, 0);
|
||||
ret = write_archive(argc, argv, prefix, repo, output, 0);
|
||||
|
||||
out:
|
||||
free(output);
|
||||
|
7
git.c
7
git.c
@ -444,6 +444,7 @@ static int handle_alias(int *argcp, const char ***argv)
|
||||
static int run_builtin(struct cmd_struct *p, int argc, const char **argv, struct repository *repo)
|
||||
{
|
||||
int status, help;
|
||||
int no_repo = 1;
|
||||
struct stat st;
|
||||
const char *prefix;
|
||||
int run_setup = (p->option & (RUN_SETUP | RUN_SETUP_GENTLY));
|
||||
@ -455,9 +456,9 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv, struct
|
||||
|
||||
if (run_setup & RUN_SETUP) {
|
||||
prefix = setup_git_directory();
|
||||
no_repo = 0;
|
||||
} else if (run_setup & RUN_SETUP_GENTLY) {
|
||||
int nongit_ok;
|
||||
prefix = setup_git_directory_gently(&nongit_ok);
|
||||
prefix = setup_git_directory_gently(&no_repo);
|
||||
} else {
|
||||
prefix = NULL;
|
||||
}
|
||||
@ -480,7 +481,7 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv, struct
|
||||
trace2_cmd_name(p->cmd);
|
||||
|
||||
validate_cache_entries(repo->index);
|
||||
status = p->fn(argc, argv, prefix, (p->option & RUN_SETUP)? repo : NULL);
|
||||
status = p->fn(argc, argv, prefix, no_repo ? NULL : repo);
|
||||
validate_cache_entries(repo->index);
|
||||
|
||||
if (status)
|
||||
|
Loading…
Reference in New Issue
Block a user