{"thread":{"id":"22936","subject":"[PATCH 01/18] builtin: introduce startup_info struct","startedAt":"2010-03-07T04:55:49Z","lastAt":"2010-03-07T04:56:07Z","messageCount":19,"participants":["Nguyễn Thái Ngọc Duy"],"isPatch":true,"patchVersion":1,"patchTotal":18},"messages":[{"id":"136289","messageId":"1267937767-12504-1-git-send-email-pclouds@gmail.com","threadId":"22936","inReplyTo":null,"subject":"[PATCH 00/18] Search and set up repository early for builtin commands","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-03-07T04:55:49Z","receivedAt":"2010-03-07T04:55:49Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"This is a simpler part of my Git setup cleanup WIP [1], to introduce\nRUN_SETUP_GENTLY and make most of commands use it.\n\nThe commands that do not have RUN_SETUP* are:\n - Init/Clone commands\n - Server commands\n - Helpers that have nothing to do with repositories\n - git-rev-parse\n\n[1] http://mid.gmane.org/1266336317-607-1-git-send-email-pclouds@gmail.com\n\nNguyễn Thái Ngọc Duy (18):\n  builtin: introduce startup_info struct\n  builtin: Support RUN_SETUP_GENTLY to set up repository early if found\n  config: use RUN_SETUP_GENTLY\n  hash-object: use RUN_SETUP_GENTLY\n  shortlog: use RUN_SETUP_GENTLY\n  grep: use RUN_SETUP_GENTLY\n  builtin: USE_PAGER should not be used without RUN_SETUP*\n  archive: use RUN_SETUP_GENTLY\n  mailinfo: use RUN_SETUP_GENTLY\n  check-ref-format: use RUN_SETUP_GENTLY\n  verify-pack: use RUN_SETUP_GENTLY\n  apply: use RUN_SETUP_GENTLY\n  bundle: use RUN_SETUP_GENTLY\n  diff: use RUN_SETUP_GENTLY\n  help: use RUN_SETUP_GENTLY\n  ls-remote: use RUN_SETUP_GENTLY\n  var: use RUN_SETUP_GENTLY\n  merge-file: use RUN_SETUP_GENTLY\n\n builtin/apply.c       |    7 ++---\n builtin/archive.c     |    2 +-\n builtin/bundle.c      |    6 +---\n builtin/config.c      |    6 +---\n builtin/diff.c        |    6 +---\n builtin/grep.c        |    9 ++-----\n builtin/hash-object.c |    9 ++++---\n builtin/help.c        |    2 -\n builtin/ls-remote.c   |    3 --\n builtin/mailinfo.c    |    3 --\n builtin/merge-file.c  |    4 +--\n builtin/shortlog.c    |    4 +--\n builtin/var.c         |    2 -\n cache.h               |    7 +++++\n environment.c         |    1 +\n git.c                 |   61 ++++++++++++++++++++++++++++---------------------\n setup.c               |   14 ++++++++++-\n 17 files changed, 76 insertions(+), 70 deletions(-)\n"},{"id":"136271","messageId":"1267937767-12504-2-git-send-email-pclouds@gmail.com","threadId":"22936","inReplyTo":"1267937767-12504-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 01/18] builtin: introduce startup_info struct","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-03-07T04:55:50Z","receivedAt":"2010-03-07T04:55:50Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The purpose of this struct is to make it easier to extend parameters\npassed to builtin commands from run_builtin(), and let libgit aware of\nsome global states in future.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n cache.h       |    6 ++++++\n environment.c |    1 +\n git.c         |    9 +++++----\n setup.c       |   12 +++++++++++-\n 4 files changed, 23 insertions(+), 5 deletions(-)\n\ndiff --git a/cache.h b/cache.h\nindex 89f6a40..30fddf1 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1054,4 +1054,10 @@ void overlay_tree_on_cache(const char *tree_name, const char *prefix);\n char *alias_lookup(const char *alias);\n int split_cmdline(char *cmdline, const char ***argv);\n \n+/* git.c */\n+struct startup_info {\n+\tconst char *prefix;\n+};\n+extern struct startup_info *startup_info;\n+\n #endif /* CACHE_H */\ndiff --git a/environment.c b/environment.c\nindex 876c5e5..c36c902 100644\n--- a/environment.c\n+++ b/environment.c\n@@ -52,6 +52,7 @@ enum object_creation_mode object_creation_mode = OBJECT_CREATION_MODE;\n char *notes_ref_name;\n int grafts_replace_parents = 1;\n int core_apply_sparse_checkout;\n+struct startup_info *startup_info;\n \n /* Parallel index stat data preload? */\n int core_preload_index = 0;\ndiff --git a/git.c b/git.c\nindex 6bae305..4be34e4 100644\n--- a/git.c\n+++ b/git.c\n@@ -13,6 +13,7 @@ const char git_usage_string[] =\n const char git_more_info_string[] =\n \t\"See 'git help COMMAND' for more information on a specific command.\";\n \n+static struct startup_info git_startup_info;\n static int use_pager = -1;\n struct pager_config {\n \tconst char *cmd;\n@@ -237,13 +238,13 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)\n {\n \tint status, help;\n \tstruct stat st;\n-\tconst char *prefix;\n \n-\tprefix = NULL;\n+\tmemset(&git_startup_info, 0, sizeof(git_startup_info));\n+\tstartup_info = &git_startup_info;\n \thelp = argc == 2 && !strcmp(argv[1], \"-h\");\n \tif (!help) {\n \t\tif (p->option & RUN_SETUP)\n-\t\t\tprefix = setup_git_directory();\n+\t\t\tsetup_git_directory();\n \n \t\tif (use_pager == -1 && p->option & RUN_SETUP)\n \t\t\tuse_pager = check_pager_config(p->cmd);\n@@ -257,7 +258,7 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)\n \n \ttrace_argv_printf(argv, \"trace: built-in: git\");\n \n-\tstatus = p->fn(argc, argv, prefix);\n+\tstatus = p->fn(argc, argv, startup_info->prefix);\n \tif (status)\n \t\treturn status;\n \ndiff --git a/setup.c b/setup.c\nindex 5716d90..cf1b37d 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -315,7 +315,7 @@ const char *read_gitfile_gently(const char *path)\n  * We cannot decide in this function whether we are in the work tree or\n  * not, since the config can only be read _after_ this function was called.\n  */\n-const char *setup_git_directory_gently(int *nongit_ok)\n+static const char *setup_git_directory_gently_1(int *nongit_ok)\n {\n \tconst char *work_tree_env = getenv(GIT_WORK_TREE_ENVIRONMENT);\n \tconst char *env_ceiling_dirs = getenv(CEILING_DIRECTORIES_ENVIRONMENT);\n@@ -443,6 +443,16 @@ const char *setup_git_directory_gently(int *nongit_ok)\n \treturn cwd + offset;\n }\n \n+const char *setup_git_directory_gently(int *nongit_ok)\n+{\n+\tconst char *prefix;\n+\n+\tprefix = setup_git_directory_gently_1(nongit_ok);\n+\tif (startup_info)\n+\t\tstartup_info->prefix = prefix;\n+\treturn prefix;\n+}\n+\n int git_config_perm(const char *var, const char *value)\n {\n \tint i;\n-- \n1.7.0.195.g637a2\n"},{"id":"136290","messageId":"1267937767-12504-3-git-send-email-pclouds@gmail.com","threadId":"22936","inReplyTo":"1267937767-12504-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 02/18] builtin: Support RUN_SETUP_GENTLY to set up repository early if found","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-03-07T04:55:51Z","receivedAt":"2010-03-07T04:55:51Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Attempts to access gitdir are everywhere, even before cmd_*() is\ncalled. Because repository has not been found, repository-specific\ninformation (i.e. $GIT_DIR/config) may not be read. This leads to\nobscure bugs.\n\nSo the sooner we setup gitdir, the less trouble we may have to deal with.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n cache.h |    1 +\n git.c   |   11 ++++++++---\n setup.c |    4 +++-\n 3 files changed, 12 insertions(+), 4 deletions(-)\n\ndiff --git a/cache.h b/cache.h\nindex 30fddf1..68412c0 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1057,6 +1057,7 @@ int split_cmdline(char *cmdline, const char ***argv);\n /* git.c */\n struct startup_info {\n \tconst char *prefix;\n+\tint have_repository;\n };\n extern struct startup_info *startup_info;\n \ndiff --git a/git.c b/git.c\nindex 4be34e4..9e0e2d0 100644\n--- a/git.c\n+++ b/git.c\n@@ -220,13 +220,14 @@ static int handle_alias(int *argcp, const char ***argv)\n \n const char git_version_string[] = GIT_VERSION;\n \n-#define RUN_SETUP\t(1<<0)\n-#define USE_PAGER\t(1<<1)\n+#define RUN_SETUP\t\t(1<<0)\n+#define USE_PAGER\t\t(1<<1)\n /*\n  * require working tree to be present -- anything uses this needs\n  * RUN_SETUP for reading from the configuration file.\n  */\n-#define NEED_WORK_TREE\t(1<<2)\n+#define NEED_WORK_TREE\t\t(1<<2)\n+#define RUN_SETUP_GENTLY\t(1<<3)\n \n struct cmd_struct {\n \tconst char *cmd;\n@@ -245,6 +246,10 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)\n \tif (!help) {\n \t\tif (p->option & RUN_SETUP)\n \t\t\tsetup_git_directory();\n+\t\tif (p->option & RUN_SETUP_GENTLY) {\n+\t\t\tint nongit_ok;\n+\t\t\tsetup_git_directory_gently(&nongit_ok);\n+\t\t}\n \n \t\tif (use_pager == -1 && p->option & RUN_SETUP)\n \t\t\tuse_pager = check_pager_config(p->cmd);\ndiff --git a/setup.c b/setup.c\nindex cf1b37d..bb3648c 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -448,8 +448,10 @@ const char *setup_git_directory_gently(int *nongit_ok)\n \tconst char *prefix;\n \n \tprefix = setup_git_directory_gently_1(nongit_ok);\n-\tif (startup_info)\n+\tif (startup_info) {\n \t\tstartup_info->prefix = prefix;\n+\t\tstartup_info->have_repository = !nongit_ok || !*nongit_ok;\n+\t}\n \treturn prefix;\n }\n \n-- \n1.7.0.195.g637a2\n"},{"id":"136272","messageId":"1267937767-12504-4-git-send-email-pclouds@gmail.com","threadId":"22936","inReplyTo":"1267937767-12504-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 03/18] config: use RUN_SETUP_GENTLY","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-03-07T04:55:52Z","receivedAt":"2010-03-07T04:55:52Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/config.c |    6 ++----\n git.c            |    4 ++--\n 2 files changed, 4 insertions(+), 6 deletions(-)\n\ndiff --git a/builtin/config.c b/builtin/config.c\nindex 4bc46b1..ecc8f87 100644\n--- a/builtin/config.c\n+++ b/builtin/config.c\n@@ -326,11 +326,9 @@ static int get_colorbool(int print)\n \t\treturn get_colorbool_found ? 0 : 1;\n }\n \n-int cmd_config(int argc, const char **argv, const char *unused_prefix)\n+int cmd_config(int argc, const char **argv, const char *prefix)\n {\n-\tint nongit;\n \tchar *value;\n-\tconst char *prefix = setup_git_directory_gently(&nongit);\n \n \tconfig_exclusive_filename = getenv(CONFIG_ENVIRONMENT);\n \n@@ -409,7 +407,7 @@ int cmd_config(int argc, const char **argv, const char *unused_prefix)\n \t}\n \telse if (actions == ACTION_EDIT) {\n \t\tcheck_argc(argc, 0, 0);\n-\t\tif (!config_exclusive_filename && nongit)\n+\t\tif (!config_exclusive_filename && !startup_info->have_repository)\n \t\t\tdie(\"not in a git directory\");\n \t\tgit_config(git_default_config, NULL);\n \t\tlaunch_editor(config_exclusive_filename ?\ndiff --git a/git.c b/git.c\nindex 9e0e2d0..4c99319 100644\n--- a/git.c\n+++ b/git.c\n@@ -309,7 +309,7 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"clean\", cmd_clean, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"commit\", cmd_commit, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"commit-tree\", cmd_commit_tree, RUN_SETUP },\n-\t\t{ \"config\", cmd_config },\n+\t\t{ \"config\", cmd_config, RUN_SETUP_GENTLY },\n \t\t{ \"count-objects\", cmd_count_objects, RUN_SETUP },\n \t\t{ \"describe\", cmd_describe, RUN_SETUP },\n \t\t{ \"diff\", cmd_diff },\n@@ -366,7 +366,7 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"reflog\", cmd_reflog, RUN_SETUP },\n \t\t{ \"remote\", cmd_remote, RUN_SETUP },\n \t\t{ \"replace\", cmd_replace, RUN_SETUP },\n-\t\t{ \"repo-config\", cmd_config },\n+\t\t{ \"repo-config\", cmd_config, RUN_SETUP_GENTLY },\n \t\t{ \"rerere\", cmd_rerere, RUN_SETUP },\n \t\t{ \"reset\", cmd_reset, RUN_SETUP },\n \t\t{ \"rev-list\", cmd_rev_list, RUN_SETUP },\n-- \n1.7.0.195.g637a2\n"},{"id":"136273","messageId":"1267937767-12504-5-git-send-email-pclouds@gmail.com","threadId":"22936","inReplyTo":"1267937767-12504-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 04/18] hash-object: use RUN_SETUP_GENTLY","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-03-07T04:55:53Z","receivedAt":"2010-03-07T04:55:53Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"hash-object needs to inspect repository's config, so it must try to\nfind a repository regardless the object will be written in object\nstore.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/hash-object.c |    9 +++++----\n git.c                 |    2 +-\n 2 files changed, 6 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/hash-object.c b/builtin/hash-object.c\nindex 6a5f5b5..57330b8 100644\n--- a/builtin/hash-object.c\n+++ b/builtin/hash-object.c\n@@ -76,7 +76,7 @@ static const struct option hash_object_options[] = {\n int cmd_hash_object(int argc, const char **argv, const char *prefix)\n {\n \tint i;\n-\tint prefix_length = -1;\n+\tint prefix_length;\n \tconst char *errstr = NULL;\n \n \ttype = blob_type;\n@@ -84,9 +84,10 @@ int cmd_hash_object(int argc, const char **argv, const char *prefix)\n \targc = parse_options(argc, argv, NULL, hash_object_options,\n \t\t\t     hash_object_usage, 0);\n \n+\tprefix_length = prefix ? strlen(prefix) : 0;\n \tif (write_object) {\n-\t\tprefix = setup_git_directory();\n-\t\tprefix_length = prefix ? strlen(prefix) : 0;\n+\t\tif (!startup_info->have_repository)\n+\t\t\tdie(\"No repository found\");\n \t\tif (vpath && prefix)\n \t\t\tvpath = prefix_filename(prefix, prefix_length, vpath);\n \t}\n@@ -121,7 +122,7 @@ int cmd_hash_object(int argc, const char **argv, const char *prefix)\n \tfor (i = 0 ; i < argc; i++) {\n \t\tconst char *arg = argv[i];\n \n-\t\tif (0 <= prefix_length)\n+\t\tif (prefix_length)\n \t\t\targ = prefix_filename(prefix, prefix_length, arg);\n \t\thash_object(arg, type, write_object,\n \t\t\t    no_filters ? NULL : vpath ? vpath : arg);\ndiff --git a/git.c b/git.c\nindex 4c99319..2069ef3 100644\n--- a/git.c\n+++ b/git.c\n@@ -327,7 +327,7 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"gc\", cmd_gc, RUN_SETUP },\n \t\t{ \"get-tar-commit-id\", cmd_get_tar_commit_id },\n \t\t{ \"grep\", cmd_grep, USE_PAGER },\n-\t\t{ \"hash-object\", cmd_hash_object },\n+\t\t{ \"hash-object\", cmd_hash_object, RUN_SETUP_GENTLY },\n \t\t{ \"help\", cmd_help },\n \t\t{ \"index-pack\", cmd_index_pack },\n \t\t{ \"init\", cmd_init_db },\n-- \n1.7.0.195.g637a2\n"},{"id":"136274","messageId":"1267937767-12504-6-git-send-email-pclouds@gmail.com","threadId":"22936","inReplyTo":"1267937767-12504-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 05/18] shortlog: use RUN_SETUP_GENTLY","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-03-07T04:55:54Z","receivedAt":"2010-03-07T04:55:54Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"shortlog has USE_PAGER set. setup_pager() may read config even\nsetup_git_dir* is not run yet. This tries to find a repository before\nthe config is read.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/shortlog.c |    4 +---\n git.c              |    2 +-\n 2 files changed, 2 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/shortlog.c b/builtin/shortlog.c\nindex 06320f5..bdf3402 100644\n--- a/builtin/shortlog.c\n+++ b/builtin/shortlog.c\n@@ -249,7 +249,6 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix)\n {\n \tstatic struct shortlog log;\n \tstatic struct rev_info rev;\n-\tint nongit;\n \n \tstatic const struct option options[] = {\n \t\tOPT_BOOLEAN('n', \"numbered\", &log.sort_by_number,\n@@ -265,7 +264,6 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix)\n \n \tstruct parse_opt_ctx_t ctx;\n \n-\tprefix = setup_git_directory_gently(&nongit);\n \tgit_config(git_default_config, NULL);\n \tshortlog_init(&log);\n \tinit_revisions(&rev, prefix);\n@@ -292,7 +290,7 @@ parse_done:\n \tlog.user_format = rev.commit_format == CMIT_FMT_USERFORMAT;\n \n \t/* assume HEAD if from a tty */\n-\tif (!nongit && !rev.pending.nr && isatty(0))\n+\tif (startup_info->have_repository && !rev.pending.nr && isatty(0))\n \t\tadd_head_to_pending(&rev);\n \tif (rev.pending.nr == 0) {\n \t\tif (isatty(0))\ndiff --git a/git.c b/git.c\nindex 2069ef3..29489e6 100644\n--- a/git.c\n+++ b/git.c\n@@ -374,7 +374,7 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"revert\", cmd_revert, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"rm\", cmd_rm, RUN_SETUP },\n \t\t{ \"send-pack\", cmd_send_pack, RUN_SETUP },\n-\t\t{ \"shortlog\", cmd_shortlog, USE_PAGER },\n+\t\t{ \"shortlog\", cmd_shortlog, RUN_SETUP_GENTLY | USE_PAGER },\n \t\t{ \"show-branch\", cmd_show_branch, RUN_SETUP },\n \t\t{ \"show\", cmd_show, RUN_SETUP | USE_PAGER },\n \t\t{ \"status\", cmd_status, RUN_SETUP | NEED_WORK_TREE },\n-- \n1.7.0.195.g637a2\n"},{"id":"136275","messageId":"1267937767-12504-7-git-send-email-pclouds@gmail.com","threadId":"22936","inReplyTo":"1267937767-12504-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 06/18] grep: use RUN_SETUP_GENTLY","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-03-07T04:55:55Z","receivedAt":"2010-03-07T04:55:55Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"grep has USE_PAGER set. setup_pager() may read config even\nsetup_git_dir* is not run yet. This tries to find a repository before\nconfig is read.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/grep.c |    9 +++------\n git.c          |    2 +-\n 2 files changed, 4 insertions(+), 7 deletions(-)\n\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 40b9a93..fb82ff8 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -765,7 +765,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)\n \tconst char **paths = NULL;\n \tint i;\n \tint dummy;\n-\tint nongit = 0, use_index = 1;\n+\tint use_index = 1;\n \tstruct option options[] = {\n \t\tOPT_BOOLEAN(0, \"cached\", &cached,\n \t\t\t\"search in index instead of in the work tree\"),\n@@ -853,8 +853,6 @@ int cmd_grep(int argc, const char **argv, const char *prefix)\n \t\tOPT_END()\n \t};\n \n-\tprefix = setup_git_directory_gently(&nongit);\n-\n \t/*\n \t * 'git grep -h', unlike 'git grep -h <pattern>', is a request\n \t * to show usage information and exit.\n@@ -893,9 +891,8 @@ int cmd_grep(int argc, const char **argv, const char *prefix)\n \t\t\t     PARSE_OPT_STOP_AT_NON_OPTION |\n \t\t\t     PARSE_OPT_NO_INTERNAL_HELP);\n \n-\tif (use_index && nongit)\n-\t\t/* die the same way as if we did it at the beginning */\n-\t\tsetup_git_directory();\n+\tif (use_index && !startup_info->have_repository)\n+\t\tdie(\"No git repository found\");\n \n \t/*\n \t * skip a -- separator; we know it cannot be\ndiff --git a/git.c b/git.c\nindex 29489e6..3904fe2 100644\n--- a/git.c\n+++ b/git.c\n@@ -326,7 +326,7 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"fsck-objects\", cmd_fsck, RUN_SETUP },\n \t\t{ \"gc\", cmd_gc, RUN_SETUP },\n \t\t{ \"get-tar-commit-id\", cmd_get_tar_commit_id },\n-\t\t{ \"grep\", cmd_grep, USE_PAGER },\n+\t\t{ \"grep\", cmd_grep, RUN_SETUP_GENTLY | USE_PAGER },\n \t\t{ \"hash-object\", cmd_hash_object, RUN_SETUP_GENTLY },\n \t\t{ \"help\", cmd_help },\n \t\t{ \"index-pack\", cmd_index_pack },\n-- \n1.7.0.195.g637a2\n"},{"id":"136288","messageId":"1267937767-12504-8-git-send-email-pclouds@gmail.com","threadId":"22936","inReplyTo":"1267937767-12504-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 07/18] builtin: USE_PAGER should not be used without RUN_SETUP*","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-03-07T04:55:56Z","receivedAt":"2010-03-07T04:55:56Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"USE_PAGER may need core.pager from repository. So a repository search\nshould be done before core.pager is read.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n git.c |    5 ++++-\n 1 files changed, 4 insertions(+), 1 deletions(-)\n\ndiff --git a/git.c b/git.c\nindex 3904fe2..84dd78e 100644\n--- a/git.c\n+++ b/git.c\n@@ -253,8 +253,11 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)\n \n \t\tif (use_pager == -1 && p->option & RUN_SETUP)\n \t\t\tuse_pager = check_pager_config(p->cmd);\n-\t\tif (use_pager == -1 && p->option & USE_PAGER)\n+\t\tif (use_pager == -1 && p->option & USE_PAGER) {\n+\t\t\tif ((p->option & (RUN_SETUP | RUN_SETUP_GENTLY)) == 0)\n+\t\t\t\tdie(\"Internal error: USE_PAGER must be together with RUN_SETUP*\");\n \t\t\tuse_pager = 1;\n+\t\t}\n \t}\n \tcommit_pager_choice();\n \n-- \n1.7.0.195.g637a2\n"},{"id":"136276","messageId":"1267937767-12504-9-git-send-email-pclouds@gmail.com","threadId":"22936","inReplyTo":"1267937767-12504-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 08/18] archive: use RUN_SETUP_GENTLY","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-03-07T04:55:57Z","receivedAt":"2010-03-07T04:55:57Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/archive.c |    2 +-\n git.c             |    4 ++--\n 2 files changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/archive.c b/builtin/archive.c\nindex 6a887f5..ef0bef8 100644\n--- a/builtin/archive.c\n+++ b/builtin/archive.c\n@@ -125,5 +125,5 @@ int cmd_archive(int argc, const char **argv, const char *prefix)\n \n \tsetvbuf(stderr, NULL, _IOLBF, BUFSIZ);\n \n-\treturn write_archive(argc, argv, prefix, 1);\n+\treturn write_archive(argc, argv, prefix, 0);\n }\ndiff --git a/git.c b/git.c\nindex 84dd78e..2b59f06 100644\n--- a/git.c\n+++ b/git.c\n@@ -295,7 +295,7 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"stage\", cmd_add, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"annotate\", cmd_annotate, RUN_SETUP },\n \t\t{ \"apply\", cmd_apply },\n-\t\t{ \"archive\", cmd_archive },\n+\t\t{ \"archive\", cmd_archive, RUN_SETUP_GENTLY },\n \t\t{ \"bisect--helper\", cmd_bisect__helper, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"blame\", cmd_blame, RUN_SETUP },\n \t\t{ \"branch\", cmd_branch, RUN_SETUP },\n@@ -384,7 +384,7 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"stripspace\", cmd_stripspace },\n \t\t{ \"symbolic-ref\", cmd_symbolic_ref, RUN_SETUP },\n \t\t{ \"tag\", cmd_tag, RUN_SETUP },\n-\t\t{ \"tar-tree\", cmd_tar_tree },\n+\t\t{ \"tar-tree\", cmd_tar_tree, RUN_SETUP_GENTLY },\n \t\t{ \"unpack-file\", cmd_unpack_file, RUN_SETUP },\n \t\t{ \"unpack-objects\", cmd_unpack_objects, RUN_SETUP },\n \t\t{ \"update-index\", cmd_update_index, RUN_SETUP },\n-- \n1.7.0.195.g637a2\n"},{"id":"136277","messageId":"1267937767-12504-10-git-send-email-pclouds@gmail.com","threadId":"22936","inReplyTo":"1267937767-12504-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 09/18] mailinfo: use RUN_SETUP_GENTLY","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-03-07T04:55:58Z","receivedAt":"2010-03-07T04:55:58Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"mailinfo may use repo config, so setup gitdir first.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/mailinfo.c |    3 ---\n git.c              |    2 +-\n 2 files changed, 1 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/mailinfo.c b/builtin/mailinfo.c\nindex ce2ef6b..3d2c650 100644\n--- a/builtin/mailinfo.c\n+++ b/builtin/mailinfo.c\n@@ -1026,9 +1026,6 @@ int cmd_mailinfo(int argc, const char **argv, const char *prefix)\n {\n \tconst char *def_charset;\n \n-\t/* NEEDSWORK: might want to do the optional .git/ directory\n-\t * discovery\n-\t */\n \tgit_config(git_mailinfo_config, NULL);\n \n \tdef_charset = (git_commit_encoding ? git_commit_encoding : \"UTF-8\");\ndiff --git a/git.c b/git.c\nindex 2b59f06..326f7c7 100644\n--- a/git.c\n+++ b/git.c\n@@ -339,7 +339,7 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"ls-files\", cmd_ls_files, RUN_SETUP },\n \t\t{ \"ls-tree\", cmd_ls_tree, RUN_SETUP },\n \t\t{ \"ls-remote\", cmd_ls_remote },\n-\t\t{ \"mailinfo\", cmd_mailinfo },\n+\t\t{ \"mailinfo\", cmd_mailinfo, RUN_SETUP_GENTLY },\n \t\t{ \"mailsplit\", cmd_mailsplit },\n \t\t{ \"merge\", cmd_merge, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"merge-base\", cmd_merge_base, RUN_SETUP },\n-- \n1.7.0.195.g637a2\n"},{"id":"136278","messageId":"1267937767-12504-11-git-send-email-pclouds@gmail.com","threadId":"22936","inReplyTo":"1267937767-12504-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 10/18] check-ref-format: use RUN_SETUP_GENTLY","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-03-07T04:55:59Z","receivedAt":"2010-03-07T04:55:59Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"When --branch is used, check-ref-format will look into repository for\nbranch name. Therefore repository search is needed.\n\nThe call flow is:\n - cmd_check_ref_format\n - strbuf_check_branch_ref\n - strbuf_branchname\n - interpret_branch_name\n - branch_get\n - read_config\n - resolve_ref\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n git.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/git.c b/git.c\nindex 326f7c7..a8660f4 100644\n--- a/git.c\n+++ b/git.c\n@@ -304,7 +304,7 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"checkout\", cmd_checkout, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"checkout-index\", cmd_checkout_index,\n \t\t\tRUN_SETUP | NEED_WORK_TREE},\n-\t\t{ \"check-ref-format\", cmd_check_ref_format },\n+\t\t{ \"check-ref-format\", cmd_check_ref_format, RUN_SETUP_GENTLY },\n \t\t{ \"check-attr\", cmd_check_attr, RUN_SETUP },\n \t\t{ \"cherry\", cmd_cherry, RUN_SETUP },\n \t\t{ \"cherry-pick\", cmd_cherry_pick, RUN_SETUP | NEED_WORK_TREE },\n-- \n1.7.0.195.g637a2\n"},{"id":"136291","messageId":"1267937767-12504-12-git-send-email-pclouds@gmail.com","threadId":"22936","inReplyTo":"1267937767-12504-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 11/18] verify-pack: use RUN_SETUP_GENTLY","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-03-07T04:56:00Z","receivedAt":"2010-03-07T04:56:00Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n git.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/git.c b/git.c\nindex a8660f4..0e052c8 100644\n--- a/git.c\n+++ b/git.c\n@@ -396,7 +396,7 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"version\", cmd_version },\n \t\t{ \"whatchanged\", cmd_whatchanged, RUN_SETUP | USE_PAGER },\n \t\t{ \"write-tree\", cmd_write_tree, RUN_SETUP },\n-\t\t{ \"verify-pack\", cmd_verify_pack },\n+\t\t{ \"verify-pack\", cmd_verify_pack, RUN_SETUP_GENTLY },\n \t\t{ \"show-ref\", cmd_show_ref, RUN_SETUP },\n \t\t{ \"pack-refs\", cmd_pack_refs, RUN_SETUP },\n \t};\n-- \n1.7.0.195.g637a2\n"},{"id":"136279","messageId":"1267937767-12504-13-git-send-email-pclouds@gmail.com","threadId":"22936","inReplyTo":"1267937767-12504-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 12/18] apply: use RUN_SETUP_GENTLY","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-03-07T04:56:01Z","receivedAt":"2010-03-07T04:56:01Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/apply.c |    7 +++----\n git.c           |    2 +-\n 2 files changed, 4 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/apply.c b/builtin/apply.c\nindex 3af4ae0..d27aac6 100644\n--- a/builtin/apply.c\n+++ b/builtin/apply.c\n@@ -3516,7 +3516,6 @@ int cmd_apply(int argc, const char **argv, const char *unused_prefix)\n {\n \tint i;\n \tint errs = 0;\n-\tint is_not_gitdir;\n \tint binary;\n \tint force_apply = 0;\n \n@@ -3589,7 +3588,7 @@ int cmd_apply(int argc, const char **argv, const char *unused_prefix)\n \t\tOPT_END()\n \t};\n \n-\tprefix = setup_git_directory_gently(&is_not_gitdir);\n+\tprefix = startup_info->prefix;\n \tprefix_length = prefix ? strlen(prefix) : 0;\n \tgit_config(git_apply_config, NULL);\n \tif (apply_default_whitespace)\n@@ -3604,10 +3603,10 @@ int cmd_apply(int argc, const char **argv, const char *unused_prefix)\n \t\tapply = apply_verbosely = 1;\n \tif (!force_apply && (diffstat || numstat || summary || check || fake_ancestor))\n \t\tapply = 0;\n-\tif (check_index && is_not_gitdir)\n+\tif (check_index && !startup_info->have_repository)\n \t\tdie(\"--index outside a repository\");\n \tif (cached) {\n-\t\tif (is_not_gitdir)\n+\t\tif (!startup_info->have_repository)\n \t\t\tdie(\"--cached outside a repository\");\n \t\tcheck_index = 1;\n \t}\ndiff --git a/git.c b/git.c\nindex 0e052c8..7820d22 100644\n--- a/git.c\n+++ b/git.c\n@@ -294,7 +294,7 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"add\", cmd_add, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"stage\", cmd_add, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"annotate\", cmd_annotate, RUN_SETUP },\n-\t\t{ \"apply\", cmd_apply },\n+\t\t{ \"apply\", cmd_apply, RUN_SETUP_GENTLY },\n \t\t{ \"archive\", cmd_archive, RUN_SETUP_GENTLY },\n \t\t{ \"bisect--helper\", cmd_bisect__helper, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"blame\", cmd_blame, RUN_SETUP },\n-- \n1.7.0.195.g637a2\n"},{"id":"136280","messageId":"1267937767-12504-14-git-send-email-pclouds@gmail.com","threadId":"22936","inReplyTo":"1267937767-12504-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 13/18] bundle: use RUN_SETUP_GENTLY","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-03-07T04:56:02Z","receivedAt":"2010-03-07T04:56:02Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/bundle.c |    6 ++----\n git.c            |    2 +-\n 2 files changed, 3 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/bundle.c b/builtin/bundle.c\nindex 2006cc5..80649ba 100644\n--- a/builtin/bundle.c\n+++ b/builtin/bundle.c\n@@ -18,7 +18,6 @@ static const char builtin_bundle_usage[] =\n int cmd_bundle(int argc, const char **argv, const char *prefix)\n {\n \tstruct bundle_header header;\n-\tint nongit;\n \tconst char *cmd, *bundle_file;\n \tint bundle_fd = -1;\n \tchar buffer[PATH_MAX];\n@@ -31,7 +30,6 @@ int cmd_bundle(int argc, const char **argv, const char *prefix)\n \targc -= 2;\n \targv += 2;\n \n-\tprefix = setup_git_directory_gently(&nongit);\n \tif (prefix && bundle_file[0] != '/') {\n \t\tsnprintf(buffer, sizeof(buffer), \"%s/%s\", prefix, bundle_file);\n \t\tbundle_file = buffer;\n@@ -54,11 +52,11 @@ int cmd_bundle(int argc, const char **argv, const char *prefix)\n \t\treturn !!list_bundle_refs(&header, argc, argv);\n \t}\n \tif (!strcmp(cmd, \"create\")) {\n-\t\tif (nongit)\n+\t\tif (!startup_info->have_repository)\n \t\t\tdie(\"Need a repository to create a bundle.\");\n \t\treturn !!create_bundle(&header, bundle_file, argc, argv);\n \t} else if (!strcmp(cmd, \"unbundle\")) {\n-\t\tif (nongit)\n+\t\tif (!startup_info->have_repository)\n \t\t\tdie(\"Need a repository to unbundle.\");\n \t\treturn !!unbundle(&header, bundle_fd) ||\n \t\t\tlist_bundle_refs(&header, argc, argv);\ndiff --git a/git.c b/git.c\nindex 7820d22..a90e0c3 100644\n--- a/git.c\n+++ b/git.c\n@@ -299,7 +299,7 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"bisect--helper\", cmd_bisect__helper, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"blame\", cmd_blame, RUN_SETUP },\n \t\t{ \"branch\", cmd_branch, RUN_SETUP },\n-\t\t{ \"bundle\", cmd_bundle },\n+\t\t{ \"bundle\", cmd_bundle, RUN_SETUP_GENTLY },\n \t\t{ \"cat-file\", cmd_cat_file, RUN_SETUP },\n \t\t{ \"checkout\", cmd_checkout, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"checkout-index\", cmd_checkout_index,\n-- \n1.7.0.195.g637a2\n"},{"id":"136281","messageId":"1267937767-12504-15-git-send-email-pclouds@gmail.com","threadId":"22936","inReplyTo":"1267937767-12504-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 14/18] diff: use RUN_SETUP_GENTLY","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-03-07T04:56:03Z","receivedAt":"2010-03-07T04:56:03Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/diff.c |    6 ++----\n git.c          |    2 +-\n 2 files changed, 3 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/diff.c b/builtin/diff.c\nindex ffcdd05..e4bd855 100644\n--- a/builtin/diff.c\n+++ b/builtin/diff.c\n@@ -252,7 +252,6 @@ int cmd_diff(int argc, const char **argv, const char *prefix)\n \tint ents = 0, blobs = 0, paths = 0;\n \tconst char *path = NULL;\n \tstruct blobinfo blob[2];\n-\tint nongit;\n \tint result = 0;\n \n \t/*\n@@ -278,7 +277,6 @@ int cmd_diff(int argc, const char **argv, const char *prefix)\n \t * Other cases are errors.\n \t */\n \n-\tprefix = setup_git_directory_gently(&nongit);\n \tgit_config(git_diff_ui_config, NULL);\n \n \tif (diff_use_color_default == -1)\n@@ -287,7 +285,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)\n \tinit_revisions(&rev, prefix);\n \n \t/* If this is a no-index diff, just run it and exit there. */\n-\tdiff_no_index(&rev, argc, argv, nongit, prefix);\n+\tdiff_no_index(&rev, argc, argv, !startup_info->have_repository, prefix);\n \n \t/* Otherwise, we are doing the usual \"git\" diff */\n \trev.diffopt.skip_stat_unmatch = !!diff_auto_refresh_index;\n@@ -296,7 +294,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)\n \tDIFF_OPT_SET(&rev.diffopt, ALLOW_EXTERNAL);\n \tDIFF_OPT_SET(&rev.diffopt, ALLOW_TEXTCONV);\n \n-\tif (nongit)\n+\tif (!startup_info->have_repository)\n \t\tdie(\"Not a git repository\");\n \targc = setup_revisions(argc, argv, &rev, NULL);\n \tif (!rev.diffopt.output_format) {\ndiff --git a/git.c b/git.c\nindex a90e0c3..02ba3b2 100644\n--- a/git.c\n+++ b/git.c\n@@ -315,7 +315,7 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"config\", cmd_config, RUN_SETUP_GENTLY },\n \t\t{ \"count-objects\", cmd_count_objects, RUN_SETUP },\n \t\t{ \"describe\", cmd_describe, RUN_SETUP },\n-\t\t{ \"diff\", cmd_diff },\n+\t\t{ \"diff\", cmd_diff, RUN_SETUP_GENTLY },\n \t\t{ \"diff-files\", cmd_diff_files, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"diff-index\", cmd_diff_index, RUN_SETUP },\n \t\t{ \"diff-tree\", cmd_diff_tree, RUN_SETUP },\n-- \n1.7.0.195.g637a2\n"},{"id":"136282","messageId":"1267937767-12504-16-git-send-email-pclouds@gmail.com","threadId":"22936","inReplyTo":"1267937767-12504-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 15/18] help: use RUN_SETUP_GENTLY","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-03-07T04:56:04Z","receivedAt":"2010-03-07T04:56:04Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/help.c |    2 --\n git.c          |    2 +-\n 2 files changed, 1 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/help.c b/builtin/help.c\nindex 3182a2b..4988629 100644\n--- a/builtin/help.c\n+++ b/builtin/help.c\n@@ -414,7 +414,6 @@ static void show_html_page(const char *git_cmd)\n \n int cmd_help(int argc, const char **argv, const char *prefix)\n {\n-\tint nongit;\n \tconst char *alias;\n \tenum help_format parsed_help_format;\n \tload_command_list(\"git-\", &main_cmds, &other_cmds);\n@@ -437,7 +436,6 @@ int cmd_help(int argc, const char **argv, const char *prefix)\n \t\treturn 0;\n \t}\n \n-\tsetup_git_directory_gently(&nongit);\n \tgit_config(git_help_config, NULL);\n \n \tif (parsed_help_format != HELP_FORMAT_NONE)\ndiff --git a/git.c b/git.c\nindex 02ba3b2..6a29756 100644\n--- a/git.c\n+++ b/git.c\n@@ -331,7 +331,7 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"get-tar-commit-id\", cmd_get_tar_commit_id },\n \t\t{ \"grep\", cmd_grep, RUN_SETUP_GENTLY | USE_PAGER },\n \t\t{ \"hash-object\", cmd_hash_object, RUN_SETUP_GENTLY },\n-\t\t{ \"help\", cmd_help },\n+\t\t{ \"help\", cmd_help, RUN_SETUP_GENTLY },\n \t\t{ \"index-pack\", cmd_index_pack },\n \t\t{ \"init\", cmd_init_db },\n \t\t{ \"init-db\", cmd_init_db },\n-- \n1.7.0.195.g637a2\n"},{"id":"136283","messageId":"1267937767-12504-17-git-send-email-pclouds@gmail.com","threadId":"22936","inReplyTo":"1267937767-12504-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 16/18] ls-remote: use RUN_SETUP_GENTLY","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-03-07T04:56:05Z","receivedAt":"2010-03-07T04:56:05Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/ls-remote.c |    3 ---\n git.c               |    4 ++--\n 2 files changed, 2 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/ls-remote.c b/builtin/ls-remote.c\nindex 70f5622..998f2c8 100644\n--- a/builtin/ls-remote.c\n+++ b/builtin/ls-remote.c\n@@ -31,7 +31,6 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n {\n \tint i;\n \tconst char *dest = NULL;\n-\tint nongit;\n \tunsigned flags = 0;\n \tconst char *uploadpack = NULL;\n \tconst char **pattern = NULL;\n@@ -40,8 +39,6 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n \tstruct transport *transport;\n \tconst struct ref *ref;\n \n-\tsetup_git_directory_gently(&nongit);\n-\n \tfor (i = 1; i < argc; i++) {\n \t\tconst char *arg = argv[i];\n \ndiff --git a/git.c b/git.c\nindex 6a29756..e0c8904 100644\n--- a/git.c\n+++ b/git.c\n@@ -338,7 +338,7 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"log\", cmd_log, RUN_SETUP | USE_PAGER },\n \t\t{ \"ls-files\", cmd_ls_files, RUN_SETUP },\n \t\t{ \"ls-tree\", cmd_ls_tree, RUN_SETUP },\n-\t\t{ \"ls-remote\", cmd_ls_remote },\n+\t\t{ \"ls-remote\", cmd_ls_remote, RUN_SETUP_GENTLY },\n \t\t{ \"mailinfo\", cmd_mailinfo, RUN_SETUP_GENTLY },\n \t\t{ \"mailsplit\", cmd_mailsplit },\n \t\t{ \"merge\", cmd_merge, RUN_SETUP | NEED_WORK_TREE },\n@@ -359,7 +359,7 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"pack-objects\", cmd_pack_objects, RUN_SETUP },\n \t\t{ \"pack-redundant\", cmd_pack_redundant, RUN_SETUP },\n \t\t{ \"patch-id\", cmd_patch_id },\n-\t\t{ \"peek-remote\", cmd_ls_remote },\n+\t\t{ \"peek-remote\", cmd_ls_remote, RUN_SETUP_GENTLY },\n \t\t{ \"pickaxe\", cmd_blame, RUN_SETUP },\n \t\t{ \"prune\", cmd_prune, RUN_SETUP },\n \t\t{ \"prune-packed\", cmd_prune_packed, RUN_SETUP },\n-- \n1.7.0.195.g637a2\n"},{"id":"136284","messageId":"1267937767-12504-18-git-send-email-pclouds@gmail.com","threadId":"22936","inReplyTo":"1267937767-12504-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 17/18] var: use RUN_SETUP_GENTLY","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-03-07T04:56:06Z","receivedAt":"2010-03-07T04:56:06Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"\"git var\" needs to read repository config, so setup gitdir first.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/var.c |    2 --\n git.c         |    2 +-\n 2 files changed, 1 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/var.c b/builtin/var.c\nindex 70fdb4d..26324ef 100644\n--- a/builtin/var.c\n+++ b/builtin/var.c\n@@ -75,12 +75,10 @@ static int show_config(const char *var, const char *value, void *cb)\n int cmd_var(int argc, const char **argv, const char *prefix)\n {\n \tconst char *val;\n-\tint nongit;\n \tif (argc != 2) {\n \t\tusage(var_usage);\n \t}\n \n-\tsetup_git_directory_gently(&nongit);\n \tval = NULL;\n \n \tif (strcmp(argv[1], \"-l\") == 0) {\ndiff --git a/git.c b/git.c\nindex e0c8904..3292627 100644\n--- a/git.c\n+++ b/git.c\n@@ -391,7 +391,7 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"update-ref\", cmd_update_ref, RUN_SETUP },\n \t\t{ \"update-server-info\", cmd_update_server_info, RUN_SETUP },\n \t\t{ \"upload-archive\", cmd_upload_archive },\n-\t\t{ \"var\", cmd_var },\n+\t\t{ \"var\", cmd_var, RUN_SETUP_GENTLY },\n \t\t{ \"verify-tag\", cmd_verify_tag, RUN_SETUP },\n \t\t{ \"version\", cmd_version },\n \t\t{ \"whatchanged\", cmd_whatchanged, RUN_SETUP | USE_PAGER },\n-- \n1.7.0.195.g637a2\n"},{"id":"136285","messageId":"1267937767-12504-19-git-send-email-pclouds@gmail.com","threadId":"22936","inReplyTo":"1267937767-12504-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 18/18] merge-file: use RUN_SETUP_GENTLY","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-03-07T04:56:07Z","receivedAt":"2010-03-07T04:56:07Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/merge-file.c |    4 +---\n git.c                |    2 +-\n 2 files changed, 2 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/merge-file.c b/builtin/merge-file.c\nindex 1e70073..474c6c2 100644\n--- a/builtin/merge-file.c\n+++ b/builtin/merge-file.c\n@@ -30,7 +30,6 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)\n \tint level = XDL_MERGE_ZEALOUS_ALNUM;\n \tint style = 0, quiet = 0;\n \tint favor = 0;\n-\tint nongit;\n \n \tstruct option options[] = {\n \t\tOPT_BOOLEAN('p', \"stdout\", &to_stdout, \"send results to standard output\"),\n@@ -45,8 +44,7 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)\n \t\tOPT_END(),\n \t};\n \n-\tprefix = setup_git_directory_gently(&nongit);\n-\tif (!nongit) {\n+\tif (startup_info->have_repository) {\n \t\t/* Read the configuration file */\n \t\tgit_config(git_xmerge_config, NULL);\n \t\tif (0 <= git_xmerge_style)\ndiff --git a/git.c b/git.c\nindex 3292627..88408c8 100644\n--- a/git.c\n+++ b/git.c\n@@ -343,7 +343,7 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"mailsplit\", cmd_mailsplit },\n \t\t{ \"merge\", cmd_merge, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"merge-base\", cmd_merge_base, RUN_SETUP },\n-\t\t{ \"merge-file\", cmd_merge_file },\n+\t\t{ \"merge-file\", cmd_merge_file, RUN_SETUP_GENTLY },\n \t\t{ \"merge-index\", cmd_merge_index, RUN_SETUP },\n \t\t{ \"merge-ours\", cmd_merge_ours, RUN_SETUP },\n \t\t{ \"merge-recursive\", cmd_merge_recursive, RUN_SETUP | NEED_WORK_TREE },\n-- \n1.7.0.195.g637a2\n"}]}