* [PATCH 00/18] Search and set up repository early for builtin commands
@ 2010-03-07 4:55 Nguyễn Thái Ngọc Duy
2010-03-07 4:55 ` [PATCH 01/18] builtin: introduce startup_info struct Nguyễn Thái Ngọc Duy
` (17 more replies)
0 siblings, 18 replies; 19+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-03-07 4:55 UTC (permalink / raw)
To: git; +Cc: Nguyễn Thái Ngọc Duy
This is a simpler part of my Git setup cleanup WIP [1], to introduce
RUN_SETUP_GENTLY and make most of commands use it.
The commands that do not have RUN_SETUP* are:
- Init/Clone commands
- Server commands
- Helpers that have nothing to do with repositories
- git-rev-parse
[1] http://mid.gmane.org/1266336317-607-1-git-send-email-pclouds@gmail.com
Nguyễn Thái Ngọc Duy (18):
builtin: introduce startup_info struct
builtin: Support RUN_SETUP_GENTLY to set up repository early if found
config: use RUN_SETUP_GENTLY
hash-object: use RUN_SETUP_GENTLY
shortlog: use RUN_SETUP_GENTLY
grep: use RUN_SETUP_GENTLY
builtin: USE_PAGER should not be used without RUN_SETUP*
archive: use RUN_SETUP_GENTLY
mailinfo: use RUN_SETUP_GENTLY
check-ref-format: use RUN_SETUP_GENTLY
verify-pack: use RUN_SETUP_GENTLY
apply: use RUN_SETUP_GENTLY
bundle: use RUN_SETUP_GENTLY
diff: use RUN_SETUP_GENTLY
help: use RUN_SETUP_GENTLY
ls-remote: use RUN_SETUP_GENTLY
var: use RUN_SETUP_GENTLY
merge-file: use RUN_SETUP_GENTLY
builtin/apply.c | 7 ++---
builtin/archive.c | 2 +-
builtin/bundle.c | 6 +---
builtin/config.c | 6 +---
builtin/diff.c | 6 +---
builtin/grep.c | 9 ++-----
builtin/hash-object.c | 9 ++++---
builtin/help.c | 2 -
builtin/ls-remote.c | 3 --
builtin/mailinfo.c | 3 --
builtin/merge-file.c | 4 +--
builtin/shortlog.c | 4 +--
builtin/var.c | 2 -
cache.h | 7 +++++
environment.c | 1 +
git.c | 61 ++++++++++++++++++++++++++++---------------------
setup.c | 14 ++++++++++-
17 files changed, 76 insertions(+), 70 deletions(-)
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 01/18] builtin: introduce startup_info struct
2010-03-07 4:55 [PATCH 00/18] Search and set up repository early for builtin commands Nguyễn Thái Ngọc Duy
@ 2010-03-07 4:55 ` Nguyễn Thái Ngọc Duy
2010-03-07 4:55 ` [PATCH 02/18] builtin: Support RUN_SETUP_GENTLY to set up repository early if found Nguyễn Thái Ngọc Duy
` (16 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-03-07 4:55 UTC (permalink / raw)
To: git; +Cc: Nguyễn Thái Ngọc Duy
The purpose of this struct is to make it easier to extend parameters
passed to builtin commands from run_builtin(), and let libgit aware of
some global states in future.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
cache.h | 6 ++++++
environment.c | 1 +
git.c | 9 +++++----
setup.c | 12 +++++++++++-
4 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/cache.h b/cache.h
index 89f6a40..30fddf1 100644
--- a/cache.h
+++ b/cache.h
@@ -1054,4 +1054,10 @@ void overlay_tree_on_cache(const char *tree_name, const char *prefix);
char *alias_lookup(const char *alias);
int split_cmdline(char *cmdline, const char ***argv);
+/* git.c */
+struct startup_info {
+ const char *prefix;
+};
+extern struct startup_info *startup_info;
+
#endif /* CACHE_H */
diff --git a/environment.c b/environment.c
index 876c5e5..c36c902 100644
--- a/environment.c
+++ b/environment.c
@@ -52,6 +52,7 @@ enum object_creation_mode object_creation_mode = OBJECT_CREATION_MODE;
char *notes_ref_name;
int grafts_replace_parents = 1;
int core_apply_sparse_checkout;
+struct startup_info *startup_info;
/* Parallel index stat data preload? */
int core_preload_index = 0;
diff --git a/git.c b/git.c
index 6bae305..4be34e4 100644
--- a/git.c
+++ b/git.c
@@ -13,6 +13,7 @@ const char git_usage_string[] =
const char git_more_info_string[] =
"See 'git help COMMAND' for more information on a specific command.";
+static struct startup_info git_startup_info;
static int use_pager = -1;
struct pager_config {
const char *cmd;
@@ -237,13 +238,13 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
{
int status, help;
struct stat st;
- const char *prefix;
- prefix = NULL;
+ memset(&git_startup_info, 0, sizeof(git_startup_info));
+ startup_info = &git_startup_info;
help = argc == 2 && !strcmp(argv[1], "-h");
if (!help) {
if (p->option & RUN_SETUP)
- prefix = setup_git_directory();
+ setup_git_directory();
if (use_pager == -1 && p->option & RUN_SETUP)
use_pager = check_pager_config(p->cmd);
@@ -257,7 +258,7 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
trace_argv_printf(argv, "trace: built-in: git");
- status = p->fn(argc, argv, prefix);
+ status = p->fn(argc, argv, startup_info->prefix);
if (status)
return status;
diff --git a/setup.c b/setup.c
index 5716d90..cf1b37d 100644
--- a/setup.c
+++ b/setup.c
@@ -315,7 +315,7 @@ const char *read_gitfile_gently(const char *path)
* We cannot decide in this function whether we are in the work tree or
* not, since the config can only be read _after_ this function was called.
*/
-const char *setup_git_directory_gently(int *nongit_ok)
+static const char *setup_git_directory_gently_1(int *nongit_ok)
{
const char *work_tree_env = getenv(GIT_WORK_TREE_ENVIRONMENT);
const char *env_ceiling_dirs = getenv(CEILING_DIRECTORIES_ENVIRONMENT);
@@ -443,6 +443,16 @@ const char *setup_git_directory_gently(int *nongit_ok)
return cwd + offset;
}
+const char *setup_git_directory_gently(int *nongit_ok)
+{
+ const char *prefix;
+
+ prefix = setup_git_directory_gently_1(nongit_ok);
+ if (startup_info)
+ startup_info->prefix = prefix;
+ return prefix;
+}
+
int git_config_perm(const char *var, const char *value)
{
int i;
--
1.7.0.195.g637a2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 02/18] builtin: Support RUN_SETUP_GENTLY to set up repository early if found
2010-03-07 4:55 [PATCH 00/18] Search and set up repository early for builtin commands Nguyễn Thái Ngọc Duy
2010-03-07 4:55 ` [PATCH 01/18] builtin: introduce startup_info struct Nguyễn Thái Ngọc Duy
@ 2010-03-07 4:55 ` Nguyễn Thái Ngọc Duy
2010-03-07 4:55 ` [PATCH 03/18] config: use RUN_SETUP_GENTLY Nguyễn Thái Ngọc Duy
` (15 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-03-07 4:55 UTC (permalink / raw)
To: git; +Cc: Nguyễn Thái Ngọc Duy
Attempts to access gitdir are everywhere, even before cmd_*() is
called. Because repository has not been found, repository-specific
information (i.e. $GIT_DIR/config) may not be read. This leads to
obscure bugs.
So the sooner we setup gitdir, the less trouble we may have to deal with.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
cache.h | 1 +
git.c | 11 ++++++++---
setup.c | 4 +++-
3 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/cache.h b/cache.h
index 30fddf1..68412c0 100644
--- a/cache.h
+++ b/cache.h
@@ -1057,6 +1057,7 @@ int split_cmdline(char *cmdline, const char ***argv);
/* git.c */
struct startup_info {
const char *prefix;
+ int have_repository;
};
extern struct startup_info *startup_info;
diff --git a/git.c b/git.c
index 4be34e4..9e0e2d0 100644
--- a/git.c
+++ b/git.c
@@ -220,13 +220,14 @@ static int handle_alias(int *argcp, const char ***argv)
const char git_version_string[] = GIT_VERSION;
-#define RUN_SETUP (1<<0)
-#define USE_PAGER (1<<1)
+#define RUN_SETUP (1<<0)
+#define USE_PAGER (1<<1)
/*
* require working tree to be present -- anything uses this needs
* RUN_SETUP for reading from the configuration file.
*/
-#define NEED_WORK_TREE (1<<2)
+#define NEED_WORK_TREE (1<<2)
+#define RUN_SETUP_GENTLY (1<<3)
struct cmd_struct {
const char *cmd;
@@ -245,6 +246,10 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
if (!help) {
if (p->option & RUN_SETUP)
setup_git_directory();
+ if (p->option & RUN_SETUP_GENTLY) {
+ int nongit_ok;
+ setup_git_directory_gently(&nongit_ok);
+ }
if (use_pager == -1 && p->option & RUN_SETUP)
use_pager = check_pager_config(p->cmd);
diff --git a/setup.c b/setup.c
index cf1b37d..bb3648c 100644
--- a/setup.c
+++ b/setup.c
@@ -448,8 +448,10 @@ const char *setup_git_directory_gently(int *nongit_ok)
const char *prefix;
prefix = setup_git_directory_gently_1(nongit_ok);
- if (startup_info)
+ if (startup_info) {
startup_info->prefix = prefix;
+ startup_info->have_repository = !nongit_ok || !*nongit_ok;
+ }
return prefix;
}
--
1.7.0.195.g637a2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 03/18] config: use RUN_SETUP_GENTLY
2010-03-07 4:55 [PATCH 00/18] Search and set up repository early for builtin commands Nguyễn Thái Ngọc Duy
2010-03-07 4:55 ` [PATCH 01/18] builtin: introduce startup_info struct Nguyễn Thái Ngọc Duy
2010-03-07 4:55 ` [PATCH 02/18] builtin: Support RUN_SETUP_GENTLY to set up repository early if found Nguyễn Thái Ngọc Duy
@ 2010-03-07 4:55 ` Nguyễn Thái Ngọc Duy
2010-03-07 4:55 ` [PATCH 04/18] hash-object: " Nguyễn Thái Ngọc Duy
` (14 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-03-07 4:55 UTC (permalink / raw)
To: git; +Cc: Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
builtin/config.c | 6 ++----
git.c | 4 ++--
2 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/builtin/config.c b/builtin/config.c
index 4bc46b1..ecc8f87 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -326,11 +326,9 @@ 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;
char *value;
- const char *prefix = setup_git_directory_gently(&nongit);
config_exclusive_filename = getenv(CONFIG_ENVIRONMENT);
@@ -409,7 +407,7 @@ int cmd_config(int argc, const char **argv, const char *unused_prefix)
}
else if (actions == ACTION_EDIT) {
check_argc(argc, 0, 0);
- if (!config_exclusive_filename && nongit)
+ if (!config_exclusive_filename && !startup_info->have_repository)
die("not in a git directory");
git_config(git_default_config, NULL);
launch_editor(config_exclusive_filename ?
diff --git a/git.c b/git.c
index 9e0e2d0..4c99319 100644
--- a/git.c
+++ b/git.c
@@ -309,7 +309,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "clean", cmd_clean, RUN_SETUP | NEED_WORK_TREE },
{ "commit", cmd_commit, RUN_SETUP | NEED_WORK_TREE },
{ "commit-tree", cmd_commit_tree, RUN_SETUP },
- { "config", cmd_config },
+ { "config", cmd_config, RUN_SETUP_GENTLY },
{ "count-objects", cmd_count_objects, RUN_SETUP },
{ "describe", cmd_describe, RUN_SETUP },
{ "diff", cmd_diff },
@@ -366,7 +366,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "reflog", cmd_reflog, RUN_SETUP },
{ "remote", cmd_remote, RUN_SETUP },
{ "replace", cmd_replace, RUN_SETUP },
- { "repo-config", cmd_config },
+ { "repo-config", cmd_config, RUN_SETUP_GENTLY },
{ "rerere", cmd_rerere, RUN_SETUP },
{ "reset", cmd_reset, RUN_SETUP },
{ "rev-list", cmd_rev_list, RUN_SETUP },
--
1.7.0.195.g637a2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 04/18] hash-object: use RUN_SETUP_GENTLY
2010-03-07 4:55 [PATCH 00/18] Search and set up repository early for builtin commands Nguyễn Thái Ngọc Duy
` (2 preceding siblings ...)
2010-03-07 4:55 ` [PATCH 03/18] config: use RUN_SETUP_GENTLY Nguyễn Thái Ngọc Duy
@ 2010-03-07 4:55 ` Nguyễn Thái Ngọc Duy
2010-03-07 4:55 ` [PATCH 05/18] shortlog: " Nguyễn Thái Ngọc Duy
` (13 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-03-07 4:55 UTC (permalink / raw)
To: git; +Cc: Nguyễn Thái Ngọc Duy
hash-object needs to inspect repository's config, so it must try to
find a repository regardless the object will be written in object
store.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
builtin/hash-object.c | 9 +++++----
git.c | 2 +-
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/builtin/hash-object.c b/builtin/hash-object.c
index 6a5f5b5..57330b8 100644
--- a/builtin/hash-object.c
+++ b/builtin/hash-object.c
@@ -76,7 +76,7 @@ static const struct option hash_object_options[] = {
int cmd_hash_object(int argc, const char **argv, const char *prefix)
{
int i;
- int prefix_length = -1;
+ int prefix_length;
const char *errstr = NULL;
type = blob_type;
@@ -84,9 +84,10 @@ int cmd_hash_object(int argc, const char **argv, const char *prefix)
argc = parse_options(argc, argv, NULL, hash_object_options,
hash_object_usage, 0);
+ prefix_length = prefix ? strlen(prefix) : 0;
if (write_object) {
- prefix = setup_git_directory();
- prefix_length = prefix ? strlen(prefix) : 0;
+ if (!startup_info->have_repository)
+ die("No repository found");
if (vpath && prefix)
vpath = prefix_filename(prefix, prefix_length, vpath);
}
@@ -121,7 +122,7 @@ int cmd_hash_object(int argc, const char **argv, const char *prefix)
for (i = 0 ; i < argc; i++) {
const char *arg = argv[i];
- if (0 <= prefix_length)
+ if (prefix_length)
arg = prefix_filename(prefix, prefix_length, arg);
hash_object(arg, type, write_object,
no_filters ? NULL : vpath ? vpath : arg);
diff --git a/git.c b/git.c
index 4c99319..2069ef3 100644
--- a/git.c
+++ b/git.c
@@ -327,7 +327,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "gc", cmd_gc, RUN_SETUP },
{ "get-tar-commit-id", cmd_get_tar_commit_id },
{ "grep", cmd_grep, USE_PAGER },
- { "hash-object", cmd_hash_object },
+ { "hash-object", cmd_hash_object, RUN_SETUP_GENTLY },
{ "help", cmd_help },
{ "index-pack", cmd_index_pack },
{ "init", cmd_init_db },
--
1.7.0.195.g637a2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 05/18] shortlog: use RUN_SETUP_GENTLY
2010-03-07 4:55 [PATCH 00/18] Search and set up repository early for builtin commands Nguyễn Thái Ngọc Duy
` (3 preceding siblings ...)
2010-03-07 4:55 ` [PATCH 04/18] hash-object: " Nguyễn Thái Ngọc Duy
@ 2010-03-07 4:55 ` Nguyễn Thái Ngọc Duy
2010-03-07 4:55 ` [PATCH 06/18] grep: " Nguyễn Thái Ngọc Duy
` (12 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-03-07 4:55 UTC (permalink / raw)
To: git; +Cc: Nguyễn Thái Ngọc Duy
shortlog has USE_PAGER set. setup_pager() may read config even
setup_git_dir* is not run yet. This tries to find a repository before
the config is read.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
builtin/shortlog.c | 4 +---
git.c | 2 +-
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index 06320f5..bdf3402 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
@@ -249,7 +249,6 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix)
{
static struct shortlog log;
static struct rev_info rev;
- int nongit;
static const struct option options[] = {
OPT_BOOLEAN('n', "numbered", &log.sort_by_number,
@@ -265,7 +264,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);
@@ -292,7 +290,7 @@ parse_done:
log.user_format = rev.commit_format == CMIT_FMT_USERFORMAT;
/* assume HEAD if from a tty */
- if (!nongit && !rev.pending.nr && isatty(0))
+ if (startup_info->have_repository && !rev.pending.nr && isatty(0))
add_head_to_pending(&rev);
if (rev.pending.nr == 0) {
if (isatty(0))
diff --git a/git.c b/git.c
index 2069ef3..29489e6 100644
--- a/git.c
+++ b/git.c
@@ -374,7 +374,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "revert", cmd_revert, RUN_SETUP | NEED_WORK_TREE },
{ "rm", cmd_rm, RUN_SETUP },
{ "send-pack", cmd_send_pack, RUN_SETUP },
- { "shortlog", cmd_shortlog, USE_PAGER },
+ { "shortlog", cmd_shortlog, RUN_SETUP_GENTLY | USE_PAGER },
{ "show-branch", cmd_show_branch, RUN_SETUP },
{ "show", cmd_show, RUN_SETUP | USE_PAGER },
{ "status", cmd_status, RUN_SETUP | NEED_WORK_TREE },
--
1.7.0.195.g637a2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 06/18] grep: use RUN_SETUP_GENTLY
2010-03-07 4:55 [PATCH 00/18] Search and set up repository early for builtin commands Nguyễn Thái Ngọc Duy
` (4 preceding siblings ...)
2010-03-07 4:55 ` [PATCH 05/18] shortlog: " Nguyễn Thái Ngọc Duy
@ 2010-03-07 4:55 ` Nguyễn Thái Ngọc Duy
2010-03-07 4:55 ` [PATCH 07/18] builtin: USE_PAGER should not be used without RUN_SETUP* Nguyễn Thái Ngọc Duy
` (11 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-03-07 4:55 UTC (permalink / raw)
To: git; +Cc: Nguyễn Thái Ngọc Duy
grep has USE_PAGER set. setup_pager() may read config even
setup_git_dir* is not run yet. This tries to find a repository before
config is read.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
builtin/grep.c | 9 +++------
git.c | 2 +-
2 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/builtin/grep.c b/builtin/grep.c
index 40b9a93..fb82ff8 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -765,7 +765,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
const char **paths = NULL;
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"),
@@ -853,8 +853,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.
@@ -893,9 +891,8 @@ 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)
- /* die the same way as if we did it at the beginning */
- setup_git_directory();
+ if (use_index && !startup_info->have_repository)
+ die("No git repository found");
/*
* skip a -- separator; we know it cannot be
diff --git a/git.c b/git.c
index 29489e6..3904fe2 100644
--- a/git.c
+++ b/git.c
@@ -326,7 +326,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "fsck-objects", cmd_fsck, RUN_SETUP },
{ "gc", cmd_gc, RUN_SETUP },
{ "get-tar-commit-id", cmd_get_tar_commit_id },
- { "grep", cmd_grep, USE_PAGER },
+ { "grep", cmd_grep, RUN_SETUP_GENTLY | USE_PAGER },
{ "hash-object", cmd_hash_object, RUN_SETUP_GENTLY },
{ "help", cmd_help },
{ "index-pack", cmd_index_pack },
--
1.7.0.195.g637a2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 07/18] builtin: USE_PAGER should not be used without RUN_SETUP*
2010-03-07 4:55 [PATCH 00/18] Search and set up repository early for builtin commands Nguyễn Thái Ngọc Duy
` (5 preceding siblings ...)
2010-03-07 4:55 ` [PATCH 06/18] grep: " Nguyễn Thái Ngọc Duy
@ 2010-03-07 4:55 ` Nguyễn Thái Ngọc Duy
2010-03-07 4:55 ` [PATCH 08/18] archive: use RUN_SETUP_GENTLY Nguyễn Thái Ngọc Duy
` (10 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-03-07 4:55 UTC (permalink / raw)
To: git; +Cc: Nguyễn Thái Ngọc Duy
USE_PAGER may need core.pager from repository. So a repository search
should be done before core.pager is read.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
git.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/git.c b/git.c
index 3904fe2..84dd78e 100644
--- a/git.c
+++ b/git.c
@@ -253,8 +253,11 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
if (use_pager == -1 && p->option & RUN_SETUP)
use_pager = check_pager_config(p->cmd);
- if (use_pager == -1 && p->option & USE_PAGER)
+ if (use_pager == -1 && p->option & USE_PAGER) {
+ if ((p->option & (RUN_SETUP | RUN_SETUP_GENTLY)) == 0)
+ die("Internal error: USE_PAGER must be together with RUN_SETUP*");
use_pager = 1;
+ }
}
commit_pager_choice();
--
1.7.0.195.g637a2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 08/18] archive: use RUN_SETUP_GENTLY
2010-03-07 4:55 [PATCH 00/18] Search and set up repository early for builtin commands Nguyễn Thái Ngọc Duy
` (6 preceding siblings ...)
2010-03-07 4:55 ` [PATCH 07/18] builtin: USE_PAGER should not be used without RUN_SETUP* Nguyễn Thái Ngọc Duy
@ 2010-03-07 4:55 ` Nguyễn Thái Ngọc Duy
2010-03-07 4:55 ` [PATCH 09/18] mailinfo: " Nguyễn Thái Ngọc Duy
` (9 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-03-07 4:55 UTC (permalink / raw)
To: git; +Cc: Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
builtin/archive.c | 2 +-
git.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/builtin/archive.c b/builtin/archive.c
index 6a887f5..ef0bef8 100644
--- a/builtin/archive.c
+++ b/builtin/archive.c
@@ -125,5 +125,5 @@ int cmd_archive(int argc, const char **argv, const char *prefix)
setvbuf(stderr, NULL, _IOLBF, BUFSIZ);
- return write_archive(argc, argv, prefix, 1);
+ return write_archive(argc, argv, prefix, 0);
}
diff --git a/git.c b/git.c
index 84dd78e..2b59f06 100644
--- a/git.c
+++ b/git.c
@@ -295,7 +295,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "stage", cmd_add, RUN_SETUP | NEED_WORK_TREE },
{ "annotate", cmd_annotate, RUN_SETUP },
{ "apply", cmd_apply },
- { "archive", cmd_archive },
+ { "archive", cmd_archive, RUN_SETUP_GENTLY },
{ "bisect--helper", cmd_bisect__helper, RUN_SETUP | NEED_WORK_TREE },
{ "blame", cmd_blame, RUN_SETUP },
{ "branch", cmd_branch, RUN_SETUP },
@@ -384,7 +384,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "stripspace", cmd_stripspace },
{ "symbolic-ref", cmd_symbolic_ref, RUN_SETUP },
{ "tag", cmd_tag, RUN_SETUP },
- { "tar-tree", cmd_tar_tree },
+ { "tar-tree", cmd_tar_tree, RUN_SETUP_GENTLY },
{ "unpack-file", cmd_unpack_file, RUN_SETUP },
{ "unpack-objects", cmd_unpack_objects, RUN_SETUP },
{ "update-index", cmd_update_index, RUN_SETUP },
--
1.7.0.195.g637a2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 09/18] mailinfo: use RUN_SETUP_GENTLY
2010-03-07 4:55 [PATCH 00/18] Search and set up repository early for builtin commands Nguyễn Thái Ngọc Duy
` (7 preceding siblings ...)
2010-03-07 4:55 ` [PATCH 08/18] archive: use RUN_SETUP_GENTLY Nguyễn Thái Ngọc Duy
@ 2010-03-07 4:55 ` Nguyễn Thái Ngọc Duy
2010-03-07 4:55 ` [PATCH 10/18] check-ref-format: " Nguyễn Thái Ngọc Duy
` (8 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-03-07 4:55 UTC (permalink / raw)
To: git; +Cc: Nguyễn Thái Ngọc Duy
mailinfo may use repo config, so setup gitdir first.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
builtin/mailinfo.c | 3 ---
git.c | 2 +-
2 files changed, 1 insertions(+), 4 deletions(-)
diff --git a/builtin/mailinfo.c b/builtin/mailinfo.c
index ce2ef6b..3d2c650 100644
--- a/builtin/mailinfo.c
+++ b/builtin/mailinfo.c
@@ -1026,9 +1026,6 @@ int cmd_mailinfo(int argc, const char **argv, const char *prefix)
{
const char *def_charset;
- /* NEEDSWORK: might want to do the optional .git/ directory
- * discovery
- */
git_config(git_mailinfo_config, NULL);
def_charset = (git_commit_encoding ? git_commit_encoding : "UTF-8");
diff --git a/git.c b/git.c
index 2b59f06..326f7c7 100644
--- a/git.c
+++ b/git.c
@@ -339,7 +339,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "ls-files", cmd_ls_files, RUN_SETUP },
{ "ls-tree", cmd_ls_tree, RUN_SETUP },
{ "ls-remote", cmd_ls_remote },
- { "mailinfo", cmd_mailinfo },
+ { "mailinfo", cmd_mailinfo, RUN_SETUP_GENTLY },
{ "mailsplit", cmd_mailsplit },
{ "merge", cmd_merge, RUN_SETUP | NEED_WORK_TREE },
{ "merge-base", cmd_merge_base, RUN_SETUP },
--
1.7.0.195.g637a2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 10/18] check-ref-format: use RUN_SETUP_GENTLY
2010-03-07 4:55 [PATCH 00/18] Search and set up repository early for builtin commands Nguyễn Thái Ngọc Duy
` (8 preceding siblings ...)
2010-03-07 4:55 ` [PATCH 09/18] mailinfo: " Nguyễn Thái Ngọc Duy
@ 2010-03-07 4:55 ` Nguyễn Thái Ngọc Duy
2010-03-07 4:56 ` [PATCH 11/18] verify-pack: " Nguyễn Thái Ngọc Duy
` (7 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-03-07 4:55 UTC (permalink / raw)
To: git; +Cc: Nguyễn Thái Ngọc Duy
When --branch is used, check-ref-format will look into repository for
branch name. Therefore repository search is needed.
The call flow is:
- cmd_check_ref_format
- strbuf_check_branch_ref
- strbuf_branchname
- interpret_branch_name
- branch_get
- read_config
- resolve_ref
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
git.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/git.c b/git.c
index 326f7c7..a8660f4 100644
--- a/git.c
+++ b/git.c
@@ -304,7 +304,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "checkout", cmd_checkout, RUN_SETUP | NEED_WORK_TREE },
{ "checkout-index", cmd_checkout_index,
RUN_SETUP | NEED_WORK_TREE},
- { "check-ref-format", cmd_check_ref_format },
+ { "check-ref-format", cmd_check_ref_format, RUN_SETUP_GENTLY },
{ "check-attr", cmd_check_attr, RUN_SETUP },
{ "cherry", cmd_cherry, RUN_SETUP },
{ "cherry-pick", cmd_cherry_pick, RUN_SETUP | NEED_WORK_TREE },
--
1.7.0.195.g637a2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 11/18] verify-pack: use RUN_SETUP_GENTLY
2010-03-07 4:55 [PATCH 00/18] Search and set up repository early for builtin commands Nguyễn Thái Ngọc Duy
` (9 preceding siblings ...)
2010-03-07 4:55 ` [PATCH 10/18] check-ref-format: " Nguyễn Thái Ngọc Duy
@ 2010-03-07 4:56 ` Nguyễn Thái Ngọc Duy
2010-03-07 4:56 ` [PATCH 12/18] apply: " Nguyễn Thái Ngọc Duy
` (6 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-03-07 4:56 UTC (permalink / raw)
To: git; +Cc: Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
git.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/git.c b/git.c
index a8660f4..0e052c8 100644
--- a/git.c
+++ b/git.c
@@ -396,7 +396,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "version", cmd_version },
{ "whatchanged", cmd_whatchanged, RUN_SETUP | USE_PAGER },
{ "write-tree", cmd_write_tree, RUN_SETUP },
- { "verify-pack", cmd_verify_pack },
+ { "verify-pack", cmd_verify_pack, RUN_SETUP_GENTLY },
{ "show-ref", cmd_show_ref, RUN_SETUP },
{ "pack-refs", cmd_pack_refs, RUN_SETUP },
};
--
1.7.0.195.g637a2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 12/18] apply: use RUN_SETUP_GENTLY
2010-03-07 4:55 [PATCH 00/18] Search and set up repository early for builtin commands Nguyễn Thái Ngọc Duy
` (10 preceding siblings ...)
2010-03-07 4:56 ` [PATCH 11/18] verify-pack: " Nguyễn Thái Ngọc Duy
@ 2010-03-07 4:56 ` Nguyễn Thái Ngọc Duy
2010-03-07 4:56 ` [PATCH 13/18] bundle: " Nguyễn Thái Ngọc Duy
` (5 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-03-07 4:56 UTC (permalink / raw)
To: git; +Cc: Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
builtin/apply.c | 7 +++----
git.c | 2 +-
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/builtin/apply.c b/builtin/apply.c
index 3af4ae0..d27aac6 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -3516,7 +3516,6 @@ int cmd_apply(int argc, const char **argv, const char *unused_prefix)
{
int i;
int errs = 0;
- int is_not_gitdir;
int binary;
int force_apply = 0;
@@ -3589,7 +3588,7 @@ int cmd_apply(int argc, const char **argv, const char *unused_prefix)
OPT_END()
};
- prefix = setup_git_directory_gently(&is_not_gitdir);
+ prefix = startup_info->prefix;
prefix_length = prefix ? strlen(prefix) : 0;
git_config(git_apply_config, NULL);
if (apply_default_whitespace)
@@ -3604,10 +3603,10 @@ int cmd_apply(int argc, const char **argv, const char *unused_prefix)
apply = apply_verbosely = 1;
if (!force_apply && (diffstat || numstat || summary || check || fake_ancestor))
apply = 0;
- if (check_index && is_not_gitdir)
+ if (check_index && !startup_info->have_repository)
die("--index outside a repository");
if (cached) {
- if (is_not_gitdir)
+ if (!startup_info->have_repository)
die("--cached outside a repository");
check_index = 1;
}
diff --git a/git.c b/git.c
index 0e052c8..7820d22 100644
--- a/git.c
+++ b/git.c
@@ -294,7 +294,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "add", cmd_add, RUN_SETUP | NEED_WORK_TREE },
{ "stage", cmd_add, RUN_SETUP | NEED_WORK_TREE },
{ "annotate", cmd_annotate, RUN_SETUP },
- { "apply", cmd_apply },
+ { "apply", cmd_apply, RUN_SETUP_GENTLY },
{ "archive", cmd_archive, RUN_SETUP_GENTLY },
{ "bisect--helper", cmd_bisect__helper, RUN_SETUP | NEED_WORK_TREE },
{ "blame", cmd_blame, RUN_SETUP },
--
1.7.0.195.g637a2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 13/18] bundle: use RUN_SETUP_GENTLY
2010-03-07 4:55 [PATCH 00/18] Search and set up repository early for builtin commands Nguyễn Thái Ngọc Duy
` (11 preceding siblings ...)
2010-03-07 4:56 ` [PATCH 12/18] apply: " Nguyễn Thái Ngọc Duy
@ 2010-03-07 4:56 ` Nguyễn Thái Ngọc Duy
2010-03-07 4:56 ` [PATCH 14/18] diff: " Nguyễn Thái Ngọc Duy
` (4 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-03-07 4:56 UTC (permalink / raw)
To: git; +Cc: Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
builtin/bundle.c | 6 ++----
git.c | 2 +-
2 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/builtin/bundle.c b/builtin/bundle.c
index 2006cc5..80649ba 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/git.c b/git.c
index 7820d22..a90e0c3 100644
--- a/git.c
+++ b/git.c
@@ -299,7 +299,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "bisect--helper", cmd_bisect__helper, RUN_SETUP | NEED_WORK_TREE },
{ "blame", cmd_blame, RUN_SETUP },
{ "branch", cmd_branch, RUN_SETUP },
- { "bundle", cmd_bundle },
+ { "bundle", cmd_bundle, RUN_SETUP_GENTLY },
{ "cat-file", cmd_cat_file, RUN_SETUP },
{ "checkout", cmd_checkout, RUN_SETUP | NEED_WORK_TREE },
{ "checkout-index", cmd_checkout_index,
--
1.7.0.195.g637a2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 14/18] diff: use RUN_SETUP_GENTLY
2010-03-07 4:55 [PATCH 00/18] Search and set up repository early for builtin commands Nguyễn Thái Ngọc Duy
` (12 preceding siblings ...)
2010-03-07 4:56 ` [PATCH 13/18] bundle: " Nguyễn Thái Ngọc Duy
@ 2010-03-07 4:56 ` Nguyễn Thái Ngọc Duy
2010-03-07 4:56 ` [PATCH 15/18] help: " Nguyễn Thái Ngọc Duy
` (3 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-03-07 4:56 UTC (permalink / raw)
To: git; +Cc: Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
builtin/diff.c | 6 ++----
git.c | 2 +-
2 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/builtin/diff.c b/builtin/diff.c
index ffcdd05..e4bd855 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -252,7 +252,6 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
int ents = 0, blobs = 0, paths = 0;
const char *path = NULL;
struct blobinfo blob[2];
- int nongit;
int result = 0;
/*
@@ -278,7 +277,6 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
* Other cases are errors.
*/
- prefix = setup_git_directory_gently(&nongit);
git_config(git_diff_ui_config, NULL);
if (diff_use_color_default == -1)
@@ -287,7 +285,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
init_revisions(&rev, prefix);
/* If this is a no-index diff, just run it and exit there. */
- diff_no_index(&rev, argc, argv, nongit, prefix);
+ diff_no_index(&rev, argc, argv, !startup_info->have_repository, prefix);
/* Otherwise, we are doing the usual "git" diff */
rev.diffopt.skip_stat_unmatch = !!diff_auto_refresh_index;
@@ -296,7 +294,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
DIFF_OPT_SET(&rev.diffopt, ALLOW_EXTERNAL);
DIFF_OPT_SET(&rev.diffopt, ALLOW_TEXTCONV);
- if (nongit)
+ if (!startup_info->have_repository)
die("Not a git repository");
argc = setup_revisions(argc, argv, &rev, NULL);
if (!rev.diffopt.output_format) {
diff --git a/git.c b/git.c
index a90e0c3..02ba3b2 100644
--- a/git.c
+++ b/git.c
@@ -315,7 +315,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "config", cmd_config, RUN_SETUP_GENTLY },
{ "count-objects", cmd_count_objects, RUN_SETUP },
{ "describe", cmd_describe, RUN_SETUP },
- { "diff", cmd_diff },
+ { "diff", cmd_diff, RUN_SETUP_GENTLY },
{ "diff-files", cmd_diff_files, RUN_SETUP | NEED_WORK_TREE },
{ "diff-index", cmd_diff_index, RUN_SETUP },
{ "diff-tree", cmd_diff_tree, RUN_SETUP },
--
1.7.0.195.g637a2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 15/18] help: use RUN_SETUP_GENTLY
2010-03-07 4:55 [PATCH 00/18] Search and set up repository early for builtin commands Nguyễn Thái Ngọc Duy
` (13 preceding siblings ...)
2010-03-07 4:56 ` [PATCH 14/18] diff: " Nguyễn Thái Ngọc Duy
@ 2010-03-07 4:56 ` Nguyễn Thái Ngọc Duy
2010-03-07 4:56 ` [PATCH 16/18] ls-remote: " Nguyễn Thái Ngọc Duy
` (2 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-03-07 4:56 UTC (permalink / raw)
To: git; +Cc: Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
builtin/help.c | 2 --
git.c | 2 +-
2 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/builtin/help.c b/builtin/help.c
index 3182a2b..4988629 100644
--- a/builtin/help.c
+++ b/builtin/help.c
@@ -414,7 +414,6 @@ static void show_html_page(const char *git_cmd)
int cmd_help(int argc, const char **argv, const char *prefix)
{
- int nongit;
const char *alias;
enum help_format parsed_help_format;
load_command_list("git-", &main_cmds, &other_cmds);
@@ -437,7 +436,6 @@ int cmd_help(int argc, const char **argv, const char *prefix)
return 0;
}
- setup_git_directory_gently(&nongit);
git_config(git_help_config, NULL);
if (parsed_help_format != HELP_FORMAT_NONE)
diff --git a/git.c b/git.c
index 02ba3b2..6a29756 100644
--- a/git.c
+++ b/git.c
@@ -331,7 +331,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "get-tar-commit-id", cmd_get_tar_commit_id },
{ "grep", cmd_grep, RUN_SETUP_GENTLY | USE_PAGER },
{ "hash-object", cmd_hash_object, RUN_SETUP_GENTLY },
- { "help", cmd_help },
+ { "help", cmd_help, RUN_SETUP_GENTLY },
{ "index-pack", cmd_index_pack },
{ "init", cmd_init_db },
{ "init-db", cmd_init_db },
--
1.7.0.195.g637a2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 16/18] ls-remote: use RUN_SETUP_GENTLY
2010-03-07 4:55 [PATCH 00/18] Search and set up repository early for builtin commands Nguyễn Thái Ngọc Duy
` (14 preceding siblings ...)
2010-03-07 4:56 ` [PATCH 15/18] help: " Nguyễn Thái Ngọc Duy
@ 2010-03-07 4:56 ` Nguyễn Thái Ngọc Duy
2010-03-07 4:56 ` [PATCH 17/18] var: " Nguyễn Thái Ngọc Duy
2010-03-07 4:56 ` [PATCH 18/18] merge-file: " Nguyễn Thái Ngọc Duy
17 siblings, 0 replies; 19+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-03-07 4:56 UTC (permalink / raw)
To: git; +Cc: Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
builtin/ls-remote.c | 3 ---
git.c | 4 ++--
2 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/builtin/ls-remote.c b/builtin/ls-remote.c
index 70f5622..998f2c8 100644
--- a/builtin/ls-remote.c
+++ b/builtin/ls-remote.c
@@ -31,7 +31,6 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
{
int i;
const char *dest = NULL;
- int nongit;
unsigned flags = 0;
const char *uploadpack = NULL;
const char **pattern = NULL;
@@ -40,8 +39,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/git.c b/git.c
index 6a29756..e0c8904 100644
--- a/git.c
+++ b/git.c
@@ -338,7 +338,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "log", cmd_log, RUN_SETUP | USE_PAGER },
{ "ls-files", cmd_ls_files, RUN_SETUP },
{ "ls-tree", cmd_ls_tree, RUN_SETUP },
- { "ls-remote", cmd_ls_remote },
+ { "ls-remote", cmd_ls_remote, RUN_SETUP_GENTLY },
{ "mailinfo", cmd_mailinfo, RUN_SETUP_GENTLY },
{ "mailsplit", cmd_mailsplit },
{ "merge", cmd_merge, RUN_SETUP | NEED_WORK_TREE },
@@ -359,7 +359,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "pack-objects", cmd_pack_objects, RUN_SETUP },
{ "pack-redundant", cmd_pack_redundant, RUN_SETUP },
{ "patch-id", cmd_patch_id },
- { "peek-remote", cmd_ls_remote },
+ { "peek-remote", cmd_ls_remote, RUN_SETUP_GENTLY },
{ "pickaxe", cmd_blame, RUN_SETUP },
{ "prune", cmd_prune, RUN_SETUP },
{ "prune-packed", cmd_prune_packed, RUN_SETUP },
--
1.7.0.195.g637a2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 17/18] var: use RUN_SETUP_GENTLY
2010-03-07 4:55 [PATCH 00/18] Search and set up repository early for builtin commands Nguyễn Thái Ngọc Duy
` (15 preceding siblings ...)
2010-03-07 4:56 ` [PATCH 16/18] ls-remote: " Nguyễn Thái Ngọc Duy
@ 2010-03-07 4:56 ` Nguyễn Thái Ngọc Duy
2010-03-07 4:56 ` [PATCH 18/18] merge-file: " Nguyễn Thái Ngọc Duy
17 siblings, 0 replies; 19+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-03-07 4:56 UTC (permalink / raw)
To: git; +Cc: Nguyễn Thái Ngọc Duy
"git var" needs to read repository config, so setup gitdir first.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
builtin/var.c | 2 --
git.c | 2 +-
2 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/builtin/var.c b/builtin/var.c
index 70fdb4d..26324ef 100644
--- a/builtin/var.c
+++ b/builtin/var.c
@@ -75,12 +75,10 @@ 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) {
usage(var_usage);
}
- setup_git_directory_gently(&nongit);
val = NULL;
if (strcmp(argv[1], "-l") == 0) {
diff --git a/git.c b/git.c
index e0c8904..3292627 100644
--- a/git.c
+++ b/git.c
@@ -391,7 +391,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "update-ref", cmd_update_ref, RUN_SETUP },
{ "update-server-info", cmd_update_server_info, RUN_SETUP },
{ "upload-archive", cmd_upload_archive },
- { "var", cmd_var },
+ { "var", cmd_var, RUN_SETUP_GENTLY },
{ "verify-tag", cmd_verify_tag, RUN_SETUP },
{ "version", cmd_version },
{ "whatchanged", cmd_whatchanged, RUN_SETUP | USE_PAGER },
--
1.7.0.195.g637a2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 18/18] merge-file: use RUN_SETUP_GENTLY
2010-03-07 4:55 [PATCH 00/18] Search and set up repository early for builtin commands Nguyễn Thái Ngọc Duy
` (16 preceding siblings ...)
2010-03-07 4:56 ` [PATCH 17/18] var: " Nguyễn Thái Ngọc Duy
@ 2010-03-07 4:56 ` Nguyễn Thái Ngọc Duy
17 siblings, 0 replies; 19+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-03-07 4:56 UTC (permalink / raw)
To: git; +Cc: Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
builtin/merge-file.c | 4 +---
git.c | 2 +-
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/builtin/merge-file.c b/builtin/merge-file.c
index 1e70073..474c6c2 100644
--- a/builtin/merge-file.c
+++ b/builtin/merge-file.c
@@ -30,7 +30,6 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
int level = XDL_MERGE_ZEALOUS_ALNUM;
int style = 0, quiet = 0;
int favor = 0;
- int nongit;
struct option options[] = {
OPT_BOOLEAN('p', "stdout", &to_stdout, "send results to standard output"),
@@ -45,8 +44,7 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
OPT_END(),
};
- 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/git.c b/git.c
index 3292627..88408c8 100644
--- a/git.c
+++ b/git.c
@@ -343,7 +343,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "mailsplit", cmd_mailsplit },
{ "merge", cmd_merge, RUN_SETUP | NEED_WORK_TREE },
{ "merge-base", cmd_merge_base, RUN_SETUP },
- { "merge-file", cmd_merge_file },
+ { "merge-file", cmd_merge_file, RUN_SETUP_GENTLY },
{ "merge-index", cmd_merge_index, RUN_SETUP },
{ "merge-ours", cmd_merge_ours, RUN_SETUP },
{ "merge-recursive", cmd_merge_recursive, RUN_SETUP | NEED_WORK_TREE },
--
1.7.0.195.g637a2
^ permalink raw reply related [flat|nested] 19+ messages in thread
end of thread, other threads:[~2010-03-07 5:07 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-07 4:55 [PATCH 00/18] Search and set up repository early for builtin commands Nguyễn Thái Ngọc Duy
2010-03-07 4:55 ` [PATCH 01/18] builtin: introduce startup_info struct Nguyễn Thái Ngọc Duy
2010-03-07 4:55 ` [PATCH 02/18] builtin: Support RUN_SETUP_GENTLY to set up repository early if found Nguyễn Thái Ngọc Duy
2010-03-07 4:55 ` [PATCH 03/18] config: use RUN_SETUP_GENTLY Nguyễn Thái Ngọc Duy
2010-03-07 4:55 ` [PATCH 04/18] hash-object: " Nguyễn Thái Ngọc Duy
2010-03-07 4:55 ` [PATCH 05/18] shortlog: " Nguyễn Thái Ngọc Duy
2010-03-07 4:55 ` [PATCH 06/18] grep: " Nguyễn Thái Ngọc Duy
2010-03-07 4:55 ` [PATCH 07/18] builtin: USE_PAGER should not be used without RUN_SETUP* Nguyễn Thái Ngọc Duy
2010-03-07 4:55 ` [PATCH 08/18] archive: use RUN_SETUP_GENTLY Nguyễn Thái Ngọc Duy
2010-03-07 4:55 ` [PATCH 09/18] mailinfo: " Nguyễn Thái Ngọc Duy
2010-03-07 4:55 ` [PATCH 10/18] check-ref-format: " Nguyễn Thái Ngọc Duy
2010-03-07 4:56 ` [PATCH 11/18] verify-pack: " Nguyễn Thái Ngọc Duy
2010-03-07 4:56 ` [PATCH 12/18] apply: " Nguyễn Thái Ngọc Duy
2010-03-07 4:56 ` [PATCH 13/18] bundle: " Nguyễn Thái Ngọc Duy
2010-03-07 4:56 ` [PATCH 14/18] diff: " Nguyễn Thái Ngọc Duy
2010-03-07 4:56 ` [PATCH 15/18] help: " Nguyễn Thái Ngọc Duy
2010-03-07 4:56 ` [PATCH 16/18] ls-remote: " Nguyễn Thái Ngọc Duy
2010-03-07 4:56 ` [PATCH 17/18] var: " Nguyễn Thái Ngọc Duy
2010-03-07 4:56 ` [PATCH 18/18] merge-file: " Nguyễn Thái Ngọc Duy
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.