aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-08-31 16:23:31 -0700
committerJunio C Hamano <gitster@pobox.com>2010-08-31 16:23:31 -0700
commit633142d86874ee8ce79a23ee4346f32e6271faad (patch)
tree8096e26f84075d3aae42d13fe0b76c2a5f2ea07c /builtin
parent693fefe3d022767975eec7585561bfe178b873f4 (diff)
parent41bf3bc232cf5f99fdc6d3d729536a4c4821d3bd (diff)
downloadgit-633142d86874ee8ce79a23ee4346f32e6271faad.tar.gz
git-633142d86874ee8ce79a23ee4346f32e6271faad.tar.xz
Merge branch 'jn/paginate-fix'
* jn/paginate-fix: t7006 (pager): add missing TTY prerequisites merge-file: run setup_git_directory_gently() sooner var: run setup_git_directory_gently() sooner ls-remote: run setup_git_directory_gently() sooner index-pack: run setup_git_directory_gently() sooner config: run setup_git_directory_gently() sooner bundle: run setup_git_directory_gently() sooner apply: run setup_git_directory_gently() sooner grep: run setup_git_directory_gently() sooner shortlog: run setup_git_directory_gently() sooner git wrapper: allow setup_git_directory_gently() be called earlier setup: remember whether repository was found git wrapper: introduce startup_info struct Conflicts: builtin/index-pack.c
Diffstat (limited to 'builtin')
-rw-r--r--builtin/apply.c6
-rw-r--r--builtin/bundle.c6
-rw-r--r--builtin/config.c5
-rw-r--r--builtin/grep.c6
-rw-r--r--builtin/index-pack.c2
-rw-r--r--builtin/ls-remote.c3
-rw-r--r--builtin/merge-file.c4
-rw-r--r--builtin/shortlog.c3
-rw-r--r--builtin/var.c9
9 files changed, 13 insertions, 31 deletions
diff --git a/builtin/apply.c b/builtin/apply.c
index f38c1f7b8..470520bde 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -3606,11 +3606,11 @@ static int option_parse_directory(const struct option *opt,
return 0;
}
-int cmd_apply(int argc, const char **argv, const char *unused_prefix)
+int cmd_apply(int argc, const char **argv, const char *prefix_)
{
int i;
int errs = 0;
- int is_not_gitdir;
+ int is_not_gitdir = !startup_info->have_repository;
int binary;
int force_apply = 0;
@@ -3683,7 +3683,7 @@ int cmd_apply(int argc, const char **argv, const char *unused_prefix)
OPT_END()
};
- prefix = setup_git_directory_gently(&is_not_gitdir);
+ prefix = prefix_;
prefix_length = prefix ? strlen(prefix) : 0;
git_config(git_apply_config, NULL);
if (apply_default_whitespace)
diff --git a/builtin/bundle.c b/builtin/bundle.c
index 2006cc5cd..80649ba0b 100644
--- a/builtin/bundle.c
+++ b/builtin/bundle.c
@@ -18,7 +18,6 @@ static const char builtin_bundle_usage[] =
int cmd_bundle(int argc, const char **argv, const char *prefix)
{
struct bundle_header header;
- int nongit;
const char *cmd, *bundle_file;
int bundle_fd = -1;
char buffer[PATH_MAX];
@@ -31,7 +30,6 @@ int cmd_bundle(int argc, const char **argv, const char *prefix)
argc -= 2;
argv += 2;
- prefix = setup_git_directory_gently(&nongit);
if (prefix && bundle_file[0] != '/') {
snprintf(buffer, sizeof(buffer), "%s/%s", prefix, bundle_file);
bundle_file = buffer;
@@ -54,11 +52,11 @@ int cmd_bundle(int argc, const char **argv, const char *prefix)
return !!list_bundle_refs(&header, argc, argv);
}
if (!strcmp(cmd, "create")) {
- if (nongit)
+ if (!startup_info->have_repository)
die("Need a repository to create a bundle.");
return !!create_bundle(&header, bundle_file, argc, argv);
} else if (!strcmp(cmd, "unbundle")) {
- if (nongit)
+ if (!startup_info->have_repository)
die("Need a repository to unbundle.");
return !!unbundle(&header, bundle_fd) ||
list_bundle_refs(&header, argc, argv);
diff --git a/builtin/config.c b/builtin/config.c
index 79fee767b..ca4a0db4a 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -331,11 +331,10 @@ static int get_colorbool(int print)
return get_colorbool_found ? 0 : 1;
}
-int cmd_config(int argc, const char **argv, const char *unused_prefix)
+int cmd_config(int argc, const char **argv, const char *prefix)
{
- int nongit;
+ int nongit = !startup_info->have_repository;
char *value;
- const char *prefix = setup_git_directory_gently(&nongit);
config_exclusive_filename = getenv(CONFIG_ENVIRONMENT);
diff --git a/builtin/grep.c b/builtin/grep.c
index b725ede0f..da32f3df3 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -839,7 +839,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
struct string_list path_list = STRING_LIST_INIT_NODUP;
int i;
int dummy;
- int nongit = 0, use_index = 1;
+ int use_index = 1;
struct option options[] = {
OPT_BOOLEAN(0, "cached", &cached,
"search in index instead of in the work tree"),
@@ -930,8 +930,6 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
OPT_END()
};
- prefix = setup_git_directory_gently(&nongit);
-
/*
* 'git grep -h', unlike 'git grep -h <pattern>', is a request
* to show usage information and exit.
@@ -976,7 +974,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
PARSE_OPT_STOP_AT_NON_OPTION |
PARSE_OPT_NO_INTERNAL_HELP);
- if (use_index && nongit)
+ if (use_index && !startup_info->have_repository)
/* die the same way as if we did it at the beginning */
setup_git_directory();
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index 96333d48c..2e680d7a7 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -880,14 +880,12 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
char *index_name_buf = NULL, *keep_name_buf = NULL;
struct pack_idx_entry **idx_objects;
unsigned char pack_sha1[20];
- int nongit;
if (argc == 2 && !strcmp(argv[1], "-h"))
usage(index_pack_usage);
read_replace_refs = 0;
- prefix = setup_git_directory_gently(&nongit);
git_config(git_index_pack_config, NULL);
if (prefix && chdir(prefix))
die("Cannot come back to cwd");
diff --git a/builtin/ls-remote.c b/builtin/ls-remote.c
index 34480cfad..97eed4012 100644
--- a/builtin/ls-remote.c
+++ b/builtin/ls-remote.c
@@ -32,7 +32,6 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
{
int i;
const char *dest = NULL;
- int nongit;
unsigned flags = 0;
int quiet = 0;
const char *uploadpack = NULL;
@@ -42,8 +41,6 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
struct transport *transport;
const struct ref *ref;
- setup_git_directory_gently(&nongit);
-
for (i = 1; i < argc; i++) {
const char *arg = argv[i];
diff --git a/builtin/merge-file.c b/builtin/merge-file.c
index b8e9e5ba0..b6664d49b 100644
--- a/builtin/merge-file.c
+++ b/builtin/merge-file.c
@@ -28,7 +28,6 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
xmparam_t xmp = {{0}};
int ret = 0, i = 0, to_stdout = 0;
int quiet = 0;
- int nongit;
struct option options[] = {
OPT_BOOLEAN('p', "stdout", &to_stdout, "send results to standard output"),
OPT_SET_INT(0, "diff3", &xmp.style, "use a diff3 based merge", XDL_MERGE_DIFF3),
@@ -50,8 +49,7 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
xmp.style = 0;
xmp.favor = 0;
- prefix = setup_git_directory_gently(&nongit);
- if (!nongit) {
+ if (startup_info->have_repository) {
/* Read the configuration file */
git_config(git_xmerge_config, NULL);
if (0 <= git_xmerge_style)
diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index 0a9681ba7..2135b0dde 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
@@ -249,7 +249,7 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix)
{
static struct shortlog log;
static struct rev_info rev;
- int nongit;
+ int nongit = !startup_info->have_repository;
static const struct option options[] = {
OPT_BOOLEAN('n', "numbered", &log.sort_by_number,
@@ -265,7 +265,6 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix)
struct parse_opt_ctx_t ctx;
- prefix = setup_git_directory_gently(&nongit);
git_config(git_default_config, NULL);
shortlog_init(&log);
init_revisions(&rev, prefix);
diff --git a/builtin/var.c b/builtin/var.c
index 70fdb4dec..0744bb831 100644
--- a/builtin/var.c
+++ b/builtin/var.c
@@ -74,14 +74,9 @@ static int show_config(const char *var, const char *value, void *cb)
int cmd_var(int argc, const char **argv, const char *prefix)
{
- const char *val;
- int nongit;
- if (argc != 2) {
+ const char *val = NULL;
+ if (argc != 2)
usage(var_usage);
- }
-
- setup_git_directory_gently(&nongit);
- val = NULL;
if (strcmp(argv[1], "-l") == 0) {
git_config(show_config, NULL);