Git fork

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

+10 -10
+2 -1
builtin/add.c
··· 385 385 char *ps_matched = NULL; 386 386 struct lock_file lock_file = LOCK_INIT; 387 387 388 - repo_config(repo, add_config, NULL); 388 + if (repo) 389 + repo_config(repo, add_config, NULL); 389 390 390 391 argc = parse_options(argc, argv, prefix, builtin_add_options, 391 392 builtin_add_usage, PARSE_OPT_KEEP_ARGV0);
+2 -3
builtin/annotate.c
··· 4 4 * Copyright (C) 2006 Ryan Anderson 5 5 */ 6 6 7 - #define USE_THE_REPOSITORY_VARIABLE 8 7 #include "git-compat-util.h" 9 8 #include "builtin.h" 10 9 #include "strvec.h" ··· 12 11 int cmd_annotate(int argc, 13 12 const char **argv, 14 13 const char *prefix, 15 - struct repository *repo UNUSED) 14 + struct repository *repo) 16 15 { 17 16 struct strvec args = STRVEC_INIT; 18 17 const char **args_copy; ··· 29 28 CALLOC_ARRAY(args_copy, args.nr + 1); 30 29 COPY_ARRAY(args_copy, args.v, args.nr); 31 30 32 - ret = cmd_blame(args.nr, args_copy, prefix, the_repository); 31 + ret = cmd_blame(args.nr, args_copy, prefix, repo); 33 32 34 33 strvec_clear(&args); 35 34 free(args_copy);
+2 -3
builtin/archive.c
··· 2 2 * Copyright (c) 2006 Franck Bui-Huu 3 3 * Copyright (c) 2006 Rene Scharfe 4 4 */ 5 - #define USE_THE_REPOSITORY_VARIABLE 6 5 #include "builtin.h" 7 6 #include "archive.h" 8 7 #include "gettext.h" ··· 79 78 int cmd_archive(int argc, 80 79 const char **argv, 81 80 const char *prefix, 82 - struct repository *repo UNUSED) 81 + struct repository *repo) 83 82 { 84 83 const char *exec = "git-upload-archive"; 85 84 char *output = NULL; ··· 110 109 111 110 setvbuf(stderr, NULL, _IOLBF, BUFSIZ); 112 111 113 - ret = write_archive(argc, argv, prefix, the_repository, output, 0); 112 + ret = write_archive(argc, argv, prefix, repo, output, 0); 114 113 115 114 out: 116 115 free(output);
+4 -3
git.c
··· 444 444 static int run_builtin(struct cmd_struct *p, int argc, const char **argv, struct repository *repo) 445 445 { 446 446 int status, help; 447 + int no_repo = 1; 447 448 struct stat st; 448 449 const char *prefix; 449 450 int run_setup = (p->option & (RUN_SETUP | RUN_SETUP_GENTLY)); ··· 455 456 456 457 if (run_setup & RUN_SETUP) { 457 458 prefix = setup_git_directory(); 459 + no_repo = 0; 458 460 } else if (run_setup & RUN_SETUP_GENTLY) { 459 - int nongit_ok; 460 - prefix = setup_git_directory_gently(&nongit_ok); 461 + prefix = setup_git_directory_gently(&no_repo); 461 462 } else { 462 463 prefix = NULL; 463 464 } ··· 480 481 trace2_cmd_name(p->cmd); 481 482 482 483 validate_cache_entries(repo->index); 483 - status = p->fn(argc, argv, prefix, (p->option & RUN_SETUP)? repo : NULL); 484 + status = p->fn(argc, argv, prefix, no_repo ? NULL : repo); 484 485 validate_cache_entries(repo->index); 485 486 486 487 if (status)