summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: db6296a)
raw | patch | inline | side by side (parent: db6296a)
author | Linus Torvalds <torvalds@osdl.org> | |
Sat, 29 Jul 2006 05:44:25 +0000 (22:44 -0700) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Sat, 29 Jul 2006 08:34:07 +0000 (01:34 -0700) |
This changes the calling convention of built-in commands and
passes the "prefix" (i.e. pathname of $PWD relative to the
project root level) down to them.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
passes the "prefix" (i.e. pathname of $PWD relative to the
project root level) down to them.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
35 files changed:
diff --git a/builtin-add.c b/builtin-add.c
index 3a73a173f729e0ca75e650779773316e8ae3fe98..0fa7dc1f11001373e512da469d4dd4d55e18919a 100644 (file)
--- a/builtin-add.c
+++ b/builtin-add.c
static struct lock_file lock_file;
-int cmd_add(int argc, const char **argv, char **envp)
+int cmd_add(int argc, const char **argv, const char *prefix)
{
int i, newfd;
int verbose = 0, show_only = 0;
- const char *prefix = setup_git_directory();
const char **pathspec;
struct dir_struct dir;
diff --git a/builtin-apply.c b/builtin-apply.c
index d4381d9a8fe2effcaca46e8455fc6601ee3dfc36..f8c6763c7464a01ea81fae0665a7aef50809d031 100644 (file)
--- a/builtin-apply.c
+++ b/builtin-apply.c
}
-int cmd_apply(int argc, const char **argv, char **envp)
+int cmd_apply(int argc, const char **argv, const char *prefix)
{
int i;
int read_stdin = 1;
diff --git a/builtin-cat-file.c b/builtin-cat-file.c
index 4d36817e5fed0e50f84eb48ac183b0c377596a86..814fb0743f7a453114991af6c28bb69ef44d4883 100644 (file)
--- a/builtin-cat-file.c
+++ b/builtin-cat-file.c
return 0;
}
-int cmd_cat_file(int argc, const char **argv, char **envp)
+int cmd_cat_file(int argc, const char **argv, const char *prefix)
{
unsigned char sha1[20];
char type[20];
unsigned long size;
int opt;
- setup_git_directory();
git_config(git_default_config);
if (argc != 3)
usage("git-cat-file [-t|-s|-e|-p|<type>] <sha1>");
index 4a23936aff8c21ca42a1b1e460543b1c775ccb45..701de439ae0f508f3a8ab41559230357be60637e 100644 (file)
#include "refs.h"
#include "builtin.h"
-int cmd_check_ref_format(int argc, const char **argv, char **envp)
+int cmd_check_ref_format(int argc, const char **argv, const char *prefix)
{
if (argc != 2)
usage("git check-ref-format refname");
diff --git a/builtin-commit-tree.c b/builtin-commit-tree.c
index ec082bf754a0ce5ae1615c41ba32c4515a927361..9c987966711d4bff1f709df0c14071170950e21d 100644 (file)
--- a/builtin-commit-tree.c
+++ b/builtin-commit-tree.c
return 1;
}
-int cmd_commit_tree(int argc, const char **argv, char **envp)
+int cmd_commit_tree(int argc, const char **argv, const char *prefix)
{
int i;
int parents = 0;
unsigned int size;
setup_ident();
- setup_git_directory();
-
git_config(git_default_config);
if (argc < 2)
diff --git a/builtin-count.c b/builtin-count.c
index 5ee72df247245cbf5fc8d5b70e8b1fddd5ab7edd..1d3729aa9914d6c68dbb6ad11cb46504b4a688e0 100644 (file)
--- a/builtin-count.c
+++ b/builtin-count.c
}
}
-int cmd_count_objects(int ac, const char **av, char **ep)
+int cmd_count_objects(int ac, const char **av, const char *prefix)
{
int i;
int verbose = 0;
diff --git a/builtin-diff-files.c b/builtin-diff-files.c
index ea2936a5ec8112d8d234b5bb3522e7be54c5a2d3..ac13db70ff741240f1f27f98dfe09614da4ea87c 100644 (file)
--- a/builtin-diff-files.c
+++ b/builtin-diff-files.c
"git-diff-files [-q] [-0/-1/2/3 |-c|--cc] [<common diff options>] [<path>...]"
COMMON_DIFF_OPTIONS_HELP;
-int cmd_diff_files(int argc, const char **argv, char **envp)
+int cmd_diff_files(int argc, const char **argv, const char *prefix)
{
struct rev_info rev;
int silent = 0;
- init_revisions(&rev, setup_git_directory());
+ init_revisions(&rev, prefix);
git_config(git_default_config); /* no "diff" UI options */
rev.abbrev = 0;
diff --git a/builtin-diff-index.c b/builtin-diff-index.c
index eeeee93fb77cc39351d071060cce9fc87f9a0216..95a3db156bda2d1e8d2ad7bdf72a9f9a821c6f51 100644 (file)
--- a/builtin-diff-index.c
+++ b/builtin-diff-index.c
"[<common diff options>] <tree-ish> [<path>...]"
COMMON_DIFF_OPTIONS_HELP;
-int cmd_diff_index(int argc, const char **argv, char **envp)
+int cmd_diff_index(int argc, const char **argv, const char *prefix)
{
struct rev_info rev;
int cached = 0;
int i;
- init_revisions(&rev, setup_git_directory());
+ init_revisions(&rev, prefix);
git_config(git_default_config); /* no "diff" UI options */
rev.abbrev = 0;
diff --git a/builtin-diff-stages.c b/builtin-diff-stages.c
index 9c62702941569511a149eba89a8be2b478f04b70..5960e089975f1f27c55c5bd8ea1c968ffe695d1f 100644 (file)
--- a/builtin-diff-stages.c
+++ b/builtin-diff-stages.c
}
}
-int cmd_diff_stages(int ac, const char **av, char **envp)
+int cmd_diff_stages(int ac, const char **av, const char *prefix)
{
int stage1, stage2;
- const char *prefix = setup_git_directory();
const char **pathspec = NULL;
git_config(git_default_config); /* no "diff" UI options */
diff --git a/builtin-diff-tree.c b/builtin-diff-tree.c
index f8215ea7072af34072a73221273c1b9cdadd18d6..24cb2d7f84064d7833fa04f33aeca6eafc8b931d 100644 (file)
--- a/builtin-diff-tree.c
+++ b/builtin-diff-tree.c
" --root include the initial commit as diff against /dev/null\n"
COMMON_DIFF_OPTIONS_HELP;
-int cmd_diff_tree(int argc, const char **argv, char **envp)
+int cmd_diff_tree(int argc, const char **argv, const char *prefix)
{
int nr_sha1;
char line[1000];
static struct rev_info *opt = &log_tree_opt;
int read_stdin = 0;
- init_revisions(opt, setup_git_directory());
+ init_revisions(opt, prefix);
git_config(git_default_config); /* no "diff" UI options */
nr_sha1 = 0;
opt->abbrev = 0;
diff --git a/builtin-diff.c b/builtin-diff.c
index 45b27cfca3975d4661651f98e951a0357686a961..48d2fd03b79c9c03e1e32b7743f936872a3684f1 100644 (file)
--- a/builtin-diff.c
+++ b/builtin-diff.c
add_pending_object(revs, obj, "HEAD");
}
-int cmd_diff(int argc, const char **argv, char **envp)
+int cmd_diff(int argc, const char **argv, const char *prefix)
{
int i;
struct rev_info rev;
struct object_array_entry ent[100];
int ents = 0, blobs = 0, paths = 0;
- const char *path = NULL, *prefix;
+ const char *path = NULL;
struct blobinfo blob[2];
/*
* Other cases are errors.
*/
- prefix = setup_git_directory();
git_config(git_diff_ui_config);
init_revisions(&rev, prefix);
index 338f2094f32504b71d41e16062010b75e33e96a3..c84224ee84803cbe4766b9e61da16da718a6eb15 100644 (file)
--- a/builtin-fmt-merge-msg.c
+++ b/builtin-fmt-merge-msg.c
free_list(&subjects);
}
-int cmd_fmt_merge_msg(int argc, char **argv, char **envp)
+int cmd_fmt_merge_msg(int argc, char **argv, const char *prefix)
{
int limit = 20, i = 0;
char line[1024];
const char *sep = "";
unsigned char head_sha1[20];
const char *head, *current_branch;
- const char *prefix = setup_git_directory();
git_config(fmt_merge_msg_config);
diff --git a/builtin-grep.c b/builtin-grep.c
index a79bac305aea880d6decb787836fe86295ead32e..69b7c4862af3bfcbc9aea2cb52abaa65b3e8490b 100644 (file)
--- a/builtin-grep.c
+++ b/builtin-grep.c
static const char emsg_missing_argument[] =
"option requires an argument -%s";
-int cmd_grep(int argc, const char **argv, char **envp)
+int cmd_grep(int argc, const char **argv, const char *prefix)
{
int hit = 0;
int cached = 0;
int seen_dashdash = 0;
struct grep_opt opt;
struct object_array list = { 0, 0, NULL };
- const char *prefix = setup_git_directory();
const char **paths = NULL;
int i;
diff --git a/builtin-help.c b/builtin-help.c
index bc1b4da3bc0186487fac40173203cac91c1e3710..bb0b03f1ae64cc5f4fa1376169c27b8a7cb71734 100644 (file)
--- a/builtin-help.c
+++ b/builtin-help.c
execlp("man", "man", page, NULL);
}
-int cmd_version(int argc, const char **argv, char **envp)
+int cmd_version(int argc, const char **argv, const char *prefix)
{
printf("git version %s\n", git_version_string);
return 0;
}
-int cmd_help(int argc, const char **argv, char **envp)
+int cmd_help(int argc, const char **argv, const char *prefix)
{
const char *help_cmd = argc > 1 ? argv[1] : NULL;
if (!help_cmd)
diff --git a/builtin-init-db.c b/builtin-init-db.c
index 7fdd2fa9f9f7fb2801c6e1fc398f78b414a269e1..52473edf569e4d318a74548acefaf4023f37c87c 100644 (file)
--- a/builtin-init-db.c
+++ b/builtin-init-db.c
* On the other hand, it might just make lookup slower and messier. You
* be the judge. The default case is to have one DB per managed directory.
*/
-int cmd_init_db(int argc, const char **argv, char **envp)
+int cmd_init_db(int argc, const char **argv, const char *prefix)
{
const char *git_dir;
const char *sha1_dir;
diff --git a/builtin-log.c b/builtin-log.c
index 52064cd178c2b705d6eec16de9f9a40eb4f5272b..82c69d1d0593156c5f7034746fe68f5a1a9f7276 100644 (file)
--- a/builtin-log.c
+++ b/builtin-log.c
/* this is in builtin-diff.c */
void add_head(struct rev_info *revs);
-static void cmd_log_init(int argc, const char **argv, char **envp,
+static void cmd_log_init(int argc, const char **argv, const char *prefix,
struct rev_info *rev)
{
rev->abbrev = DEFAULT_ABBREV;
return 0;
}
-int cmd_whatchanged(int argc, const char **argv, char **envp)
+int cmd_whatchanged(int argc, const char **argv, const char *prefix)
{
struct rev_info rev;
- const char *prefix = setup_git_directory();
git_config(git_diff_ui_config);
init_revisions(&rev, prefix);
rev.diff = 1;
rev.diffopt.recursive = 1;
rev.simplify_history = 0;
- cmd_log_init(argc, argv, envp, &rev);
+ cmd_log_init(argc, argv, prefix, &rev);
if (!rev.diffopt.output_format)
rev.diffopt.output_format = DIFF_FORMAT_RAW;
return cmd_log_walk(&rev);
}
-int cmd_show(int argc, const char **argv, char **envp)
+int cmd_show(int argc, const char **argv, const char *prefix)
{
struct rev_info rev;
- const char *prefix = setup_git_directory();
git_config(git_diff_ui_config);
init_revisions(&rev, prefix);
rev.always_show_header = 1;
rev.ignore_merges = 0;
rev.no_walk = 1;
- cmd_log_init(argc, argv, envp, &rev);
+ cmd_log_init(argc, argv, prefix, &rev);
return cmd_log_walk(&rev);
}
-int cmd_log(int argc, const char **argv, char **envp)
+int cmd_log(int argc, const char **argv, const char *prefix)
{
struct rev_info rev;
- const char *prefix = setup_git_directory();
git_config(git_diff_ui_config);
init_revisions(&rev, prefix);
rev.always_show_header = 1;
- cmd_log_init(argc, argv, envp, &rev);
+ cmd_log_init(argc, argv, prefix, &rev);
return cmd_log_walk(&rev);
}
return diff_flush_patch_id(options, sha1);
}
-static void get_patch_ids(struct rev_info *rev, struct diff_options *options)
+static void get_patch_ids(struct rev_info *rev, struct diff_options *options, const char *prefix)
{
struct rev_info check_rev;
struct commit *commit;
struct object *o1, *o2;
unsigned flags1, flags2;
unsigned char sha1[20];
- const char *prefix = setup_git_directory();
if (rev->pending.nr != 2)
die("Need exactly one range.");
(int)(email_end - email_start - 1), email_start + 1);
}
-int cmd_format_patch(int argc, const char **argv, char **envp)
+int cmd_format_patch(int argc, const char **argv, const char *prefix)
{
struct commit *commit;
struct commit **list = NULL;
char *add_signoff = NULL;
char message_id[1024];
char ref_message_id[1024];
- const char *prefix = setup_git_directory();
git_config(git_format_config);
init_revisions(&rev, prefix);
}
if (ignore_if_in_upstream)
- get_patch_ids(&rev, &patch_id_opts);
+ get_patch_ids(&rev, &patch_id_opts, prefix);
if (!use_stdout)
realstdout = fdopen(dup(1), "w");
diff --git a/builtin-ls-files.c b/builtin-ls-files.c
index 8dae9f70e2f9079d521fbc80e317addf41346d0f..79ffe8f42351f6ca5d01ce5601b6708bdfac7101 100644 (file)
--- a/builtin-ls-files.c
+++ b/builtin-ls-files.c
"[ --exclude-per-directory=<filename> ] [--full-name] [--abbrev] "
"[--] [<file>]*";
-int cmd_ls_files(int argc, const char **argv, char** envp)
+int cmd_ls_files(int argc, const char **argv, const char *prefix)
{
int i;
int exc_given = 0;
struct dir_struct dir;
memset(&dir, 0, sizeof(dir));
- prefix = setup_git_directory();
if (prefix)
prefix_offset = strlen(prefix);
git_config(git_default_config);
diff --git a/builtin-ls-tree.c b/builtin-ls-tree.c
index b8d0d88ba85d7c9770f64288971963250dc3391c..261147fdbe76cf9d277bd420cc17efedecc2da2f 100644 (file)
--- a/builtin-ls-tree.c
+++ b/builtin-ls-tree.c
static int ls_options = 0;
static const char **pathspec;
static int chomp_prefix = 0;
-static const char *prefix;
+static const char *ls_tree_prefix;
static const char ls_tree_usage[] =
"git-ls-tree [-d] [-r] [-t] [-z] [--name-only] [--name-status] [--full-name] [--abbrev[=<n>]] <tree-ish> [path...]";
return 0;
if (chomp_prefix &&
- (baselen < chomp_prefix || memcmp(prefix, base, chomp_prefix)))
+ (baselen < chomp_prefix || memcmp(ls_tree_prefix, base, chomp_prefix)))
return 0;
if (!(ls_options & LS_NAME_ONLY))
return retval;
}
-int cmd_ls_tree(int argc, const char **argv, char **envp)
+int cmd_ls_tree(int argc, const char **argv, const char *prefix)
{
unsigned char sha1[20];
struct tree *tree;
- prefix = setup_git_directory();
git_config(git_default_config);
+ ls_tree_prefix = prefix;
if (prefix && *prefix)
chomp_prefix = strlen(prefix);
while (1 < argc && argv[1][0] == '-') {
diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c
index 05dc1bfe71976ed24a4bb8cafb0036b8f93fadd6..24a4fc63b35ec4c6b5f85bda260811546b12ed46 100644 (file)
--- a/builtin-mailinfo.c
+++ b/builtin-mailinfo.c
static const char mailinfo_usage[] =
"git-mailinfo [-k] [-u | --encoding=<encoding>] msg patch <mail >info";
-int cmd_mailinfo(int argc, const char **argv, char **envp)
+int cmd_mailinfo(int argc, const char **argv, const char *prefix)
{
/* NEEDSWORK: might want to do the optional .git/ directory
* discovery
diff --git a/builtin-mailsplit.c b/builtin-mailsplit.c
index e2a0058435d396161145221eab80205a934b271c..91a699d34d93462b56f2591193bb5729b42b3950 100644 (file)
--- a/builtin-mailsplit.c
+++ b/builtin-mailsplit.c
free(name);
return ret;
}
-int cmd_mailsplit(int argc, const char **argv, char **envp)
+int cmd_mailsplit(int argc, const char **argv, const char *prefix)
{
int nr = 0, nr_prec = 4, ret;
int allow_bare = 0;
diff --git a/builtin-prune.c b/builtin-prune.c
index 4ed1e1b43ce9971eeae085a3534742c09f621bd0..6a86eb52aedc45b0a59adad4da31341440f2f82e 100644 (file)
--- a/builtin-prune.c
+++ b/builtin-prune.c
add_cache_tree(active_cache_tree);
}
-int cmd_prune(int argc, const char **argv, char **envp)
+int cmd_prune(int argc, const char **argv, const char *prefix)
{
int i;
* Set up revision parsing, and mark us as being interested
* in all object types, not just commits.
*/
- init_revisions(&revs, setup_git_directory());
+ init_revisions(&revs, prefix);
revs.tag_objects = 1;
revs.blob_objects = 1;
revs.tree_objects = 1;
diff --git a/builtin-push.c b/builtin-push.c
index 31cbfd73861326ad303472718365838329a55cb8..a824171066b8b02b82ee45030efa7e6ef359b995 100644 (file)
--- a/builtin-push.c
+++ b/builtin-push.c
return 0;
}
-int cmd_push(int argc, const char **argv, char **envp)
+int cmd_push(int argc, const char **argv, const char *prefix)
{
int i;
const char *repo = "origin"; /* default repository */
diff --git a/builtin-read-tree.c b/builtin-read-tree.c
index 122b6f130b37b27055efd7dffa25f41ef03698e8..49c10bf221961363b1edd073c926fe1bf92880c8 100644 (file)
--- a/builtin-read-tree.c
+++ b/builtin-read-tree.c
@@ -870,7 +870,7 @@ static const char read_tree_usage[] = "git-read-tree (<sha> | [[-m [--aggressive
static struct lock_file lock_file;
-int cmd_read_tree(int argc, const char **argv, char **envp)
+int cmd_read_tree(int argc, const char **argv, const char *prefix)
{
int i, newfd, stage = 0;
unsigned char sha1[20];
state.quiet = 1;
state.refresh_cache = 1;
- setup_git_directory();
git_config(git_default_config);
newfd = hold_lock_file_for_update(&lock_file, get_index_file());
diff --git a/builtin-rev-list.c b/builtin-rev-list.c
index 2b6691c8e4737a19acf3c57c8d75cbf09da6d939..0dee1734a31308ace74b0b25cc87ffcf4993549b 100644 (file)
--- a/builtin-rev-list.c
+++ b/builtin-rev-list.c
}
}
-int cmd_rev_list(int argc, const char **argv, char **envp)
+int cmd_rev_list(int argc, const char **argv, const char *prefix)
{
struct commit_list *list;
int i;
- init_revisions(&revs, setup_git_directory());
+ init_revisions(&revs, prefix);
revs.abbrev = 0;
revs.commit_format = CMIT_FMT_UNSPECIFIED;
argc = setup_revisions(argc, argv, &revs, NULL);
diff --git a/builtin-rev-parse.c b/builtin-rev-parse.c
index b3e4386c1baec7c3a56704e61e44e575203ab759..aca4a3603283a257f7621934103c85d5c0c31390 100644 (file)
--- a/builtin-rev-parse.c
+++ b/builtin-rev-parse.c
return 0;
}
-int cmd_rev_parse(int argc, const char **argv, char **envp)
+int cmd_rev_parse(int argc, const char **argv, const char *prefix)
{
int i, as_is = 0, verify = 0;
unsigned char sha1[20];
- const char *prefix = setup_git_directory();
git_config(git_default_config);
diff --git a/builtin-rm.c b/builtin-rm.c
index bb810ba41ae23c9dc4c38fbb0fa7883a33d43524..92d205a7153a7cc5267ea9cf774bc1e4fac887d4 100644 (file)
--- a/builtin-rm.c
+++ b/builtin-rm.c
static struct lock_file lock_file;
-int cmd_rm(int argc, const char **argv, char **envp)
+int cmd_rm(int argc, const char **argv, const char *prefix)
{
int i, newfd;
int verbose = 0, show_only = 0, force = 0;
- const char *prefix = setup_git_directory();
const char **pathspec;
char *seen;
diff --git a/builtin-show-branch.c b/builtin-show-branch.c
index 82f75b72dea1a5e6c620003d5c0c4c414dfe42e3..2a1b848f6c169f09cb168d12e6bb5033795b8be2 100644 (file)
--- a/builtin-show-branch.c
+++ b/builtin-show-branch.c
return 0;
}
-int cmd_show_branch(int ac, const char **av, char **envp)
+int cmd_show_branch(int ac, const char **av, const char *prefix)
{
struct commit *rev[MAX_REVS], *commit;
struct commit_list *list = NULL, *seen = NULL;
int topics = 0;
int dense = 1;
- setup_git_directory();
git_config(git_show_branch_config);
/* If nothing is specified, try the default first */
diff --git a/builtin-stripspace.c b/builtin-stripspace.c
index 2ce1264f7b4bfb5baf85f82907e2a8f7219846fa..09cc9108cdaf2aa20dc10788bccd2fee0ae9b02a 100644 (file)
--- a/builtin-stripspace.c
+++ b/builtin-stripspace.c
fputc('\n', out);
}
-int cmd_stripspace(int argc, const char **argv, char **envp)
+int cmd_stripspace(int argc, const char **argv, const char *prefix)
{
stripspace(stdin, stdout);
return 0;
diff --git a/builtin-tar-tree.c b/builtin-tar-tree.c
index e5aaded820bddfe2d5175508cc9c422b55a66eec..7c48db9ec85adb1b8866b2cc1dc0eccd2d1816c7 100644 (file)
--- a/builtin-tar-tree.c
+++ b/builtin-tar-tree.c
return git_default_config(var, value);
}
-static int generate_tar(int argc, const char **argv, char** envp)
+static int generate_tar(int argc, const char **argv, const char *prefix)
{
unsigned char sha1[20], tree_sha1[20];
struct commit *commit;
current_path.alloc = PATH_MAX;
current_path.len = current_path.eof = 0;
- setup_git_directory();
git_config(git_tar_config);
switch (argc) {
return !!ret;
}
-int cmd_tar_tree(int argc, const char **argv, char **envp)
+int cmd_tar_tree(int argc, const char **argv, const char *prefix)
{
if (argc < 2)
usage(tar_tree_usage);
if (!strncmp("--remote=", argv[1], 9))
return remote_tar(argc, argv);
- return generate_tar(argc, argv, envp);
+ return generate_tar(argc, argv, prefix);
}
/* ustar header + extended global header content */
#define HEADERSIZE (2 * RECORDSIZE)
-int cmd_get_tar_commit_id(int argc, const char **argv, char **envp)
+int cmd_get_tar_commit_id(int argc, const char **argv, const char *prefix)
{
char buffer[HEADERSIZE];
struct ustar_header *header = (struct ustar_header *)buffer;
diff --git a/builtin-update-index.c b/builtin-update-index.c
index 1a4200d151dd8e876c6f84531422cae50b049aa3..24dca47d8d6e54429aa89b04e4d67bda04fa0173 100644 (file)
--- a/builtin-update-index.c
+++ b/builtin-update-index.c
return 0;
}
-int cmd_update_index(int argc, const char **argv, char **envp)
+int cmd_update_index(int argc, const char **argv, const char *prefix)
{
int i, newfd, entries, has_errors = 0, line_termination = '\n';
int allow_options = 1;
int read_from_stdin = 0;
- const char *prefix = setup_git_directory();
int prefix_length = prefix ? strlen(prefix) : 0;
char set_executable_bit = 0;
unsigned int refresh_flags = 0;
diff --git a/builtin-update-ref.c b/builtin-update-ref.c
index 83094abe0f20d36bf2d9e65539fb2c8b7a5644fc..5bd71825fdc48392952faf170efe98c072c7e482 100644 (file)
--- a/builtin-update-ref.c
+++ b/builtin-update-ref.c
static const char git_update_ref_usage[] =
"git-update-ref <refname> <value> [<oldval>] [-m <reason>]";
-int cmd_update_ref(int argc, const char **argv, char **envp)
+int cmd_update_ref(int argc, const char **argv, const char *prefix)
{
const char *refname=NULL, *value=NULL, *oldval=NULL, *msg=NULL;
struct ref_lock *lock;
int i;
setup_ident();
- setup_git_directory();
git_config(git_default_config);
for (i = 1; i < argc; i++) {
diff --git a/builtin-upload-tar.c b/builtin-upload-tar.c
index d4fa7b56c39f03e8b48d513f967d89d4031bacb2..7b401bbb779ea0cc8bca3720eab612af2b50a4c3 100644 (file)
--- a/builtin-upload-tar.c
+++ b/builtin-upload-tar.c
return 1;
}
-int cmd_upload_tar(int argc, const char **argv, char **envp)
+int cmd_upload_tar(int argc, const char **argv, const char *prefix)
{
int len;
const char *dir = argv[1];
diff --git a/builtin-write-tree.c b/builtin-write-tree.c
index 449a4d1b575b591aa07a40532649f9ea06eb6890..0289f59936267194ccbb8276a525ad24198a5de9 100644 (file)
--- a/builtin-write-tree.c
+++ b/builtin-write-tree.c
return 0;
}
-int cmd_write_tree(int argc, const char **argv, char **envp)
+int cmd_write_tree(int argc, const char **argv, const char *unused_prefix)
{
int missing_ok = 0, ret;
const char *prefix = NULL;
unsigned char sha1[20];
- setup_git_directory();
-
while (1 < argc) {
const char *arg = argv[1];
if (!strcmp(arg, "--missing-ok"))
diff --git a/builtin.h b/builtin.h
index 5339d8627f48a44e3fbf3c81a0790bc467ccd459..de244cdf65f106edf020ca034d9c09bb60d77285 100644 (file)
--- a/builtin.h
+++ b/builtin.h
#endif
;
-extern int cmd_help(int argc, const char **argv, char **envp);
-extern int cmd_version(int argc, const char **argv, char **envp);
+extern int cmd_help(int argc, const char **argv, const char *prefix);
+extern int cmd_version(int argc, const char **argv, const char *prefix);
-extern int cmd_whatchanged(int argc, const char **argv, char **envp);
-extern int cmd_show(int argc, const char **argv, char **envp);
-extern int cmd_log(int argc, const char **argv, char **envp);
-extern int cmd_diff(int argc, const char **argv, char **envp);
-extern int cmd_format_patch(int argc, const char **argv, char **envp);
-extern int cmd_count_objects(int argc, const char **argv, char **envp);
+extern int cmd_whatchanged(int argc, const char **argv, const char *prefix);
+extern int cmd_show(int argc, const char **argv, const char *prefix);
+extern int cmd_log(int argc, const char **argv, const char *prefix);
+extern int cmd_diff(int argc, const char **argv, const char *prefix);
+extern int cmd_format_patch(int argc, const char **argv, const char *prefix);
+extern int cmd_count_objects(int argc, const char **argv, const char *prefix);
-extern int cmd_prune(int argc, const char **argv, char **envp);
+extern int cmd_prune(int argc, const char **argv, const char *prefix);
-extern int cmd_push(int argc, const char **argv, char **envp);
-extern int cmd_grep(int argc, const char **argv, char **envp);
-extern int cmd_rm(int argc, const char **argv, char **envp);
-extern int cmd_add(int argc, const char **argv, char **envp);
-extern int cmd_rev_list(int argc, const char **argv, char **envp);
-extern int cmd_check_ref_format(int argc, const char **argv, char **envp);
-extern int cmd_init_db(int argc, const char **argv, char **envp);
-extern int cmd_tar_tree(int argc, const char **argv, char **envp);
-extern int cmd_upload_tar(int argc, const char **argv, char **envp);
-extern int cmd_get_tar_commit_id(int argc, const char **argv, char **envp);
-extern int cmd_ls_files(int argc, const char **argv, char **envp);
-extern int cmd_ls_tree(int argc, const char **argv, char **envp);
-extern int cmd_read_tree(int argc, const char **argv, char **envp);
-extern int cmd_commit_tree(int argc, const char **argv, char **envp);
-extern int cmd_apply(int argc, const char **argv, char **envp);
-extern int cmd_show_branch(int argc, const char **argv, char **envp);
-extern int cmd_diff_files(int argc, const char **argv, char **envp);
-extern int cmd_diff_index(int argc, const char **argv, char **envp);
-extern int cmd_diff_stages(int argc, const char **argv, char **envp);
-extern int cmd_diff_tree(int argc, const char **argv, char **envp);
-extern int cmd_cat_file(int argc, const char **argv, char **envp);
-extern int cmd_rev_parse(int argc, const char **argv, char **envp);
-extern int cmd_update_index(int argc, const char **argv, char **envp);
-extern int cmd_update_ref(int argc, const char **argv, char **envp);
-extern int cmd_fmt_merge_msg(int argc, const char **argv, char **envp);
+extern int cmd_push(int argc, const char **argv, const char *prefix);
+extern int cmd_grep(int argc, const char **argv, const char *prefix);
+extern int cmd_rm(int argc, const char **argv, const char *prefix);
+extern int cmd_add(int argc, const char **argv, const char *prefix);
+extern int cmd_rev_list(int argc, const char **argv, const char *prefix);
+extern int cmd_check_ref_format(int argc, const char **argv, const char *prefix);
+extern int cmd_init_db(int argc, const char **argv, const char *prefix);
+extern int cmd_tar_tree(int argc, const char **argv, const char *prefix);
+extern int cmd_upload_tar(int argc, const char **argv, const char *prefix);
+extern int cmd_get_tar_commit_id(int argc, const char **argv, const char *prefix);
+extern int cmd_ls_files(int argc, const char **argv, const char *prefix);
+extern int cmd_ls_tree(int argc, const char **argv, const char *prefix);
+extern int cmd_read_tree(int argc, const char **argv, const char *prefix);
+extern int cmd_commit_tree(int argc, const char **argv, const char *prefix);
+extern int cmd_apply(int argc, const char **argv, const char *prefix);
+extern int cmd_show_branch(int argc, const char **argv, const char *prefix);
+extern int cmd_diff_files(int argc, const char **argv, const char *prefix);
+extern int cmd_diff_index(int argc, const char **argv, const char *prefix);
+extern int cmd_diff_stages(int argc, const char **argv, const char *prefix);
+extern int cmd_diff_tree(int argc, const char **argv, const char *prefix);
+extern int cmd_cat_file(int argc, const char **argv, const char *prefix);
+extern int cmd_rev_parse(int argc, const char **argv, const char *prefix);
+extern int cmd_update_index(int argc, const char **argv, const char *prefix);
+extern int cmd_update_ref(int argc, const char **argv, const char *prefix);
+extern int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix);
-extern int cmd_write_tree(int argc, const char **argv, char **envp);
+extern int cmd_write_tree(int argc, const char **argv, const char *prefix);
extern int write_tree(unsigned char *sha1, int missing_ok, const char *prefix);
-extern int cmd_mailsplit(int argc, const char **argv, char **envp);
+extern int cmd_mailsplit(int argc, const char **argv, const char *prefix);
extern int split_mbox(const char **mbox, const char *dir, int allow_bare, int nr_prec, int skip);
-extern int cmd_mailinfo(int argc, const char **argv, char **envp);
+extern int cmd_mailinfo(int argc, const char **argv, const char *prefix);
extern int mailinfo(FILE *in, FILE *out, int ks, const char *encoding, const char *msg, const char *patch);
-extern int cmd_stripspace(int argc, const char **argv, char **envp);
+extern int cmd_stripspace(int argc, const char **argv, const char *prefix);
extern void stripspace(FILE *in, FILE *out);
#endif
index 885e1ce75b5c085c544c74029d2a32562b4fcaa1..79db43e143b289d7e6857ee59cd8b68c7d656b49 100644 (file)
--- a/git.c
+++ b/git.c
const char git_version_string[] = GIT_VERSION;
+#define NEEDS_PREFIX 1
+
static void handle_internal_command(int argc, const char **argv, char **envp)
{
const char *cmd = argv[0];
static struct cmd_struct {
const char *cmd;
- int (*fn)(int, const char **, char **);
+ int (*fn)(int, const char **, const char *);
+ int prefix;
} commands[] = {
{ "version", cmd_version },
{ "help", cmd_help },
- { "log", cmd_log },
- { "whatchanged", cmd_whatchanged },
- { "show", cmd_show },
+ { "log", cmd_log, NEEDS_PREFIX },
+ { "whatchanged", cmd_whatchanged, NEEDS_PREFIX },
+ { "show", cmd_show, NEEDS_PREFIX },
{ "push", cmd_push },
- { "format-patch", cmd_format_patch },
+ { "format-patch", cmd_format_patch, NEEDS_PREFIX },
{ "count-objects", cmd_count_objects },
- { "diff", cmd_diff },
- { "grep", cmd_grep },
- { "rm", cmd_rm },
- { "add", cmd_add },
- { "rev-list", cmd_rev_list },
+ { "diff", cmd_diff, NEEDS_PREFIX },
+ { "grep", cmd_grep, NEEDS_PREFIX },
+ { "rm", cmd_rm, NEEDS_PREFIX },
+ { "add", cmd_add, NEEDS_PREFIX },
+ { "rev-list", cmd_rev_list, NEEDS_PREFIX },
{ "init-db", cmd_init_db },
{ "get-tar-commit-id", cmd_get_tar_commit_id },
{ "upload-tar", cmd_upload_tar },
{ "check-ref-format", cmd_check_ref_format },
- { "ls-files", cmd_ls_files },
- { "ls-tree", cmd_ls_tree },
- { "tar-tree", cmd_tar_tree },
- { "read-tree", cmd_read_tree },
- { "commit-tree", cmd_commit_tree },
+ { "ls-files", cmd_ls_files, NEEDS_PREFIX },
+ { "ls-tree", cmd_ls_tree, NEEDS_PREFIX },
+ { "tar-tree", cmd_tar_tree, NEEDS_PREFIX },
+ { "read-tree", cmd_read_tree, NEEDS_PREFIX },
+ { "commit-tree", cmd_commit_tree, NEEDS_PREFIX },
{ "apply", cmd_apply },
- { "show-branch", cmd_show_branch },
- { "diff-files", cmd_diff_files },
- { "diff-index", cmd_diff_index },
- { "diff-stages", cmd_diff_stages },
- { "diff-tree", cmd_diff_tree },
- { "cat-file", cmd_cat_file },
- { "rev-parse", cmd_rev_parse },
- { "write-tree", cmd_write_tree },
+ { "show-branch", cmd_show_branch, NEEDS_PREFIX },
+ { "diff-files", cmd_diff_files, NEEDS_PREFIX },
+ { "diff-index", cmd_diff_index, NEEDS_PREFIX },
+ { "diff-stages", cmd_diff_stages, NEEDS_PREFIX },
+ { "diff-tree", cmd_diff_tree, NEEDS_PREFIX },
+ { "cat-file", cmd_cat_file, NEEDS_PREFIX },
+ { "rev-parse", cmd_rev_parse, NEEDS_PREFIX },
+ { "write-tree", cmd_write_tree, NEEDS_PREFIX },
{ "mailsplit", cmd_mailsplit },
{ "mailinfo", cmd_mailinfo },
{ "stripspace", cmd_stripspace },
- { "update-index", cmd_update_index },
- { "update-ref", cmd_update_ref },
- { "fmt-merge-msg", cmd_fmt_merge_msg },
- { "prune", cmd_prune },
+ { "update-index", cmd_update_index, NEEDS_PREFIX },
+ { "update-ref", cmd_update_ref, NEEDS_PREFIX },
+ { "fmt-merge-msg", cmd_fmt_merge_msg, NEEDS_PREFIX },
+ { "prune", cmd_prune, NEEDS_PREFIX },
};
int i;
for (i = 0; i < ARRAY_SIZE(commands); i++) {
struct cmd_struct *p = commands+i;
+ const char *prefix;
if (strcmp(p->cmd, cmd))
continue;
+ prefix = NULL;
+ if (p->prefix)
+ prefix = setup_git_directory();
if (getenv("GIT_TRACE")) {
int i;
fprintf(stderr, "trace: built-in: git");
fflush(stderr);
}
- exit(p->fn(argc, argv, envp));
+ exit(p->fn(argc, argv, prefix));
}
}