* [PATCH 00/43] nd/setup update
@ 2010-04-05 18:40 Nguyễn Thái Ngọc Duy
2010-04-05 18:40 ` [PATCH 01/43] builtin: introduce startup_info struct Nguyễn Thái Ngọc Duy
` (42 more replies)
0 siblings, 43 replies; 50+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-04-05 18:40 UTC (permalink / raw)
To: git, Junio C Hamano, Jonathan Niedier
Cc: Nguyễn Thái Ngọc Duy
Cleanup series, rebased on master.
Except 15/43 (which is now a comment only patch), no changes from pu 9f72b82.
Jonathan Nieder (2):
help: take note why this command is not applicable for
RUN_SETUP_GENTLY
t0001: Add test cases for "git init" with aliases
Nguyễn Thái Ngọc Duy (41):
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
ls-remote: use RUN_SETUP_GENTLY
var: use RUN_SETUP_GENTLY
merge-file: use RUN_SETUP_GENTLY
worktree setup: calculate prefix even if no worktree is found
index-pack: trust the prefix returned by setup_git_directory_gently()
index-pack: use RUN_SETUP_GENTLY
Move enter_repo() to setup.c
enter_repo(): initialize other variables as
setup_git_directory_gently() does
rev-parse --git-dir: print relative gitdir correctly
worktree setup: call set_git_dir explicitly
Add git_config_early()
Use git_config_early() instead of git_config() during repo setup
worktree setup: restore original state when things go wrong
init/clone: turn on startup->have_repository properly
git_config(): do not read .git/config if there is no repository
Do not read .git/info/exclude if there is no repository
Do not read .git/info/attributes if there is no repository
apply: do not check sha1 when repository has not been found
config: do not read .git/config if there is no repository
run_builtin(): save "-h" detection result for later use
builtins: utilize startup_info->help where possible
builtins: check for startup_info->help, print and exit early
Allow to undo setup_git_directory_gently() gracefully (and fix alias
code)
alias: keep repository found while collecting aliases as long as
possible
Guard unallowed access to repository when it's not set up
builtins: setup repository before print unknown command error
builtins: do not commit pager choice early
attr.c | 5 +-
builtin/apply.c | 9 +-
builtin/archive.c | 2 +-
builtin/branch.c | 3 +
builtin/bundle.c | 6 +-
builtin/check-ref-format.c | 2 +-
builtin/checkout-index.c | 3 +
builtin/clone.c | 3 +-
builtin/commit.c | 6 +
builtin/config.c | 15 ++--
builtin/diff.c | 6 +-
builtin/gc.c | 3 +
builtin/grep.c | 11 +--
builtin/hash-object.c | 9 +-
builtin/help.c | 5 +
builtin/index-pack.c | 21 +---
builtin/init-db.c | 10 +-
builtin/log.c | 6 +-
builtin/ls-files.c | 3 +
builtin/ls-remote.c | 3 -
builtin/mailinfo.c | 3 -
builtin/merge-file.c | 4 +-
builtin/merge-ours.c | 2 +-
builtin/merge.c | 3 +
builtin/pack-redundant.c | 2 +-
builtin/rev-parse.c | 8 ++
builtin/shortlog.c | 4 +-
builtin/show-ref.c | 2 +-
builtin/update-index.c | 3 +
builtin/upload-archive.c | 7 +-
builtin/var.c | 2 -
cache.h | 14 +++-
config.c | 22 ++++-
dir.c | 8 +-
environment.c | 34 +++++++-
git.c | 99 ++++++++++++-------
help.c | 4 +
path.c | 91 ------------------
setup.c | 223 ++++++++++++++++++++++++++++++++++++++++----
t/t0001-init.sh | 52 ++++++++++
t/t1300-repo-config.sh | 14 +++
t/t1302-repo-version.sh | 2 +-
t/t1500-rev-parse.sh | 2 +-
t/t1501-worktree.sh | 5 +
t/t7002-grep.sh | 24 +++++
45 files changed, 525 insertions(+), 240 deletions(-)
^ permalink raw reply [flat|nested] 50+ messages in thread
* [PATCH 01/43] builtin: introduce startup_info struct
2010-04-05 18:40 [PATCH 00/43] nd/setup update Nguyễn Thái Ngọc Duy
@ 2010-04-05 18:40 ` Nguyễn Thái Ngọc Duy
2010-04-05 18:40 ` [PATCH 02/43] builtin: Support RUN_SETUP_GENTLY to set up repository early if found Nguyễn Thái Ngọc Duy
` (41 subsequent siblings)
42 siblings, 0 replies; 50+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-04-05 18:40 UTC (permalink / raw)
To: git, Junio C Hamano, Jonathan Niedier
Cc: Nguyễn Thái Ngọc Duy, Junio C Hamano
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>
Signed-off-by: Junio C Hamano <gitster@pobox.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 6dcb100..8d8f8ee 100644
--- a/cache.h
+++ b/cache.h
@@ -1061,4 +1061,10 @@ int split_cmdline(char *cmdline, const char ***argv);
/* builtin/merge.c */
int checkout_fast_forward(const unsigned char *from, const unsigned char *to);
+/* 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.rc1.541.g2da82.dirty
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH 02/43] builtin: Support RUN_SETUP_GENTLY to set up repository early if found
2010-04-05 18:40 [PATCH 00/43] nd/setup update Nguyễn Thái Ngọc Duy
2010-04-05 18:40 ` [PATCH 01/43] builtin: introduce startup_info struct Nguyễn Thái Ngọc Duy
@ 2010-04-05 18:40 ` Nguyễn Thái Ngọc Duy
2010-04-05 18:40 ` [PATCH 03/43] config: use RUN_SETUP_GENTLY Nguyễn Thái Ngọc Duy
` (40 subsequent siblings)
42 siblings, 0 replies; 50+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-04-05 18:40 UTC (permalink / raw)
To: git, Junio C Hamano, Jonathan Niedier
Cc: Nguyễn Thái Ngọc Duy, Junio C Hamano
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>
Signed-off-by: Junio C Hamano <gitster@pobox.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 8d8f8ee..fa13bf7 100644
--- a/cache.h
+++ b/cache.h
@@ -1064,6 +1064,7 @@ int checkout_fast_forward(const unsigned char *from, const unsigned char *to);
/* 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.rc1.541.g2da82.dirty
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH 03/43] config: use RUN_SETUP_GENTLY
2010-04-05 18:40 [PATCH 00/43] nd/setup update Nguyễn Thái Ngọc Duy
2010-04-05 18:40 ` [PATCH 01/43] builtin: introduce startup_info struct Nguyễn Thái Ngọc Duy
2010-04-05 18:40 ` [PATCH 02/43] builtin: Support RUN_SETUP_GENTLY to set up repository early if found Nguyễn Thái Ngọc Duy
@ 2010-04-05 18:40 ` Nguyễn Thái Ngọc Duy
2010-04-05 18:40 ` [PATCH 04/43] hash-object: " Nguyễn Thái Ngọc Duy
` (39 subsequent siblings)
42 siblings, 0 replies; 50+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-04-05 18:40 UTC (permalink / raw)
To: git, Junio C Hamano, Jonathan Niedier
Cc: Nguyễn Thái Ngọc Duy, Junio C Hamano
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.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.rc1.541.g2da82.dirty
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH 04/43] hash-object: use RUN_SETUP_GENTLY
2010-04-05 18:40 [PATCH 00/43] nd/setup update Nguyễn Thái Ngọc Duy
` (2 preceding siblings ...)
2010-04-05 18:40 ` [PATCH 03/43] config: use RUN_SETUP_GENTLY Nguyễn Thái Ngọc Duy
@ 2010-04-05 18:40 ` Nguyễn Thái Ngọc Duy
2010-04-05 18:40 ` [PATCH 05/43] shortlog: " Nguyễn Thái Ngọc Duy
` (38 subsequent siblings)
42 siblings, 0 replies; 50+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-04-05 18:40 UTC (permalink / raw)
To: git, Junio C Hamano, Jonathan Niedier
Cc: Nguyễn Thái Ngọc Duy, Junio C Hamano
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>
Signed-off-by: Junio C Hamano <gitster@pobox.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 080af1a..1f7fd6a 100644
--- a/builtin/hash-object.c
+++ b/builtin/hash-object.c
@@ -78,7 +78,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;
@@ -86,9 +86,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.rc1.541.g2da82.dirty
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH 05/43] shortlog: use RUN_SETUP_GENTLY
2010-04-05 18:40 [PATCH 00/43] nd/setup update Nguyễn Thái Ngọc Duy
` (3 preceding siblings ...)
2010-04-05 18:40 ` [PATCH 04/43] hash-object: " Nguyễn Thái Ngọc Duy
@ 2010-04-05 18:40 ` Nguyễn Thái Ngọc Duy
2010-04-05 18:40 ` [PATCH 06/43] grep: " Nguyễn Thái Ngọc Duy
` (37 subsequent siblings)
42 siblings, 0 replies; 50+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-04-05 18:40 UTC (permalink / raw)
To: git, Junio C Hamano, Jonathan Niedier
Cc: Nguyễn Thái Ngọc Duy, Junio C Hamano
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>
Signed-off-by: Junio C Hamano <gitster@pobox.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.rc1.541.g2da82.dirty
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH 06/43] grep: use RUN_SETUP_GENTLY
2010-04-05 18:40 [PATCH 00/43] nd/setup update Nguyễn Thái Ngọc Duy
` (4 preceding siblings ...)
2010-04-05 18:40 ` [PATCH 05/43] shortlog: " Nguyễn Thái Ngọc Duy
@ 2010-04-05 18:40 ` Nguyễn Thái Ngọc Duy
2010-04-05 18:40 ` [PATCH 07/43] builtin: USE_PAGER should not be used without RUN_SETUP* Nguyễn Thái Ngọc Duy
` (36 subsequent siblings)
42 siblings, 0 replies; 50+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-04-05 18:40 UTC (permalink / raw)
To: git, Junio C Hamano, Jonathan Niedier
Cc: Nguyễn Thái Ngọc Duy, Junio C Hamano
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>
Signed-off-by: Junio C Hamano <gitster@pobox.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 9d30ddb..a4ea0c9 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -779,7 +779,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"),
@@ -867,8 +867,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.
@@ -913,9 +911,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.rc1.541.g2da82.dirty
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH 07/43] builtin: USE_PAGER should not be used without RUN_SETUP*
2010-04-05 18:40 [PATCH 00/43] nd/setup update Nguyễn Thái Ngọc Duy
` (5 preceding siblings ...)
2010-04-05 18:40 ` [PATCH 06/43] grep: " Nguyễn Thái Ngọc Duy
@ 2010-04-05 18:40 ` Nguyễn Thái Ngọc Duy
2010-04-05 18:40 ` [PATCH 08/43] archive: use RUN_SETUP_GENTLY Nguyễn Thái Ngọc Duy
` (35 subsequent siblings)
42 siblings, 0 replies; 50+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-04-05 18:40 UTC (permalink / raw)
To: git, Junio C Hamano, Jonathan Niedier
Cc: Nguyễn Thái Ngọc Duy, Junio C Hamano
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>
Signed-off-by: Junio C Hamano <gitster@pobox.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.rc1.541.g2da82.dirty
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH 08/43] archive: use RUN_SETUP_GENTLY
2010-04-05 18:40 [PATCH 00/43] nd/setup update Nguyễn Thái Ngọc Duy
` (6 preceding siblings ...)
2010-04-05 18:40 ` [PATCH 07/43] builtin: USE_PAGER should not be used without RUN_SETUP* Nguyễn Thái Ngọc Duy
@ 2010-04-05 18:40 ` Nguyễn Thái Ngọc Duy
2010-04-05 18:40 ` [PATCH 09/43] mailinfo: " Nguyễn Thái Ngọc Duy
` (34 subsequent siblings)
42 siblings, 0 replies; 50+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-04-05 18:40 UTC (permalink / raw)
To: git, Junio C Hamano, Jonathan Niedier
Cc: Nguyễn Thái Ngọc Duy, Junio C Hamano
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.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.rc1.541.g2da82.dirty
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH 09/43] mailinfo: use RUN_SETUP_GENTLY
2010-04-05 18:40 [PATCH 00/43] nd/setup update Nguyễn Thái Ngọc Duy
` (7 preceding siblings ...)
2010-04-05 18:40 ` [PATCH 08/43] archive: use RUN_SETUP_GENTLY Nguyễn Thái Ngọc Duy
@ 2010-04-05 18:40 ` Nguyễn Thái Ngọc Duy
2010-04-05 18:40 ` [PATCH 10/43] check-ref-format: " Nguyễn Thái Ngọc Duy
` (33 subsequent siblings)
42 siblings, 0 replies; 50+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-04-05 18:40 UTC (permalink / raw)
To: git, Junio C Hamano, Jonathan Niedier
Cc: Nguyễn Thái Ngọc Duy, Junio C Hamano
mailinfo may use repo config, so setup gitdir first.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.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.rc1.541.g2da82.dirty
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH 10/43] check-ref-format: use RUN_SETUP_GENTLY
2010-04-05 18:40 [PATCH 00/43] nd/setup update Nguyễn Thái Ngọc Duy
` (8 preceding siblings ...)
2010-04-05 18:40 ` [PATCH 09/43] mailinfo: " Nguyễn Thái Ngọc Duy
@ 2010-04-05 18:40 ` Nguyễn Thái Ngọc Duy
2010-04-05 18:40 ` [PATCH 11/43] verify-pack: " Nguyễn Thái Ngọc Duy
` (32 subsequent siblings)
42 siblings, 0 replies; 50+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-04-05 18:40 UTC (permalink / raw)
To: git, Junio C Hamano, Jonathan Niedier
Cc: Nguyễn Thái Ngọc Duy, Junio C Hamano
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>
Signed-off-by: Junio C Hamano <gitster@pobox.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.rc1.541.g2da82.dirty
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH 11/43] verify-pack: use RUN_SETUP_GENTLY
2010-04-05 18:40 [PATCH 00/43] nd/setup update Nguyễn Thái Ngọc Duy
` (9 preceding siblings ...)
2010-04-05 18:40 ` [PATCH 10/43] check-ref-format: " Nguyễn Thái Ngọc Duy
@ 2010-04-05 18:40 ` Nguyễn Thái Ngọc Duy
2010-04-05 18:40 ` [PATCH 12/43] apply: " Nguyễn Thái Ngọc Duy
` (31 subsequent siblings)
42 siblings, 0 replies; 50+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-04-05 18:40 UTC (permalink / raw)
To: git, Junio C Hamano, Jonathan Niedier
Cc: Nguyễn Thái Ngọc Duy, Junio C Hamano
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.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.rc1.541.g2da82.dirty
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH 12/43] apply: use RUN_SETUP_GENTLY
2010-04-05 18:40 [PATCH 00/43] nd/setup update Nguyễn Thái Ngọc Duy
` (10 preceding siblings ...)
2010-04-05 18:40 ` [PATCH 11/43] verify-pack: " Nguyễn Thái Ngọc Duy
@ 2010-04-05 18:40 ` Nguyễn Thái Ngọc Duy
2010-04-05 18:40 ` [PATCH 13/43] bundle: " Nguyễn Thái Ngọc Duy
` (30 subsequent siblings)
42 siblings, 0 replies; 50+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-04-05 18:40 UTC (permalink / raw)
To: git, Junio C Hamano, Jonathan Niedier
Cc: Nguyễn Thái Ngọc Duy, Junio C Hamano
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.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 7ca9047..bb957d4 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -3621,7 +3621,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;
@@ -3694,7 +3693,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)
@@ -3709,10 +3708,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.rc1.541.g2da82.dirty
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH 13/43] bundle: use RUN_SETUP_GENTLY
2010-04-05 18:40 [PATCH 00/43] nd/setup update Nguyễn Thái Ngọc Duy
` (11 preceding siblings ...)
2010-04-05 18:40 ` [PATCH 12/43] apply: " Nguyễn Thái Ngọc Duy
@ 2010-04-05 18:40 ` Nguyễn Thái Ngọc Duy
2010-04-05 18:40 ` [PATCH 14/43] diff: " Nguyễn Thái Ngọc Duy
` (29 subsequent siblings)
42 siblings, 0 replies; 50+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-04-05 18:40 UTC (permalink / raw)
To: git, Junio C Hamano, Jonathan Niedier
Cc: Nguyễn Thái Ngọc Duy, Junio C Hamano
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.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.rc1.541.g2da82.dirty
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH 14/43] diff: use RUN_SETUP_GENTLY
2010-04-05 18:40 [PATCH 00/43] nd/setup update Nguyễn Thái Ngọc Duy
` (12 preceding siblings ...)
2010-04-05 18:40 ` [PATCH 13/43] bundle: " Nguyễn Thái Ngọc Duy
@ 2010-04-05 18:40 ` Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 15/43] help: take note why this command is not applicable for RUN_SETUP_GENTLY Nguyễn Thái Ngọc Duy
` (28 subsequent siblings)
42 siblings, 0 replies; 50+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-04-05 18:40 UTC (permalink / raw)
To: git, Junio C Hamano, Jonathan Niedier
Cc: Nguyễn Thái Ngọc Duy, Junio C Hamano
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.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.rc1.541.g2da82.dirty
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH 15/43] help: take note why this command is not applicable for RUN_SETUP_GENTLY
2010-04-05 18:40 [PATCH 00/43] nd/setup update Nguyễn Thái Ngọc Duy
` (13 preceding siblings ...)
2010-04-05 18:40 ` [PATCH 14/43] diff: " Nguyễn Thái Ngọc Duy
@ 2010-04-05 18:41 ` Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 16/43] ls-remote: use RUN_SETUP_GENTLY Nguyễn Thái Ngọc Duy
` (27 subsequent siblings)
42 siblings, 0 replies; 50+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-04-05 18:41 UTC (permalink / raw)
To: git, Junio C Hamano, Jonathan Niedier
Cc: Jonathan Nieder, Nguyễn Thái Ngọc Duy
From: Jonathan Nieder <jrnieder@gmail.com>
"git help" calls setup_git_directory_gently(), thus a candidate for
RUN_SETUP_GENTLY. However RUN_SETUP_GENTLY should not be used for
performance reason, as follows.
In automount setups like that which prompted v1.6.0-rc0~121^2~1 (Add
support for GIT_CEILING_DIRECTORIES, 2008-05-19), if
GIT_CEILING_DIRECTORIES is unset, then probing for the Git directory
can take a long time. Thus unnecessarily searching for a git
directory can slow down 'git help -a' (and thus bash completion).
'git help' does not use RUN_SETUP or USE_PAGER, and neither option
parsing nor producing output for plain 'git help' or 'git help -a'
requires access to the git configuration. Therefore it is safe to not
search for the git directory early in this case.
Also add some comments to document the requirements this places on
list_commands() and list_common_cmds_help().
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
builtin/help.c | 5 +++++
help.c | 4 ++++
2 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/builtin/help.c b/builtin/help.c
index 3182a2b..1626251 100644
--- a/builtin/help.c
+++ b/builtin/help.c
@@ -271,6 +271,11 @@ static int git_help_config(const char *var, const char *value, void *cb)
static struct cmdnames main_cmds, other_cmds;
+/*
+ * Used for plain 'git' and 'git help'.
+ * Therefore this should not use git_config(), nor any other function
+ * that requires searching for a repository.
+ */
void list_common_cmds_help(void)
{
int i, longest = 0;
diff --git a/help.c b/help.c
index 7f4928e..d4c3165 100644
--- a/help.c
+++ b/help.c
@@ -221,6 +221,10 @@ void load_command_list(const char *prefix,
exclude_cmds(other_cmds, main_cmds);
}
+/*
+ * Used for 'git help -a'. Therefore this should not use git_config(),
+ * nor any other function that requires searching for a repository.
+ */
void list_commands(const char *title, struct cmdnames *main_cmds,
struct cmdnames *other_cmds)
{
--
1.7.0.rc1.541.g2da82.dirty
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH 16/43] ls-remote: use RUN_SETUP_GENTLY
2010-04-05 18:40 [PATCH 00/43] nd/setup update Nguyễn Thái Ngọc Duy
` (14 preceding siblings ...)
2010-04-05 18:41 ` [PATCH 15/43] help: take note why this command is not applicable for RUN_SETUP_GENTLY Nguyễn Thái Ngọc Duy
@ 2010-04-05 18:41 ` Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 17/43] var: " Nguyễn Thái Ngọc Duy
` (26 subsequent siblings)
42 siblings, 0 replies; 50+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-04-05 18:41 UTC (permalink / raw)
To: git, Junio C Hamano, Jonathan Niedier
Cc: Nguyễn Thái Ngọc Duy, Junio C Hamano
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.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 02ba3b2..257ddde 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.rc1.541.g2da82.dirty
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH 17/43] var: use RUN_SETUP_GENTLY
2010-04-05 18:40 [PATCH 00/43] nd/setup update Nguyễn Thái Ngọc Duy
` (15 preceding siblings ...)
2010-04-05 18:41 ` [PATCH 16/43] ls-remote: use RUN_SETUP_GENTLY Nguyễn Thái Ngọc Duy
@ 2010-04-05 18:41 ` Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 18/43] merge-file: " Nguyễn Thái Ngọc Duy
` (25 subsequent siblings)
42 siblings, 0 replies; 50+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-04-05 18:41 UTC (permalink / raw)
To: git, Junio C Hamano, Jonathan Niedier
Cc: Nguyễn Thái Ngọc Duy, Junio C Hamano
"git var" needs to read repository config, so setup gitdir first.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.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 257ddde..567d533 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.rc1.541.g2da82.dirty
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH 18/43] merge-file: use RUN_SETUP_GENTLY
2010-04-05 18:40 [PATCH 00/43] nd/setup update Nguyễn Thái Ngọc Duy
` (16 preceding siblings ...)
2010-04-05 18:41 ` [PATCH 17/43] var: " Nguyễn Thái Ngọc Duy
@ 2010-04-05 18:41 ` Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 19/43] worktree setup: calculate prefix even if no worktree is found Nguyễn Thái Ngọc Duy
` (24 subsequent siblings)
42 siblings, 0 replies; 50+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-04-05 18:41 UTC (permalink / raw)
To: git, Junio C Hamano, Jonathan Niedier
Cc: Nguyễn Thái Ngọc Duy, Junio C Hamano
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.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 69cc683..493ff76 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 = {{XDF_NEED_MINIMAL}};
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/git.c b/git.c
index 567d533..96c2d21 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.rc1.541.g2da82.dirty
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH 19/43] worktree setup: calculate prefix even if no worktree is found
2010-04-05 18:40 [PATCH 00/43] nd/setup update Nguyễn Thái Ngọc Duy
` (17 preceding siblings ...)
2010-04-05 18:41 ` [PATCH 18/43] merge-file: " Nguyễn Thái Ngọc Duy
@ 2010-04-05 18:41 ` Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 20/43] index-pack: trust the prefix returned by setup_git_directory_gently() Nguyễn Thái Ngọc Duy
` (23 subsequent siblings)
42 siblings, 0 replies; 50+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-04-05 18:41 UTC (permalink / raw)
To: git, Junio C Hamano, Jonathan Niedier
Cc: Nguyễn Thái Ngọc Duy, Junio C Hamano
Commit a672ea6 (rehabilitate 'git index-pack' inside the object
store - 2008-10-20) worked around a fault in
setup_git_directory_gently(). When walking up from inside a git
repository, we will return NULL as prefix. We should have returned a
correct prefix anyway because cwd has been moved.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
setup.c | 19 ++++++++-----------
t/t1500-rev-parse.sh | 2 +-
t/t1501-worktree.sh | 5 +++++
3 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/setup.c b/setup.c
index bb3648c..8796c6f 100644
--- a/setup.c
+++ b/setup.c
@@ -392,13 +392,16 @@ static const char *setup_git_directory_gently_1(int *nongit_ok)
offset = len = strlen(cwd);
for (;;) {
gitfile_dir = read_gitfile_gently(DEFAULT_GIT_DIR_ENVIRONMENT);
- if (gitfile_dir) {
- if (set_git_dir(gitfile_dir))
+ if (gitfile_dir || is_git_directory(DEFAULT_GIT_DIR_ENVIRONMENT)) {
+ if (gitfile_dir && set_git_dir(gitfile_dir))
die("Repository setup failed");
+ inside_git_dir = 0;
+ if (!work_tree_env)
+ inside_work_tree = 1;
+ root_len = offset_1st_component(cwd);
+ git_work_tree_cfg = xstrndup(cwd, offset > root_len ? offset : root_len);
break;
}
- if (is_git_directory(DEFAULT_GIT_DIR_ENVIRONMENT))
- break;
if (is_git_directory(".")) {
inside_git_dir = 1;
if (!work_tree_env)
@@ -409,8 +412,7 @@ static const char *setup_git_directory_gently_1(int *nongit_ok)
set_git_dir(cwd);
} else
set_git_dir(".");
- check_repository_format_gently(nongit_ok);
- return NULL;
+ break;
}
while (--offset > ceil_offset && cwd[offset] != '/');
if (offset <= ceil_offset) {
@@ -426,11 +428,6 @@ static const char *setup_git_directory_gently_1(int *nongit_ok)
die_errno("Cannot change to '%s/..'", cwd);
}
- inside_git_dir = 0;
- if (!work_tree_env)
- inside_work_tree = 1;
- root_len = offset_1st_component(cwd);
- git_work_tree_cfg = xstrndup(cwd, offset > root_len ? offset : root_len);
if (check_repository_format_gently(nongit_ok))
return NULL;
if (offset == len)
diff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh
index 48ee077..4ee92c7 100755
--- a/t/t1500-rev-parse.sh
+++ b/t/t1500-rev-parse.sh
@@ -42,7 +42,7 @@ test_rev_parse toplevel false false true '' .git
cd .git || exit 1
test_rev_parse .git/ false true false '' .
cd objects || exit 1
-test_rev_parse .git/objects/ false true false '' "$ROOT/.git"
+test_rev_parse .git/objects/ false true false 'objects/' "$ROOT/.git"
cd ../.. || exit 1
mkdir -p sub/dir || exit 1
diff --git a/t/t1501-worktree.sh b/t/t1501-worktree.sh
index 9df3012..c72b578 100755
--- a/t/t1501-worktree.sh
+++ b/t/t1501-worktree.sh
@@ -28,6 +28,11 @@ test_rev_parse() {
[ $# -eq 0 ] && return
}
+cd .git/objects || exit 1
+say "subdirectory inside .git"
+test_rev_parse 'inside' false true false objects/
+cd ../.. || exit 1
+
EMPTY_TREE=$(git write-tree)
mkdir -p work/sub/dir || exit 1
mv .git repo.git || exit 1
--
1.7.0.rc1.541.g2da82.dirty
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH 20/43] index-pack: trust the prefix returned by setup_git_directory_gently()
2010-04-05 18:40 [PATCH 00/43] nd/setup update Nguyễn Thái Ngọc Duy
` (18 preceding siblings ...)
2010-04-05 18:41 ` [PATCH 19/43] worktree setup: calculate prefix even if no worktree is found Nguyễn Thái Ngọc Duy
@ 2010-04-05 18:41 ` Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 21/43] index-pack: use RUN_SETUP_GENTLY Nguyễn Thái Ngọc Duy
` (22 subsequent siblings)
42 siblings, 0 replies; 50+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-04-05 18:41 UTC (permalink / raw)
To: git, Junio C Hamano, Jonathan Niedier
Cc: Nguyễn Thái Ngọc Duy, Junio C Hamano
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
builtin/index-pack.c | 21 ++++++---------------
1 files changed, 6 insertions(+), 15 deletions(-)
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index b4cf8c5..2a6359d 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -879,29 +879,20 @@ 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);
/*
- * We wish to read the repository's config file if any, and
- * for that it is necessary to call setup_git_directory_gently().
+ * We wish to read the repository's config file if any.
* However if the cwd was inside .git/objects/pack/ then we need
* to go back there or all the pack name arguments will be wrong.
- * And in that case we cannot rely on any prefix returned by
- * setup_git_directory_gently() either.
*/
- {
- char cwd[PATH_MAX+1];
- int nongit;
-
- if (!getcwd(cwd, sizeof(cwd)-1))
- die("Unable to get current working directory");
- setup_git_directory_gently(&nongit);
- git_config(git_index_pack_config, NULL);
- if (chdir(cwd))
- die("Cannot come back to cwd");
- }
+ prefix = setup_git_directory_gently(&nongit);
+ git_config(git_index_pack_config, NULL);
+ if (prefix && chdir(prefix))
+ die("Cannot come back to cwd");
for (i = 1; i < argc; i++) {
const char *arg = argv[i];
--
1.7.0.rc1.541.g2da82.dirty
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH 21/43] index-pack: use RUN_SETUP_GENTLY
2010-04-05 18:40 [PATCH 00/43] nd/setup update Nguyễn Thái Ngọc Duy
` (19 preceding siblings ...)
2010-04-05 18:41 ` [PATCH 20/43] index-pack: trust the prefix returned by setup_git_directory_gently() Nguyễn Thái Ngọc Duy
@ 2010-04-05 18:41 ` Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 22/43] Move enter_repo() to setup.c Nguyễn Thái Ngọc Duy
` (21 subsequent siblings)
42 siblings, 0 replies; 50+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-04-05 18:41 UTC (permalink / raw)
To: git, Junio C Hamano, Jonathan Niedier
Cc: Nguyễn Thái Ngọc Duy, Junio C Hamano
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
builtin/index-pack.c | 2 --
git.c | 2 +-
2 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index 2a6359d..9aa6a13 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -879,7 +879,6 @@ 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);
@@ -889,7 +888,6 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
* However if the cwd was inside .git/objects/pack/ then we need
* to go back there or all the pack name arguments will be wrong.
*/
- 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/git.c b/git.c
index 96c2d21..fac3d1c 100644
--- a/git.c
+++ b/git.c
@@ -332,7 +332,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "grep", cmd_grep, RUN_SETUP_GENTLY | USE_PAGER },
{ "hash-object", cmd_hash_object, RUN_SETUP_GENTLY },
{ "help", cmd_help },
- { "index-pack", cmd_index_pack },
+ { "index-pack", cmd_index_pack, RUN_SETUP_GENTLY },
{ "init", cmd_init_db },
{ "init-db", cmd_init_db },
{ "log", cmd_log, RUN_SETUP | USE_PAGER },
--
1.7.0.rc1.541.g2da82.dirty
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH 22/43] Move enter_repo() to setup.c
2010-04-05 18:40 [PATCH 00/43] nd/setup update Nguyễn Thái Ngọc Duy
` (20 preceding siblings ...)
2010-04-05 18:41 ` [PATCH 21/43] index-pack: use RUN_SETUP_GENTLY Nguyễn Thái Ngọc Duy
@ 2010-04-05 18:41 ` Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 23/43] enter_repo(): initialize other variables as setup_git_directory_gently() does Nguyễn Thái Ngọc Duy
` (20 subsequent siblings)
42 siblings, 0 replies; 50+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-04-05 18:41 UTC (permalink / raw)
To: git, Junio C Hamano, Jonathan Niedier
Cc: Nguyễn Thái Ngọc Duy, Junio C Hamano
enter_repo() is to set up a repository, it fits better in setup.c
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
path.c | 91 ---------------------------------------------------------------
setup.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 91 insertions(+), 91 deletions(-)
diff --git a/path.c b/path.c
index b4c8d91..f42eb1b 100644
--- a/path.c
+++ b/path.c
@@ -332,97 +332,6 @@ return_null:
return NULL;
}
-/*
- * First, one directory to try is determined by the following algorithm.
- *
- * (0) If "strict" is given, the path is used as given and no DWIM is
- * done. Otherwise:
- * (1) "~/path" to mean path under the running user's home directory;
- * (2) "~user/path" to mean path under named user's home directory;
- * (3) "relative/path" to mean cwd relative directory; or
- * (4) "/absolute/path" to mean absolute directory.
- *
- * Unless "strict" is given, we try access() for existence of "%s.git/.git",
- * "%s/.git", "%s.git", "%s" in this order. The first one that exists is
- * what we try.
- *
- * Second, we try chdir() to that. Upon failure, we return NULL.
- *
- * Then, we try if the current directory is a valid git repository.
- * Upon failure, we return NULL.
- *
- * If all goes well, we return the directory we used to chdir() (but
- * before ~user is expanded), avoiding getcwd() resolving symbolic
- * links. User relative paths are also returned as they are given,
- * except DWIM suffixing.
- */
-char *enter_repo(char *path, int strict)
-{
- static char used_path[PATH_MAX];
- static char validated_path[PATH_MAX];
-
- if (!path)
- return NULL;
-
- if (!strict) {
- static const char *suffix[] = {
- ".git/.git", "/.git", ".git", "", NULL,
- };
- int len = strlen(path);
- int i;
- while ((1 < len) && (path[len-1] == '/')) {
- path[len-1] = 0;
- len--;
- }
- if (PATH_MAX <= len)
- return NULL;
- if (path[0] == '~') {
- char *newpath = expand_user_path(path);
- if (!newpath || (PATH_MAX - 10 < strlen(newpath))) {
- free(newpath);
- return NULL;
- }
- /*
- * Copy back into the static buffer. A pity
- * since newpath was not bounded, but other
- * branches of the if are limited by PATH_MAX
- * anyway.
- */
- strcpy(used_path, newpath); free(newpath);
- strcpy(validated_path, path);
- path = used_path;
- }
- else if (PATH_MAX - 10 < len)
- return NULL;
- else {
- path = strcpy(used_path, path);
- strcpy(validated_path, path);
- }
- len = strlen(path);
- for (i = 0; suffix[i]; i++) {
- strcpy(path + len, suffix[i]);
- if (!access(path, F_OK)) {
- strcat(validated_path, suffix[i]);
- break;
- }
- }
- if (!suffix[i] || chdir(path))
- return NULL;
- path = validated_path;
- }
- else if (chdir(path))
- return NULL;
-
- if (access("objects", X_OK) == 0 && access("refs", X_OK) == 0 &&
- validate_headref("HEAD") == 0) {
- set_git_dir(".");
- check_repository_format();
- return path;
- }
-
- return NULL;
-}
-
int set_shared_perm(const char *path, int mode)
{
struct stat st;
diff --git a/setup.c b/setup.c
index 8796c6f..3019da2 100644
--- a/setup.c
+++ b/setup.c
@@ -452,6 +452,97 @@ const char *setup_git_directory_gently(int *nongit_ok)
return prefix;
}
+/*
+ * First, one directory to try is determined by the following algorithm.
+ *
+ * (0) If "strict" is given, the path is used as given and no DWIM is
+ * done. Otherwise:
+ * (1) "~/path" to mean path under the running user's home directory;
+ * (2) "~user/path" to mean path under named user's home directory;
+ * (3) "relative/path" to mean cwd relative directory; or
+ * (4) "/absolute/path" to mean absolute directory.
+ *
+ * Unless "strict" is given, we try access() for existence of "%s.git/.git",
+ * "%s/.git", "%s.git", "%s" in this order. The first one that exists is
+ * what we try.
+ *
+ * Second, we try chdir() to that. Upon failure, we return NULL.
+ *
+ * Then, we try if the current directory is a valid git repository.
+ * Upon failure, we return NULL.
+ *
+ * If all goes well, we return the directory we used to chdir() (but
+ * before ~user is expanded), avoiding getcwd() resolving symbolic
+ * links. User relative paths are also returned as they are given,
+ * except DWIM suffixing.
+ */
+char *enter_repo(char *path, int strict)
+{
+ static char used_path[PATH_MAX];
+ static char validated_path[PATH_MAX];
+
+ if (!path)
+ return NULL;
+
+ if (!strict) {
+ static const char *suffix[] = {
+ ".git/.git", "/.git", ".git", "", NULL,
+ };
+ int len = strlen(path);
+ int i;
+ while ((1 < len) && (path[len-1] == '/')) {
+ path[len-1] = 0;
+ len--;
+ }
+ if (PATH_MAX <= len)
+ return NULL;
+ if (path[0] == '~') {
+ char *newpath = expand_user_path(path);
+ if (!newpath || (PATH_MAX - 10 < strlen(newpath))) {
+ free(newpath);
+ return NULL;
+ }
+ /*
+ * Copy back into the static buffer. A pity
+ * since newpath was not bounded, but other
+ * branches of the if are limited by PATH_MAX
+ * anyway.
+ */
+ strcpy(used_path, newpath); free(newpath);
+ strcpy(validated_path, path);
+ path = used_path;
+ }
+ else if (PATH_MAX - 10 < len)
+ return NULL;
+ else {
+ path = strcpy(used_path, path);
+ strcpy(validated_path, path);
+ }
+ len = strlen(path);
+ for (i = 0; suffix[i]; i++) {
+ strcpy(path + len, suffix[i]);
+ if (!access(path, F_OK)) {
+ strcat(validated_path, suffix[i]);
+ break;
+ }
+ }
+ if (!suffix[i] || chdir(path))
+ return NULL;
+ path = validated_path;
+ }
+ else if (chdir(path))
+ return NULL;
+
+ if (access("objects", X_OK) == 0 && access("refs", X_OK) == 0 &&
+ validate_headref("HEAD") == 0) {
+ set_git_dir(".");
+ check_repository_format();
+ return path;
+ }
+
+ return NULL;
+}
+
int git_config_perm(const char *var, const char *value)
{
int i;
--
1.7.0.rc1.541.g2da82.dirty
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH 23/43] enter_repo(): initialize other variables as setup_git_directory_gently() does
2010-04-05 18:40 [PATCH 00/43] nd/setup update Nguyễn Thái Ngọc Duy
` (21 preceding siblings ...)
2010-04-05 18:41 ` [PATCH 22/43] Move enter_repo() to setup.c Nguyễn Thái Ngọc Duy
@ 2010-04-05 18:41 ` Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 24/43] rev-parse --git-dir: print relative gitdir correctly Nguyễn Thái Ngọc Duy
` (19 subsequent siblings)
42 siblings, 0 replies; 50+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-04-05 18:41 UTC (permalink / raw)
To: git, Junio C Hamano, Jonathan Niedier
Cc: Nguyễn Thái Ngọc Duy, Junio C Hamano
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
setup.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/setup.c b/setup.c
index 3019da2..e067292 100644
--- a/setup.c
+++ b/setup.c
@@ -535,8 +535,14 @@ char *enter_repo(char *path, int strict)
if (access("objects", X_OK) == 0 && access("refs", X_OK) == 0 &&
validate_headref("HEAD") == 0) {
- set_git_dir(".");
+ inside_work_tree = 0;
+ inside_git_dir = 1;
check_repository_format();
+ set_git_dir(".");
+ if (startup_info) {
+ startup_info->prefix = NULL;
+ startup_info->have_repository = 1;
+ }
return path;
}
--
1.7.0.rc1.541.g2da82.dirty
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH 24/43] rev-parse --git-dir: print relative gitdir correctly
2010-04-05 18:40 [PATCH 00/43] nd/setup update Nguyễn Thái Ngọc Duy
` (22 preceding siblings ...)
2010-04-05 18:41 ` [PATCH 23/43] enter_repo(): initialize other variables as setup_git_directory_gently() does Nguyễn Thái Ngọc Duy
@ 2010-04-05 18:41 ` Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 25/43] worktree setup: call set_git_dir explicitly Nguyễn Thái Ngọc Duy
` (18 subsequent siblings)
42 siblings, 0 replies; 50+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-04-05 18:41 UTC (permalink / raw)
To: git, Junio C Hamano, Jonathan Niedier
Cc: Nguyễn Thái Ngọc Duy, Junio C Hamano
When git_dir is relative, it is relative to Git's current working
directory, which is worktree top directory. "git rev-parse --git-dir"
is expected to output relative to user's current working directory.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
builtin/rev-parse.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index 8fbf9d0..8819e8a 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -646,6 +646,14 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
static char cwd[PATH_MAX];
int len;
if (gitdir) {
+ if (prefix && !is_absolute_path(gitdir)) {
+ int len;
+ if (!getcwd(cwd, PATH_MAX))
+ die_errno("unable to get current working directory");
+ len = strlen(cwd);
+ printf("%s%s%s\n", cwd, len && cwd[len-1] != '/' ? "/" : "", gitdir);
+ continue;
+ }
puts(gitdir);
continue;
}
--
1.7.0.rc1.541.g2da82.dirty
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH 25/43] worktree setup: call set_git_dir explicitly
2010-04-05 18:40 [PATCH 00/43] nd/setup update Nguyễn Thái Ngọc Duy
` (23 preceding siblings ...)
2010-04-05 18:41 ` [PATCH 24/43] rev-parse --git-dir: print relative gitdir correctly Nguyễn Thái Ngọc Duy
@ 2010-04-05 18:41 ` Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 26/43] Add git_config_early() Nguyễn Thái Ngọc Duy
` (17 subsequent siblings)
42 siblings, 0 replies; 50+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-04-05 18:41 UTC (permalink / raw)
To: git, Junio C Hamano, Jonathan Niedier
Cc: Nguyễn Thái Ngọc Duy, Junio C Hamano
Currently setup_git_env() can automatically set git directory to
".git", relative to current working directory, no matter where it
is. Any access to repository may call setup_git_env() automatically if
there is no repository found yet. This leads to obscure faults where
we don't expect a repository setup to happen.
The ultimate goal (**) is:
- Git repository will be searched and set up by either one of these
functions (and no other functions):
+ setup_git_directory_gently()
+ setup_git_directory()
+ enter_repo()
+ init_db()
- Repository setup can't be called more than once. If it is really
needed, then un-setup the previous repo before moving on with
another one.
- Any attempts to access repository when it's not found/set up should
be caught.
This patch is the first step to accomplish this goal. It ensures that
after the "setup function" (mentioned above) is called, if a
repository is found, then setup_git_env() must be called already.
The two other cases (no setup function called,
setup_git_directory_gently() called but no repo found) will be covered
by the next patches, to ensure setup_git_env() will not be triggered.
(**) This only applies to builtin commands, for now.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
setup.c | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/setup.c b/setup.c
index e067292..43a8609 100644
--- a/setup.c
+++ b/setup.c
@@ -350,14 +350,17 @@ static const char *setup_git_directory_gently_1(int *nongit_ok)
/* config may override worktree */
if (check_repository_format_gently(nongit_ok))
return NULL;
+ set_git_dir(gitdirenv);
return retval;
}
if (check_repository_format_gently(nongit_ok))
return NULL;
retval = get_relative_cwd(buffer, sizeof(buffer) - 1,
get_git_work_tree());
- if (!retval || !*retval)
+ if (!retval || !*retval) {
+ set_git_dir(gitdirenv);
return NULL;
+ }
set_git_dir(make_absolute_path(gitdirenv));
if (chdir(work_tree_env) < 0)
die_errno ("Could not chdir to '%s'", work_tree_env);
@@ -392,8 +395,10 @@ static const char *setup_git_directory_gently_1(int *nongit_ok)
offset = len = strlen(cwd);
for (;;) {
gitfile_dir = read_gitfile_gently(DEFAULT_GIT_DIR_ENVIRONMENT);
- if (gitfile_dir || is_git_directory(DEFAULT_GIT_DIR_ENVIRONMENT)) {
- if (gitfile_dir && set_git_dir(gitfile_dir))
+ if (!gitfile_dir && is_git_directory(DEFAULT_GIT_DIR_ENVIRONMENT))
+ gitfile_dir = DEFAULT_GIT_DIR_ENVIRONMENT;
+ if (gitfile_dir) {
+ if (set_git_dir(gitfile_dir))
die("Repository setup failed");
inside_git_dir = 0;
if (!work_tree_env)
--
1.7.0.rc1.541.g2da82.dirty
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH 26/43] Add git_config_early()
2010-04-05 18:40 [PATCH 00/43] nd/setup update Nguyễn Thái Ngọc Duy
` (24 preceding siblings ...)
2010-04-05 18:41 ` [PATCH 25/43] worktree setup: call set_git_dir explicitly Nguyễn Thái Ngọc Duy
@ 2010-04-05 18:41 ` Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 27/43] Use git_config_early() instead of git_config() during repo setup Nguyễn Thái Ngọc Duy
` (16 subsequent siblings)
42 siblings, 0 replies; 50+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-04-05 18:41 UTC (permalink / raw)
To: git, Junio C Hamano, Jonathan Niedier
Cc: Nguyễn Thái Ngọc Duy, Junio C Hamano
This version of git_config() will be used during repository setup.
As a repository is being set up, $GIT_DIR is not nailed down yet,
git_pathdup() should not be used to get $GIT_DIR/config.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
cache.h | 1 +
config.c | 19 ++++++++++++++-----
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/cache.h b/cache.h
index fa13bf7..f4935b8 100644
--- a/cache.h
+++ b/cache.h
@@ -937,6 +937,7 @@ typedef int (*config_fn_t)(const char *, const char *, void *);
extern int git_default_config(const char *, const char *, void *);
extern int git_config_from_file(config_fn_t fn, const char *, void *);
extern int git_config(config_fn_t fn, void *);
+extern int git_config_early(config_fn_t fn, void *, const char *repo_config);
extern int git_parse_ulong(const char *, unsigned long *);
extern int git_config_int(const char *, const char *);
extern unsigned long git_config_ulong(const char *, const char *);
diff --git a/config.c b/config.c
index 6963fbe..2d38096 100644
--- a/config.c
+++ b/config.c
@@ -699,10 +699,9 @@ int git_config_global(void)
return !git_env_bool("GIT_CONFIG_NOGLOBAL", 0);
}
-int git_config(config_fn_t fn, void *data)
+int git_config_early(config_fn_t fn, void *data, const char *repo_config)
{
int ret = 0, found = 0;
- char *repo_config = NULL;
const char *home = NULL;
/* Setting $GIT_CONFIG makes git read _only_ the given config file. */
@@ -724,17 +723,27 @@ int git_config(config_fn_t fn, void *data)
free(user_config);
}
- repo_config = git_pathdup("config");
- if (!access(repo_config, R_OK)) {
+ if (repo_config && !access(repo_config, R_OK)) {
ret += git_config_from_file(fn, repo_config, data);
found += 1;
}
- free(repo_config);
if (found == 0)
return -1;
return ret;
}
+int git_config(config_fn_t fn, void *data)
+{
+ char *repo_config = NULL;
+ int ret;
+
+ repo_config = git_pathdup("config");
+ ret = git_config_early(fn, data, repo_config);
+ if (repo_config)
+ free(repo_config);
+ return ret;
+}
+
/*
* Find all the stuff for git_config_set() below.
*/
--
1.7.0.rc1.541.g2da82.dirty
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH 27/43] Use git_config_early() instead of git_config() during repo setup
2010-04-05 18:40 [PATCH 00/43] nd/setup update Nguyễn Thái Ngọc Duy
` (25 preceding siblings ...)
2010-04-05 18:41 ` [PATCH 26/43] Add git_config_early() Nguyễn Thái Ngọc Duy
@ 2010-04-05 18:41 ` Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 28/43] worktree setup: restore original state when things go wrong Nguyễn Thái Ngọc Duy
` (15 subsequent siblings)
42 siblings, 0 replies; 50+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-04-05 18:41 UTC (permalink / raw)
To: git, Junio C Hamano, Jonathan Niedier
Cc: Nguyễn Thái Ngọc Duy, Junio C Hamano
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
setup.c | 30 ++++++++++++++++++++++--------
1 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/setup.c b/setup.c
index 43a8609..2c1b64f 100644
--- a/setup.c
+++ b/setup.c
@@ -241,9 +241,21 @@ void setup_work_tree(void)
initialized = 1;
}
-static int check_repository_format_gently(int *nongit_ok)
+static int check_repository_format_gently(const char *gitdir, int *nongit_ok)
{
- git_config(check_repository_format_version, NULL);
+ char repo_config[PATH_MAX+1];
+
+ /*
+ * git_config() can't be used here because it calls git_pathdup()
+ * to get $GIT_CONFIG/config. That call will make setup_git_env()
+ * set git_dir to ".git".
+ *
+ * We are in gitdir setup, no git dir has been found useable yet.
+ * Use a gentler version of git_config() to check if this repo
+ * is a good one.
+ */
+ snprintf(repo_config, PATH_MAX, "%s/config", gitdir);
+ git_config_early(check_repository_format_version, NULL, repo_config);
if (GIT_REPO_VERSION < repository_format_version) {
if (!nongit_ok)
die ("Expected git repo version <= %d, found %d",
@@ -348,12 +360,12 @@ static const char *setup_git_directory_gently_1(int *nongit_ok)
if (!work_tree_env) {
retval = set_work_tree(gitdirenv);
/* config may override worktree */
- if (check_repository_format_gently(nongit_ok))
+ if (check_repository_format_gently(gitdirenv, nongit_ok))
return NULL;
set_git_dir(gitdirenv);
return retval;
}
- if (check_repository_format_gently(nongit_ok))
+ if (check_repository_format_gently(gitdirenv, nongit_ok))
return NULL;
retval = get_relative_cwd(buffer, sizeof(buffer) - 1,
get_git_work_tree());
@@ -403,6 +415,8 @@ static const char *setup_git_directory_gently_1(int *nongit_ok)
inside_git_dir = 0;
if (!work_tree_env)
inside_work_tree = 1;
+ if (check_repository_format_gently(gitfile_dir, nongit_ok))
+ return NULL;
root_len = offset_1st_component(cwd);
git_work_tree_cfg = xstrndup(cwd, offset > root_len ? offset : root_len);
break;
@@ -411,6 +425,8 @@ static const char *setup_git_directory_gently_1(int *nongit_ok)
inside_git_dir = 1;
if (!work_tree_env)
inside_work_tree = 0;
+ if (check_repository_format_gently(".", nongit_ok))
+ return NULL;
if (offset != len) {
root_len = offset_1st_component(cwd);
cwd[offset > root_len ? offset : root_len] = '\0';
@@ -433,8 +449,6 @@ static const char *setup_git_directory_gently_1(int *nongit_ok)
die_errno("Cannot change to '%s/..'", cwd);
}
- if (check_repository_format_gently(nongit_ok))
- return NULL;
if (offset == len)
return NULL;
@@ -542,7 +556,7 @@ char *enter_repo(char *path, int strict)
validate_headref("HEAD") == 0) {
inside_work_tree = 0;
inside_git_dir = 1;
- check_repository_format();
+ check_repository_format_gently(".", NULL);
set_git_dir(".");
if (startup_info) {
startup_info->prefix = NULL;
@@ -627,7 +641,7 @@ int check_repository_format_version(const char *var, const char *value, void *cb
int check_repository_format(void)
{
- return check_repository_format_gently(NULL);
+ return check_repository_format_gently(get_git_dir(), NULL);
}
const char *setup_git_directory(void)
--
1.7.0.rc1.541.g2da82.dirty
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH 28/43] worktree setup: restore original state when things go wrong
2010-04-05 18:40 [PATCH 00/43] nd/setup update Nguyễn Thái Ngọc Duy
` (26 preceding siblings ...)
2010-04-05 18:41 ` [PATCH 27/43] Use git_config_early() instead of git_config() during repo setup Nguyễn Thái Ngọc Duy
@ 2010-04-05 18:41 ` Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 29/43] init/clone: turn on startup->have_repository properly Nguyễn Thái Ngọc Duy
` (14 subsequent siblings)
42 siblings, 0 replies; 50+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-04-05 18:41 UTC (permalink / raw)
To: git, Junio C Hamano, Jonathan Niedier
Cc: Nguyễn Thái Ngọc Duy
In current state of setup_git_directory_gently(), when a repository is
not found, many things will not be the same as when setup procedure is
started (while they should be). For one thing, current working
directory will not be the same in certain cases.
This patch reorders actions in clear steps and rolls back if one step
is wrong. (Actually the last step, setting git_dir, can't be rolled
back by this patch).
The steps and their state change are:
1. Looking in working directory for repository candidates (or $GIT_DIR
if it is set)
This step may move $(cwd) to somewhere.
2. Set internal variables to record repository features, based only
on repository location and environment variables.
This step sets variables:
- inside_git_dir
- inside_work_tree
3. Inspect $GIT_DIR/config to see if it's a valid repository.
This step may change variables:
- repository_format_version
- shared_repository
- is_bare_repository_cfg
- git_work_tree_cfg
4. Save the repository location for later use.
This step calls setup_git_dir() to set many variables in environment.c
5. Calculate prefix (relative path to the original current working
directory)
Setup procedure is completed at step 5. Stopping at any other steps
is considered a setup failure.
In case of setup failure, if it's not fatal and nongit_ok is not NULL,
prefix must be calculated before returning to caller. In other words:
if (!fatal && gently)
goto step_5;
Things that go wrong before step 4 will be cleaned up by
unset_git_directory(). Step 4 is irreversible, for now.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
cache.h | 1 +
setup.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++----
2 files changed, 52 insertions(+), 4 deletions(-)
diff --git a/cache.h b/cache.h
index f4935b8..f53fb32 100644
--- a/cache.h
+++ b/cache.h
@@ -421,6 +421,7 @@ extern const char **get_pathspec(const char *prefix, const char **pathspec);
extern void setup_work_tree(void);
extern const char *setup_git_directory_gently(int *);
extern const char *setup_git_directory(void);
+extern void unset_git_directory(const char *prefix);
extern const char *prefix_path(const char *prefix, int len, const char *path);
extern const char *prefix_filename(const char *prefix, int len, const char *path);
extern int check_filename(const char *prefix, const char *name);
diff --git a/setup.c b/setup.c
index 2c1b64f..858cf6b 100644
--- a/setup.c
+++ b/setup.c
@@ -323,6 +323,42 @@ const char *read_gitfile_gently(const char *path)
return path;
}
+void unset_git_directory(const char *prefix)
+{
+ /*
+ * FIXME:
+ * chdir(prefix) may be enough for most of cases,
+ * if original cwd is outside worktree, prefix
+ * will always be set NULL, thus impossible to move
+ * back to orignal cwd
+ */
+ if (prefix && chdir(prefix))
+ die("Cannot change to '%s'", prefix);
+
+ if (startup_info) {
+ startup_info->prefix = NULL;
+ startup_info->have_repository = 0;
+ }
+
+ /* Initialized in setup_git_directory_gently_1() */
+ inside_work_tree = -1;
+ inside_git_dir = -1;
+
+ /* Initialized in check_repository_format_version() */
+ /*
+ * repository_format_version is zero for two reasons:
+ * - For really old repos, there won't be core.repositoryformatversion
+ * we treat it as supported version zero.
+ * - For repo creating commands like "git init" or "git clone"
+ * $GIT_DIR/config may not be there, just let it pass, the
+ * repository will be properly initialized later.
+ * For history of this setting see commits 4f62953 and 96f1e58
+ */
+ repository_format_version = 0;
+ shared_repository = PERM_UMASK;
+ is_bare_repository_cfg = -1;
+ git_work_tree_cfg = NULL;
+}
/*
* 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.
@@ -403,6 +439,13 @@ static const char *setup_git_directory_gently_1(int *nongit_ok)
* - ../ (bare)
* - ../../.git/
* etc.
+ *
+ * When a repository is found:
+ * - inside_git_dir/inside_work_tree are set
+ * - check_repository_format_gently() is called
+ * if repo version is not supported, restore cwd
+ * - set_git_dir
+ * - calculate and return prefix
*/
offset = len = strlen(cwd);
for (;;) {
@@ -410,13 +453,15 @@ static const char *setup_git_directory_gently_1(int *nongit_ok)
if (!gitfile_dir && is_git_directory(DEFAULT_GIT_DIR_ENVIRONMENT))
gitfile_dir = DEFAULT_GIT_DIR_ENVIRONMENT;
if (gitfile_dir) {
- if (set_git_dir(gitfile_dir))
- die("Repository setup failed");
inside_git_dir = 0;
if (!work_tree_env)
inside_work_tree = 1;
- if (check_repository_format_gently(gitfile_dir, nongit_ok))
+ if (check_repository_format_gently(gitfile_dir, nongit_ok)) {
+ unset_git_directory(offset != len ? cwd + offset + 1: NULL);
return NULL;
+ }
+ if (set_git_dir(gitfile_dir))
+ die("Repository setup failed");
root_len = offset_1st_component(cwd);
git_work_tree_cfg = xstrndup(cwd, offset > root_len ? offset : root_len);
break;
@@ -425,8 +470,10 @@ static const char *setup_git_directory_gently_1(int *nongit_ok)
inside_git_dir = 1;
if (!work_tree_env)
inside_work_tree = 0;
- if (check_repository_format_gently(".", nongit_ok))
+ if (check_repository_format_gently(".", nongit_ok)) {
+ unset_git_directory(offset != len ? cwd + offset + 1: NULL);
return NULL;
+ }
if (offset != len) {
root_len = offset_1st_component(cwd);
cwd[offset > root_len ? offset : root_len] = '\0';
--
1.7.0.rc1.541.g2da82.dirty
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH 29/43] init/clone: turn on startup->have_repository properly
2010-04-05 18:40 [PATCH 00/43] nd/setup update Nguyễn Thái Ngọc Duy
` (27 preceding siblings ...)
2010-04-05 18:41 ` [PATCH 28/43] worktree setup: restore original state when things go wrong Nguyễn Thái Ngọc Duy
@ 2010-04-05 18:41 ` Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 30/43] git_config(): do not read .git/config if there is no repository Nguyễn Thái Ngọc Duy
` (13 subsequent siblings)
42 siblings, 0 replies; 50+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-04-05 18:41 UTC (permalink / raw)
To: git, Junio C Hamano, Jonathan Niedier
Cc: Nguyễn Thái Ngọc Duy, Junio C Hamano
With startup_info != NULL, many code path may be disabled, depending
on repo setup. Also move set_git_dir() closer to have_repository
assignment to make it clear about repo setup.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
builtin/clone.c | 3 +--
builtin/init-db.c | 9 +++++----
cache.h | 2 +-
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/builtin/clone.c b/builtin/clone.c
index 05f8fb4..3badb44 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -459,9 +459,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
if (safe_create_leading_directories_const(git_dir) < 0)
die("could not create leading directories of '%s'", git_dir);
- set_git_dir(make_absolute_path(git_dir));
- init_db(option_template, (option_verbosity < 0) ? INIT_DB_QUIET : 0);
+ init_db(git_dir, option_template, (option_verbosity < 0) ? INIT_DB_QUIET : 0);
/*
* At this point, the config exists, so we do not need the
diff --git a/builtin/init-db.c b/builtin/init-db.c
index edc40ff..064b919 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -294,12 +294,15 @@ static int create_default_files(const char *template_path)
return reinit;
}
-int init_db(const char *template_dir, unsigned int flags)
+int init_db(const char *git_dir, const char *template_dir, unsigned int flags)
{
const char *sha1_dir;
char *path;
int len, reinit;
+ set_git_dir(make_absolute_path(git_dir));
+ startup_info->have_repository = 1;
+
safe_create_dir(get_git_dir(), 0);
init_is_bare_repository = is_bare_repository();
@@ -509,7 +512,5 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
get_git_work_tree());
}
- set_git_dir(make_absolute_path(git_dir));
-
- return init_db(template_dir, flags);
+ return init_db(git_dir, template_dir, flags);
}
diff --git a/cache.h b/cache.h
index f53fb32..2980741 100644
--- a/cache.h
+++ b/cache.h
@@ -430,7 +430,7 @@ extern void verify_non_filename(const char *prefix, const char *name);
#define INIT_DB_QUIET 0x0001
-extern int init_db(const char *template_dir, unsigned int flags);
+extern int init_db(const char *git_dir, const char *template_dir, unsigned int flags);
#define alloc_nr(x) (((x)+16)*3/2)
--
1.7.0.rc1.541.g2da82.dirty
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH 30/43] git_config(): do not read .git/config if there is no repository
2010-04-05 18:40 [PATCH 00/43] nd/setup update Nguyễn Thái Ngọc Duy
` (28 preceding siblings ...)
2010-04-05 18:41 ` [PATCH 29/43] init/clone: turn on startup->have_repository properly Nguyễn Thái Ngọc Duy
@ 2010-04-05 18:41 ` Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 31/43] Do not read .git/info/exclude " Nguyễn Thái Ngọc Duy
` (12 subsequent siblings)
42 siblings, 0 replies; 50+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-04-05 18:41 UTC (permalink / raw)
To: git, Junio C Hamano, Jonathan Niedier
Cc: Nguyễn Thái Ngọc Duy, Junio C Hamano
If no repository is found, do not bother calling git_pathdup(). If a
command forgets to call setup_git_directory*() or enter_repo(),
$GIT_DIR/config will be missed, though.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
config.c | 3 ++-
t/t1300-repo-config.sh | 13 +++++++++++++
2 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/config.c b/config.c
index 2d38096..07d854a 100644
--- a/config.c
+++ b/config.c
@@ -737,7 +737,8 @@ int git_config(config_fn_t fn, void *data)
char *repo_config = NULL;
int ret;
- repo_config = git_pathdup("config");
+ if (!startup_info || startup_info->have_repository)
+ repo_config = git_pathdup("config");
ret = git_config_early(fn, data, repo_config);
if (repo_config)
free(repo_config);
diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh
index f11f98c..cfb70e2 100755
--- a/t/t1300-repo-config.sh
+++ b/t/t1300-repo-config.sh
@@ -824,4 +824,17 @@ test_expect_success 'check split_cmdline return' "
test_must_fail git merge master
"
+test_expect_success 'skip .git/config if there is no repository' '
+ (
+ mkdir -p a/b/.git &&
+ cd a &&
+ GIT_CEILING_DIRECTORIES="`pwd`" &&
+ export GIT_CEILING_DIRECTORIES &&
+ cd b &&
+ echo "[core]" > .git/config &&
+ echo "wrong = true" >> .git/config &&
+ test -z "$(git var -l | grep core.wrong)"
+ )
+'
+
test_done
--
1.7.0.rc1.541.g2da82.dirty
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH 31/43] Do not read .git/info/exclude if there is no repository
2010-04-05 18:40 [PATCH 00/43] nd/setup update Nguyễn Thái Ngọc Duy
` (29 preceding siblings ...)
2010-04-05 18:41 ` [PATCH 30/43] git_config(): do not read .git/config if there is no repository Nguyễn Thái Ngọc Duy
@ 2010-04-05 18:41 ` Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 32/43] Do not read .git/info/attributes " Nguyễn Thái Ngọc Duy
` (11 subsequent siblings)
42 siblings, 0 replies; 50+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-04-05 18:41 UTC (permalink / raw)
To: git, Junio C Hamano, Jonathan Niedier
Cc: Nguyễn Thái Ngọc Duy, Junio C Hamano
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
dir.c | 8 +++++---
t/t7002-grep.sh | 24 ++++++++++++++++++++++++
2 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/dir.c b/dir.c
index cb83332..0bd5d9f 100644
--- a/dir.c
+++ b/dir.c
@@ -1040,9 +1040,11 @@ void setup_standard_excludes(struct dir_struct *dir)
const char *path;
dir->exclude_per_dir = ".gitignore";
- path = git_path("info/exclude");
- if (!access(path, R_OK))
- add_excludes_from_file(dir, path);
+ if (!startup_info || startup_info->have_repository) {
+ path = git_path("info/exclude");
+ if (!access(path, R_OK))
+ add_excludes_from_file(dir, path);
+ }
if (excludes_file && !access(excludes_file, R_OK))
add_excludes_from_file(dir, excludes_file);
}
diff --git a/t/t7002-grep.sh b/t/t7002-grep.sh
index e249c3e..06ec4cb 100755
--- a/t/t7002-grep.sh
+++ b/t/t7002-grep.sh
@@ -527,4 +527,28 @@ test_expect_success 'grep -e -- -- path' '
test_cmp expected actual
'
+test_expect_success 'Setup fake .git' '
+ cd t &&
+ GIT_CEILING_DIRECTORIES="`pwd`" &&
+ export GIT_CEILING_DIRECTORIES &&
+ cd a &&
+ mkdir -p .git/info &&
+ cd ../..
+
+'
+
+test_expect_success 'Ignore fake .git/info/exclude' '
+ (
+ cd t/a &&
+ echo v > .git/info/exclude &&
+ git grep --no-index vvv . &&
+ rm .git/info/exclude
+ )
+'
+
+test_expect_success 'Unsetup fake .git' '
+ rm -rf t/a &&
+ unset GIT_CEILING_DIRECTORIES
+'
+
test_done
--
1.7.0.rc1.541.g2da82.dirty
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH 32/43] Do not read .git/info/attributes if there is no repository
2010-04-05 18:40 [PATCH 00/43] nd/setup update Nguyễn Thái Ngọc Duy
` (30 preceding siblings ...)
2010-04-05 18:41 ` [PATCH 31/43] Do not read .git/info/exclude " Nguyễn Thái Ngọc Duy
@ 2010-04-05 18:41 ` Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 33/43] apply: do not check sha1 " Nguyễn Thái Ngọc Duy
` (10 subsequent siblings)
42 siblings, 0 replies; 50+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-04-05 18:41 UTC (permalink / raw)
To: git, Junio C Hamano, Jonathan Niedier
Cc: Nguyễn Thái Ngọc Duy, Junio C Hamano
This one is difficult to demonstrate by tests. So I'll describe the
call flow instead.
Say we do "git grep --no-index --show-function foo -- bar" in no
repository. The call flow would be:
- ...
- cmd_grep
- grep_directory
- grep_file
- grep_buffer
- grep_buffer_1
- userdiff_find_by_path
- git_checkattr("diff")
- bootstrap_attr_stack
- git_path("info/attributes")
Because no repository is found, git_dir in environment.c would be
NULL. When it reaches git_path("info/attributes"), it will
automatically set git_dir to ".git". If we have $(cwd)/.git/info/attributes
then that file will be read, no matter $(cwd)/.git is a valid
repository.
This bug is hard to be exposed, because after git_checkattr("diff")
finds something (wrong). It will look up for diff drivers from
.git/config. If we do thing correctly, .git/config will not be read,
thus no diff drivers, no visible impact. If .git/config is read,
git_dir must be set already, all this would not happen.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
attr.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/attr.c b/attr.c
index f5346ed..f1362de 100644
--- a/attr.c
+++ b/attr.c
@@ -480,7 +480,10 @@ static void bootstrap_attr_stack(void)
debug_push(elem);
}
- elem = read_attr_from_file(git_path(INFOATTRIBUTES_FILE), 1);
+ if (!startup_info || startup_info->have_repository)
+ elem = read_attr_from_file(git_path(INFOATTRIBUTES_FILE), 1);
+ else
+ elem = NULL;
if (!elem)
elem = xcalloc(1, sizeof(*elem));
elem->origin = NULL;
--
1.7.0.rc1.541.g2da82.dirty
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH 33/43] apply: do not check sha1 if there is no repository
2010-04-05 18:40 [PATCH 00/43] nd/setup update Nguyễn Thái Ngọc Duy
` (31 preceding siblings ...)
2010-04-05 18:41 ` [PATCH 32/43] Do not read .git/info/attributes " Nguyễn Thái Ngọc Duy
@ 2010-04-05 18:41 ` Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 34/43] config: do not read .git/config " Nguyễn Thái Ngọc Duy
` (9 subsequent siblings)
42 siblings, 0 replies; 50+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-04-05 18:41 UTC (permalink / raw)
To: git, Junio C Hamano, Jonathan Niedier
Cc: Nguyễn Thái Ngọc Duy, Junio C Hamano
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
builtin/apply.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/builtin/apply.c b/builtin/apply.c
index bb957d4..0f269aa 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -2546,7 +2546,7 @@ static int apply_binary(struct image *img, struct patch *patch)
return 0; /* deletion patch */
}
- if (has_sha1_file(sha1)) {
+ if (startup_info->have_repository && has_sha1_file(sha1)) {
/* We already have the postimage */
enum object_type type;
unsigned long size;
--
1.7.0.rc1.541.g2da82.dirty
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH 34/43] config: do not read .git/config if there is no repository
2010-04-05 18:40 [PATCH 00/43] nd/setup update Nguyễn Thái Ngọc Duy
` (32 preceding siblings ...)
2010-04-05 18:41 ` [PATCH 33/43] apply: do not check sha1 " Nguyễn Thái Ngọc Duy
@ 2010-04-05 18:41 ` Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 35/43] run_builtin(): save "-h" detection result for later use Nguyễn Thái Ngọc Duy
` (8 subsequent siblings)
42 siblings, 0 replies; 50+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-04-05 18:41 UTC (permalink / raw)
To: git, Junio C Hamano, Jonathan Niedier
Cc: Nguyễn Thái Ngọc Duy, Junio C Hamano
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
builtin/config.c | 9 ++++++---
t/t1300-repo-config.sh | 3 ++-
t/t1302-repo-version.sh | 2 +-
3 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/builtin/config.c b/builtin/config.c
index ecc8f87..3fca3b4 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -159,7 +159,8 @@ static int get_value(const char *key_, const char *regex_)
local = config_exclusive_filename;
if (!local) {
const char *home = getenv("HOME");
- local = repo_config = git_pathdup("config");
+ if (startup_info->have_repository)
+ local = repo_config = git_pathdup("config");
if (git_config_global() && home)
global = xstrdup(mkpath("%s/.gitconfig", home));
if (git_config_system())
@@ -197,7 +198,8 @@ static int get_value(const char *key_, const char *regex_)
git_config_from_file(show_config, system_wide, NULL);
if (do_all && global)
git_config_from_file(show_config, global, NULL);
- git_config_from_file(show_config, local, NULL);
+ if (local)
+ git_config_from_file(show_config, local, NULL);
if (!do_all && !seen && global)
git_config_from_file(show_config, global, NULL);
if (!do_all && !seen && system_wide)
@@ -215,7 +217,8 @@ static int get_value(const char *key_, const char *regex_)
ret = (seen == 1) ? 0 : seen > 1 ? 2 : 1;
free_strings:
- free(repo_config);
+ if (repo_config)
+ free(repo_config);
free(global);
return ret;
}
diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh
index cfb70e2..b040f72 100755
--- a/t/t1300-repo-config.sh
+++ b/t/t1300-repo-config.sh
@@ -833,7 +833,8 @@ test_expect_success 'skip .git/config if there is no repository' '
cd b &&
echo "[core]" > .git/config &&
echo "wrong = true" >> .git/config &&
- test -z "$(git var -l | grep core.wrong)"
+ test -z "$(git var -l | grep core.wrong)" &&
+ test -z "$(git config --bool core.wrong)"
)
'
diff --git a/t/t1302-repo-version.sh b/t/t1302-repo-version.sh
index 8d305b4..74bf51f 100755
--- a/t/t1302-repo-version.sh
+++ b/t/t1302-repo-version.sh
@@ -29,7 +29,7 @@ test_expect_success 'gitdir selection on normal repos' '
# Make sure it would stop at test2, not trash
test_expect_success 'gitdir selection on unsupported repo' '
(cd test2 &&
- test "$(git config core.repositoryformatversion)" = 99)'
+ test "$(git config --file=.git/config core.repositoryformatversion)" = 99)'
test_expect_success 'gitdir not required mode' '
(git apply --stat test.patch &&
--
1.7.0.rc1.541.g2da82.dirty
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH 35/43] run_builtin(): save "-h" detection result for later use
2010-04-05 18:40 [PATCH 00/43] nd/setup update Nguyễn Thái Ngọc Duy
` (33 preceding siblings ...)
2010-04-05 18:41 ` [PATCH 34/43] config: do not read .git/config " Nguyễn Thái Ngọc Duy
@ 2010-04-05 18:41 ` Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 36/43] builtins: utilize startup_info->help where possible Nguyễn Thái Ngọc Duy
` (7 subsequent siblings)
42 siblings, 0 replies; 50+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-04-05 18:41 UTC (permalink / raw)
To: git, Junio C Hamano, Jonathan Niedier
Cc: Nguyễn Thái Ngọc Duy, Junio C Hamano
When run_builtin() sees "-h" as the first argument, it assumes that:
- it's the call for help usage
- the real git command will only print help usage then exit
So it skips all setup in this case. Unfortunately some commands may do
more things before calling parse_options(), which is where help usage
is printed. Some of those things may touch repository, which has yet
to be set up.
Until now, the only safe thing that can be called before
parse_options() is git_config(). This function is aware of repository
findind status, and will skip reading $GIT_DIR/config if no repository
is found.
Make real commands aware of this fast path so that they can handle it
properly (i.e. print help usage then exist immediately) if they do
more initialization than git_config().
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
cache.h | 1 +
git.c | 8 ++++----
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/cache.h b/cache.h
index 2980741..bdcd1ec 100644
--- a/cache.h
+++ b/cache.h
@@ -1067,6 +1067,7 @@ int checkout_fast_forward(const unsigned char *from, const unsigned char *to);
struct startup_info {
const char *prefix;
int have_repository;
+ int help;
};
extern struct startup_info *startup_info;
diff --git a/git.c b/git.c
index fac3d1c..d60f792 100644
--- a/git.c
+++ b/git.c
@@ -237,13 +237,13 @@ struct cmd_struct {
static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
{
- int status, help;
+ int status;
struct stat st;
memset(&git_startup_info, 0, sizeof(git_startup_info));
startup_info = &git_startup_info;
- help = argc == 2 && !strcmp(argv[1], "-h");
- if (!help) {
+ startup_info->help = argc == 2 && !strcmp(argv[1], "-h");
+ if (!startup_info->help) {
if (p->option & RUN_SETUP)
setup_git_directory();
if (p->option & RUN_SETUP_GENTLY) {
@@ -261,7 +261,7 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
}
commit_pager_choice();
- if (!help && p->option & NEED_WORK_TREE)
+ if (!startup_info->help && p->option & NEED_WORK_TREE)
setup_work_tree();
trace_argv_printf(argv, "trace: built-in: git");
--
1.7.0.rc1.541.g2da82.dirty
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH 36/43] builtins: utilize startup_info->help where possible
2010-04-05 18:40 [PATCH 00/43] nd/setup update Nguyễn Thái Ngọc Duy
` (34 preceding siblings ...)
2010-04-05 18:41 ` [PATCH 35/43] run_builtin(): save "-h" detection result for later use Nguyễn Thái Ngọc Duy
@ 2010-04-05 18:41 ` Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 37/43] builtins: check for startup_info->help, print and exit early Nguyễn Thái Ngọc Duy
` (6 subsequent siblings)
42 siblings, 0 replies; 50+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-04-05 18:41 UTC (permalink / raw)
To: git, Junio C Hamano, Jonathan Niedier
Cc: Nguyễn Thái Ngọc Duy, Junio C Hamano
It helps reduce false alarms while I'm looking for "git foo -h" code
path that accesses repository. Anyway it looks like a good thing to
do.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
builtin/check-ref-format.c | 2 +-
builtin/grep.c | 2 +-
builtin/index-pack.c | 2 +-
builtin/log.c | 6 +-----
builtin/merge-ours.c | 2 +-
builtin/pack-redundant.c | 2 +-
builtin/show-ref.c | 2 +-
7 files changed, 7 insertions(+), 11 deletions(-)
diff --git a/builtin/check-ref-format.c b/builtin/check-ref-format.c
index b106c65..c13f90a 100644
--- a/builtin/check-ref-format.c
+++ b/builtin/check-ref-format.c
@@ -35,7 +35,7 @@ static void collapse_slashes(char *dst, const char *src)
int cmd_check_ref_format(int argc, const char **argv, const char *prefix)
{
- if (argc == 2 && !strcmp(argv[1], "-h"))
+ if (startup_info->help)
usage(builtin_check_ref_format_usage);
if (argc == 3 && !strcmp(argv[1], "--branch")) {
diff --git a/builtin/grep.c b/builtin/grep.c
index a4ea0c9..7b5e416 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -871,7 +871,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
* 'git grep -h', unlike 'git grep -h <pattern>', is a request
* to show usage information and exit.
*/
- if (argc == 2 && !strcmp(argv[1], "-h"))
+ if (startup_info->help)
usage_with_options(grep_usage, options);
memset(&opt, 0, sizeof(opt));
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index 9aa6a13..44375a2 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -880,7 +880,7 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
struct pack_idx_entry **idx_objects;
unsigned char pack_sha1[20];
- if (argc == 2 && !strcmp(argv[1], "-h"))
+ if (startup_info->help)
usage(index_pack_usage);
/*
diff --git a/builtin/log.c b/builtin/log.c
index 542ecc7..294402b 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -50,11 +50,7 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,
if (default_date_mode)
rev->date_mode = parse_date_format(default_date_mode);
- /*
- * Check for -h before setup_revisions(), or "git log -h" will
- * fail when run without a git directory.
- */
- if (argc == 2 && !strcmp(argv[1], "-h"))
+ if (startup_info->help)
usage(builtin_log_usage);
argc = setup_revisions(argc, argv, rev, opt);
diff --git a/builtin/merge-ours.c b/builtin/merge-ours.c
index 6844116..8e0777b 100644
--- a/builtin/merge-ours.c
+++ b/builtin/merge-ours.c
@@ -20,7 +20,7 @@ static const char *diff_index_args[] = {
int cmd_merge_ours(int argc, const char **argv, const char *prefix)
{
- if (argc == 2 && !strcmp(argv[1], "-h"))
+ if (startup_info->help)
usage(builtin_merge_ours_usage);
/*
diff --git a/builtin/pack-redundant.c b/builtin/pack-redundant.c
index 41e1615..3f090b2 100644
--- a/builtin/pack-redundant.c
+++ b/builtin/pack-redundant.c
@@ -601,7 +601,7 @@ int cmd_pack_redundant(int argc, const char **argv, const char *prefix)
unsigned char *sha1;
char buf[42]; /* 40 byte sha1 + \n + \0 */
- if (argc == 2 && !strcmp(argv[1], "-h"))
+ if (startup_info->help)
usage(pack_redundant_usage);
for (i = 1; i < argc; i++) {
diff --git a/builtin/show-ref.c b/builtin/show-ref.c
index 17ada88..59f90df 100644
--- a/builtin/show-ref.c
+++ b/builtin/show-ref.c
@@ -204,7 +204,7 @@ static const struct option show_ref_options[] = {
int cmd_show_ref(int argc, const char **argv, const char *prefix)
{
- if (argc == 2 && !strcmp(argv[1], "-h"))
+ if (startup_info->help)
usage_with_options(show_ref_usage, show_ref_options);
argc = parse_options(argc, argv, prefix, show_ref_options,
--
1.7.0.rc1.541.g2da82.dirty
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH 37/43] builtins: check for startup_info->help, print and exit early
2010-04-05 18:40 [PATCH 00/43] nd/setup update Nguyễn Thái Ngọc Duy
` (35 preceding siblings ...)
2010-04-05 18:41 ` [PATCH 36/43] builtins: utilize startup_info->help where possible Nguyễn Thái Ngọc Duy
@ 2010-04-05 18:41 ` Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 38/43] Allow to undo setup_git_directory_gently() gracefully (and fix alias code) Nguyễn Thái Ngọc Duy
` (5 subsequent siblings)
42 siblings, 0 replies; 50+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-04-05 18:41 UTC (permalink / raw)
To: git, Junio C Hamano, Jonathan Niedier
Cc: Nguyễn Thái Ngọc Duy, Junio C Hamano
These commands need more than just git_config() before parsing
commmand line arguments. Some of these activities will unconditionally
look into a repository. When startup_info->help is TRUE, no repository
is set up and the caller expects callees to print help usage and exit,
no more.
Do as expected.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
builtin/branch.c | 3 +++
builtin/checkout-index.c | 3 +++
builtin/commit.c | 6 ++++++
builtin/gc.c | 3 +++
builtin/ls-files.c | 3 +++
builtin/merge.c | 3 +++
builtin/update-index.c | 3 +++
builtin/upload-archive.c | 7 ++++---
8 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/builtin/branch.c b/builtin/branch.c
index 6cf7e72..cc0053b 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -651,6 +651,9 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
OPT_END(),
};
+ if (startup_info->help)
+ usage_with_options(builtin_branch_usage, options);
+
git_config(git_branch_config, NULL);
if (branch_use_color == -1)
diff --git a/builtin/checkout-index.c b/builtin/checkout-index.c
index a7a5ee1..7f25cd7 100644
--- a/builtin/checkout-index.c
+++ b/builtin/checkout-index.c
@@ -241,6 +241,9 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)
OPT_END()
};
+ if (startup_info->help)
+ usage_with_options(builtin_checkout_index_usage, builtin_checkout_index_options);
+
git_config(git_default_config, NULL);
state.base_dir = "";
prefix_length = prefix ? strlen(prefix) : 0;
diff --git a/builtin/commit.c b/builtin/commit.c
index c5ab683..bccbbef 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -1034,6 +1034,9 @@ int cmd_status(int argc, const char **argv, const char *prefix)
OPT_END(),
};
+ if (startup_info->help)
+ usage_with_options(builtin_status_usage, builtin_status_options);
+
if (null_termination && status_format == STATUS_FORMAT_LONG)
status_format = STATUS_FORMAT_PORCELAIN;
@@ -1208,6 +1211,9 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
int allow_fast_forward = 1;
struct wt_status s;
+ if (startup_info->help)
+ usage_with_options(builtin_commit_usage, builtin_commit_options);
+
wt_status_prepare(&s);
git_config(git_commit_config, &s);
in_merge = file_exists(git_path("MERGE_HEAD"));
diff --git a/builtin/gc.c b/builtin/gc.c
index c304638..f040171 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -191,6 +191,9 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
git_config(gc_config, NULL);
+ if (startup_info->help)
+ usage_with_options(builtin_gc_usage, builtin_gc_options);
+
if (pack_refs < 0)
pack_refs = !is_bare_repository();
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index b065061..5125560 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -518,6 +518,9 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)
OPT_END()
};
+ if (startup_info->help)
+ usage_with_options(ls_files_usage, builtin_ls_files_options);
+
memset(&dir, 0, sizeof(dir));
if (prefix)
prefix_offset = strlen(prefix);
diff --git a/builtin/merge.c b/builtin/merge.c
index c043066..3cced9e 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -886,6 +886,9 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
const char *best_strategy = NULL, *wt_strategy = NULL;
struct commit_list **remotes = &remoteheads;
+ if (startup_info->help)
+ usage_with_options(builtin_merge_usage, builtin_merge_options);
+
if (read_cache_unmerged()) {
die_resolve_conflict("merge");
}
diff --git a/builtin/update-index.c b/builtin/update-index.c
index 3ab214d..46a53f5 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -589,6 +589,9 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
int lock_error = 0;
struct lock_file *lock_file;
+ if (startup_info->help)
+ usage(update_index_usage);
+
git_config(git_default_config, NULL);
/* We can't free this memory, it becomes part of a linked list parsed atexit() */
diff --git a/builtin/upload-archive.c b/builtin/upload-archive.c
index 73f788e..d4f4741 100644
--- a/builtin/upload-archive.c
+++ b/builtin/upload-archive.c
@@ -26,9 +26,6 @@ static int run_upload_archive(int argc, const char **argv, const char *prefix)
int sent_argc;
int len;
- if (argc != 2)
- usage(upload_archive_usage);
-
if (strlen(argv[1]) + 1 > sizeof(buf))
die("insanely long repository name");
@@ -98,6 +95,10 @@ int cmd_upload_archive(int argc, const char **argv, const char *prefix)
{
pid_t writer;
int fd1[2], fd2[2];
+
+ if (startup_info->help || argc != 2)
+ usage(upload_archive_usage);
+
/*
* Set up sideband subprocess.
*
--
1.7.0.rc1.541.g2da82.dirty
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH 38/43] Allow to undo setup_git_directory_gently() gracefully (and fix alias code)
2010-04-05 18:40 [PATCH 00/43] nd/setup update Nguyễn Thái Ngọc Duy
` (36 preceding siblings ...)
2010-04-05 18:41 ` [PATCH 37/43] builtins: check for startup_info->help, print and exit early Nguyễn Thái Ngọc Duy
@ 2010-04-05 18:41 ` Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 39/43] alias: keep repository found while collecting aliases as long as possible Nguyễn Thái Ngọc Duy
` (4 subsequent siblings)
42 siblings, 0 replies; 50+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-04-05 18:41 UTC (permalink / raw)
To: git, Junio C Hamano, Jonathan Niedier
Cc: Nguyễn Thái Ngọc Duy, Junio C Hamano
unset_git_directory() can only clean up things as long as
set_git_dir() has not been called because set_git_dir() sets internal
state itself. Even worse, set_git_dir() may override $GIT_DIR env
variable.
Add unset_git_env() to undo set_git_dir(), allow unset_git_directory()
to undo a succesful setup_git_directory_gently().
While at there, fix alias handling code regarding git_dir {,un-}setup,
use unset_git_directory() instead of just chdir() back.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
cache.h | 1 +
environment.c | 20 ++++++++++++++++++++
git.c | 11 +++++------
setup.c | 2 ++
4 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/cache.h b/cache.h
index bdcd1ec..137edac 100644
--- a/cache.h
+++ b/cache.h
@@ -422,6 +422,7 @@ extern void setup_work_tree(void);
extern const char *setup_git_directory_gently(int *);
extern const char *setup_git_directory(void);
extern void unset_git_directory(const char *prefix);
+extern void unset_git_env();
extern const char *prefix_path(const char *prefix, int len, const char *path);
extern const char *prefix_filename(const char *prefix, int len, const char *path);
extern int check_filename(const char *prefix, const char *name);
diff --git a/environment.c b/environment.c
index c36c902..6127025 100644
--- a/environment.c
+++ b/environment.c
@@ -62,6 +62,7 @@ char *git_work_tree_cfg;
static char *work_tree;
static const char *git_dir;
+static const char *original_git_dir;
static char *git_object_dir, *git_index_file, *git_refs_dir, *git_graft_file;
/*
@@ -81,6 +82,20 @@ const char * const local_repo_env[LOCAL_REPO_ENV_SIZE + 1] = {
NULL
};
+void unset_git_env(void)
+{
+ git_dir = NULL;
+ if (original_git_dir)
+ setenv(GIT_DIR_ENVIRONMENT, original_git_dir, 1);
+ else
+ unsetenv(GIT_DIR_ENVIRONMENT);
+ git_object_dir = NULL;
+ git_refs_dir = NULL;
+ git_index_file = NULL;
+ git_graft_file = NULL;
+ read_replace_refs = 1;
+}
+
static void setup_git_env(void)
{
git_dir = getenv(GIT_DIR_ENVIRONMENT);
@@ -184,6 +199,11 @@ char *get_graft_file(void)
int set_git_dir(const char *path)
{
+ static int original_git_dir_set = 0;
+ if (!original_git_dir_set) {
+ original_git_dir = getenv(GIT_DIR_ENVIRONMENT);
+ original_git_dir_set = 1;
+ }
if (setenv(GIT_DIR_ENVIRONMENT, path, 1))
return error("Could not set GIT_DIR to '%s'", path);
setup_git_env();
diff --git a/git.c b/git.c
index d60f792..17482dd 100644
--- a/git.c
+++ b/git.c
@@ -146,14 +146,13 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
static int handle_alias(int *argcp, const char ***argv)
{
int envchanged = 0, ret = 0, saved_errno = errno;
- const char *subdir;
int count, option_count;
const char **new_argv;
const char *alias_command;
char *alias_string;
int unused_nongit;
- subdir = setup_git_directory_gently(&unused_nongit);
+ setup_git_directory_gently(&unused_nongit);
alias_command = (*argv)[0];
alias_string = alias_lookup(alias_command);
@@ -210,8 +209,7 @@ static int handle_alias(int *argcp, const char ***argv)
ret = 1;
}
- if (subdir && chdir(subdir))
- die_errno("Cannot change to '%s'", subdir);
+ unset_git_directory(startup_info->prefix);
errno = saved_errno;
@@ -240,8 +238,6 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
int status;
struct stat st;
- memset(&git_startup_info, 0, sizeof(git_startup_info));
- startup_info = &git_startup_info;
startup_info->help = argc == 2 && !strcmp(argv[1], "-h");
if (!startup_info->help) {
if (p->option & RUN_SETUP)
@@ -486,6 +482,9 @@ int main(int argc, const char **argv)
{
const char *cmd;
+ memset(&git_startup_info, 0, sizeof(git_startup_info));
+ startup_info = &git_startup_info;
+
cmd = git_extract_argv0_path(argv[0]);
if (!cmd)
cmd = "git-help";
diff --git a/setup.c b/setup.c
index 858cf6b..b0269aa 100644
--- a/setup.c
+++ b/setup.c
@@ -336,6 +336,8 @@ void unset_git_directory(const char *prefix)
die("Cannot change to '%s'", prefix);
if (startup_info) {
+ if (startup_info->have_repository)
+ unset_git_env();
startup_info->prefix = NULL;
startup_info->have_repository = 0;
}
--
1.7.0.rc1.541.g2da82.dirty
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH 39/43] alias: keep repository found while collecting aliases as long as possible
2010-04-05 18:40 [PATCH 00/43] nd/setup update Nguyễn Thái Ngọc Duy
` (37 preceding siblings ...)
2010-04-05 18:41 ` [PATCH 38/43] Allow to undo setup_git_directory_gently() gracefully (and fix alias code) Nguyễn Thái Ngọc Duy
@ 2010-04-05 18:41 ` Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 40/43] Guard unallowed access to repository when it's not set up Nguyễn Thái Ngọc Duy
` (3 subsequent siblings)
42 siblings, 0 replies; 50+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-04-05 18:41 UTC (permalink / raw)
To: git, Junio C Hamano, Jonathan Niedier
Cc: Nguyễn Thái Ngọc Duy, Junio C Hamano
Given that about 80% builtin commands will need to search for a
repository, we should keep the repository found in alias handling
code. Until we are clear there's no need for a repository, then we can
undo the setup with unset_git_directory().
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
git.c | 15 ++++++++++-----
1 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/git.c b/git.c
index 17482dd..d6513f1 100644
--- a/git.c
+++ b/git.c
@@ -152,7 +152,8 @@ static int handle_alias(int *argcp, const char ***argv)
char *alias_string;
int unused_nongit;
- setup_git_directory_gently(&unused_nongit);
+ if (!startup_info->have_repository)
+ setup_git_directory_gently(&unused_nongit);
alias_command = (*argv)[0];
alias_string = alias_lookup(alias_command);
@@ -209,8 +210,6 @@ static int handle_alias(int *argcp, const char ***argv)
ret = 1;
}
- unset_git_directory(startup_info->prefix);
-
errno = saved_errno;
return ret;
@@ -240,12 +239,18 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
startup_info->help = argc == 2 && !strcmp(argv[1], "-h");
if (!startup_info->help) {
- if (p->option & RUN_SETUP)
+ if ((p->option & RUN_SETUP) && !startup_info->have_repository)
setup_git_directory();
- if (p->option & RUN_SETUP_GENTLY) {
+ else if ((p->option & RUN_SETUP_GENTLY) && !startup_info->have_repository) {
int nongit_ok;
setup_git_directory_gently(&nongit_ok);
}
+ else if (startup_info->have_repository) {
+ if (p->option & (RUN_SETUP_GENTLY | RUN_SETUP))
+ ; /* done already */
+ else
+ unset_git_directory(startup_info->prefix);
+ }
if (use_pager == -1 && p->option & RUN_SETUP)
use_pager = check_pager_config(p->cmd);
--
1.7.0.rc1.541.g2da82.dirty
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH 40/43] Guard unallowed access to repository when it's not set up
2010-04-05 18:40 [PATCH 00/43] nd/setup update Nguyễn Thái Ngọc Duy
` (38 preceding siblings ...)
2010-04-05 18:41 ` [PATCH 39/43] alias: keep repository found while collecting aliases as long as possible Nguyễn Thái Ngọc Duy
@ 2010-04-05 18:41 ` Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 41/43] t0001: Add test cases for "git init" with aliases Nguyễn Thái Ngọc Duy
` (2 subsequent siblings)
42 siblings, 0 replies; 50+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-04-05 18:41 UTC (permalink / raw)
To: git, Junio C Hamano, Jonathan Niedier
Cc: Nguyễn Thái Ngọc Duy
Many code path will skip repo access if startup_info->have_repository
is false. This may be a fault if startup_info->have_repository has not
been properly initialized.
So the rule is one of the following commands must be run before any
repo access. And none of them can be called twice.
- setup_git_directory*
- enter_repo
- init_db
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
builtin/init-db.c | 1 +
cache.h | 1 +
config.c | 2 ++
environment.c | 13 +++++++++++--
git.c | 16 +++++++++++-----
setup.c | 13 +++++++++++++
6 files changed, 39 insertions(+), 7 deletions(-)
diff --git a/builtin/init-db.c b/builtin/init-db.c
index 064b919..d4c415c 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -302,6 +302,7 @@ int init_db(const char *git_dir, const char *template_dir, unsigned int flags)
set_git_dir(make_absolute_path(git_dir));
startup_info->have_repository = 1;
+ startup_info->have_run_setup_gitdir = 1;
safe_create_dir(get_git_dir(), 0);
diff --git a/cache.h b/cache.h
index 137edac..1e6fd56 100644
--- a/cache.h
+++ b/cache.h
@@ -1067,6 +1067,7 @@ int checkout_fast_forward(const unsigned char *from, const unsigned char *to);
/* git.c */
struct startup_info {
const char *prefix;
+ int have_run_setup_gitdir;
int have_repository;
int help;
};
diff --git a/config.c b/config.c
index 07d854a..9981b09 100644
--- a/config.c
+++ b/config.c
@@ -737,6 +737,8 @@ int git_config(config_fn_t fn, void *data)
char *repo_config = NULL;
int ret;
+ if (startup_info && !startup_info->have_run_setup_gitdir)
+ die("internal error: access to .git/config without repo setup");
if (!startup_info || startup_info->have_repository)
repo_config = git_pathdup("config");
ret = git_config_early(fn, data, repo_config);
diff --git a/environment.c b/environment.c
index 6127025..17f0cbe 100644
--- a/environment.c
+++ b/environment.c
@@ -98,9 +98,18 @@ void unset_git_env(void)
static void setup_git_env(void)
{
+ if (startup_info && startup_info->have_run_setup_gitdir)
+ die("internal error: setup_git_env can't be called twice");
git_dir = getenv(GIT_DIR_ENVIRONMENT);
- if (!git_dir)
- git_dir = read_gitfile_gently(DEFAULT_GIT_DIR_ENVIRONMENT);
+ if (!git_dir) {
+ /*
+ * Repo detection should be done by setup_git_directory*
+ * or enter_repo, not by this function
+ */
+ if (startup_info)
+ die("internal error: $GIT_DIR is empty");
+ git_dir = read_gitfile_gently(DEFAULT_GIT_DIR_ENVIRONMENT);
+ }
if (!git_dir)
git_dir = DEFAULT_GIT_DIR_ENVIRONMENT;
git_object_dir = getenv(DB_ENVIRONMENT);
diff --git a/git.c b/git.c
index d6513f1..43cebd7 100644
--- a/git.c
+++ b/git.c
@@ -245,11 +245,14 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
int nongit_ok;
setup_git_directory_gently(&nongit_ok);
}
- else if (startup_info->have_repository) {
- if (p->option & (RUN_SETUP_GENTLY | RUN_SETUP))
- ; /* done already */
- else
- unset_git_directory(startup_info->prefix);
+ else if (startup_info->have_run_setup_gitdir) {
+ if (startup_info->have_repository) {
+ if (p->option & (RUN_SETUP_GENTLY | RUN_SETUP))
+ ; /* done already */
+ else
+ unset_git_directory(startup_info->prefix);
+ }
+ startup_info->have_run_setup_gitdir = 0;
}
if (use_pager == -1 && p->option & RUN_SETUP)
@@ -260,6 +263,9 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
use_pager = 1;
}
}
+ else
+ /* Stop git_config() from complaining that no repository found. */
+ startup_info->have_run_setup_gitdir = 1;
commit_pager_choice();
if (!startup_info->help && p->option & NEED_WORK_TREE)
diff --git a/setup.c b/setup.c
index b0269aa..89757fc 100644
--- a/setup.c
+++ b/setup.c
@@ -237,7 +237,17 @@ void setup_work_tree(void)
git_dir = make_absolute_path(git_dir);
if (!work_tree || chdir(work_tree))
die("This operation must be run in a work tree");
+
+ /*
+ * have_run_setup_gitdir is unset in order to avoid die()ing
+ * inside set_git_env(). We don't actually initialize
+ * repo twice, we're just relative-izing gitdir
+ */
+ if (startup_info)
+ startup_info->have_run_setup_gitdir = 0;
set_git_dir(make_relative_path(git_dir, work_tree));
+ if (startup_info)
+ startup_info->have_run_setup_gitdir = 1;
initialized = 1;
}
@@ -340,6 +350,7 @@ void unset_git_directory(const char *prefix)
unset_git_env();
startup_info->prefix = NULL;
startup_info->have_repository = 0;
+ startup_info->have_run_setup_gitdir = 0;
}
/* Initialized in setup_git_directory_gently_1() */
@@ -515,6 +526,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
prefix = setup_git_directory_gently_1(nongit_ok);
if (startup_info) {
startup_info->prefix = prefix;
+ startup_info->have_run_setup_gitdir = 1;
startup_info->have_repository = !nongit_ok || !*nongit_ok;
}
return prefix;
@@ -609,6 +621,7 @@ char *enter_repo(char *path, int strict)
set_git_dir(".");
if (startup_info) {
startup_info->prefix = NULL;
+ startup_info->have_run_setup_gitdir = 1;
startup_info->have_repository = 1;
}
return path;
--
1.7.0.rc1.541.g2da82.dirty
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH 41/43] t0001: Add test cases for "git init" with aliases
2010-04-05 18:40 [PATCH 00/43] nd/setup update Nguyễn Thái Ngọc Duy
` (39 preceding siblings ...)
2010-04-05 18:41 ` [PATCH 40/43] Guard unallowed access to repository when it's not set up Nguyễn Thái Ngọc Duy
@ 2010-04-05 18:41 ` Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 42/43] builtins: setup repository before print unknown command error Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 43/43] builtins: do not commit pager choice early Nguyễn Thái Ngọc Duy
42 siblings, 0 replies; 50+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-04-05 18:41 UTC (permalink / raw)
To: git, Junio C Hamano, Jonathan Niedier
Cc: Jonathan Nieder, Nguyễn Thái Ngọc Duy
From: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
t/t0001-init.sh | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 52 insertions(+), 0 deletions(-)
diff --git a/t/t0001-init.sh b/t/t0001-init.sh
index 6757734..dd66352 100755
--- a/t/t0001-init.sh
+++ b/t/t0001-init.sh
@@ -33,6 +33,58 @@ test_expect_success 'plain' '
check_config plain/.git false unset
'
+test_expect_success 'plain nested in bare' '
+ (
+ unset GIT_DIR GIT_WORK_TREE &&
+ git init --bare bare-ancestor.git &&
+ cd bare-ancestor.git &&
+ mkdir plain-nested &&
+ cd plain-nested &&
+ git init
+ ) &&
+ check_config bare-ancestor.git/plain-nested/.git false unset
+'
+
+test_expect_success 'plain through aliased command' '
+ (
+ unset GIT_DIR GIT_WORK_TREE GIT_CONFIG_NOGLOBAL &&
+ HOME=$(pwd)/alias-config &&
+ export HOME &&
+ mkdir alias-config &&
+ echo "[alias] aliasedinit = init" >alias-config/.gitconfig &&
+ mkdir plain-aliased &&
+ cd plain-aliased &&
+ git aliasedinit
+ ) &&
+ check_config plain-aliased/.git false unset
+'
+
+test_expect_success 'plain nested through aliased command' '
+ (
+ unset GIT_DIR GIT_WORK_TREE &&
+ git init plain-ancestor-aliased &&
+ cd plain-ancestor-aliased &&
+ echo "[alias] aliasedinit = init" >>.git/config &&
+ mkdir plain-nested &&
+ cd plain-nested &&
+ git aliasedinit
+ ) &&
+ check_config plain-ancestor-aliased/plain-nested/.git false unset
+'
+
+test_expect_success 'plain nested in bare through aliased command' '
+ (
+ unset GIT_DIR GIT_WORK_TREE &&
+ git init --bare bare-ancestor-aliased.git &&
+ cd bare-ancestor-aliased.git &&
+ echo "[alias] aliasedinit = init" >>config &&
+ mkdir plain-nested &&
+ cd plain-nested &&
+ git aliasedinit
+ ) &&
+ check_config bare-ancestor-aliased.git/plain-nested/.git false unset
+'
+
test_expect_success 'plain with GIT_WORK_TREE' '
if (
unset GIT_DIR
--
1.7.0.rc1.541.g2da82.dirty
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH 42/43] builtins: setup repository before print unknown command error
2010-04-05 18:40 [PATCH 00/43] nd/setup update Nguyễn Thái Ngọc Duy
` (40 preceding siblings ...)
2010-04-05 18:41 ` [PATCH 41/43] t0001: Add test cases for "git init" with aliases Nguyễn Thái Ngọc Duy
@ 2010-04-05 18:41 ` Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 43/43] builtins: do not commit pager choice early Nguyễn Thái Ngọc Duy
42 siblings, 0 replies; 50+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-04-05 18:41 UTC (permalink / raw)
To: git, Junio C Hamano, Jonathan Niedier
Cc: Nguyễn Thái Ngọc Duy, Junio C Hamano
help_unknown_cmd() will need to look into repository's config, in
order to collect all possible commands/aliases and give a
suggestion. So, repository must be set up before this function is
called.
As it is now, because
- alias handling will always be done before help_unknown_cmd()
- alias handling code will search and set up repository if found
- alias handline code will not undo repository setup
These ensure that repository will always be set up (or attempted to
set up) before help_unknown_cmd(), so there is no issue. But the setup
dependency here is subtle. It may break some day if someone reorders
the loop, for example.
Make a note about this.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
git.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/git.c b/git.c
index 43cebd7..1fb478f 100644
--- a/git.c
+++ b/git.c
@@ -555,6 +555,13 @@ int main(int argc, const char **argv)
exit(1);
}
if (!done_help) {
+ /*
+ * help_unknown_cmd() requires that a repository has been
+ * searched for and set up if found.
+ * Luckily, the alias handling code already took care of this.
+ */
+ if (!startup_info->have_run_setup_gitdir)
+ die("internal error: handling unknown command");
cmd = argv[0] = help_unknown_cmd(cmd);
done_help = 1;
} else
--
1.7.0.rc1.541.g2da82.dirty
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH 43/43] builtins: do not commit pager choice early
2010-04-05 18:40 [PATCH 00/43] nd/setup update Nguyễn Thái Ngọc Duy
` (41 preceding siblings ...)
2010-04-05 18:41 ` [PATCH 42/43] builtins: setup repository before print unknown command error Nguyễn Thái Ngọc Duy
@ 2010-04-05 18:41 ` Nguyễn Thái Ngọc Duy
2010-04-06 4:01 ` [PATCH 0/2] fix weird git --paginate behavior Jonathan Nieder
42 siblings, 1 reply; 50+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2010-04-05 18:41 UTC (permalink / raw)
To: git, Junio C Hamano, Jonathan Niedier
Cc: Nguyễn Thái Ngọc Duy, Junio C Hamano
Committing pager choice may require setting up the pager, which
will need access to repository.
At the time after handle_options() is called, the repository has not
been found yet. As a result, unallowed access to repository may
happen.
There are several possible code path after
handle_options()/commit_pager_choice() is called:
1. list_common_cmds_help()
2. run_argv()
3. help_unknown_cmd()
Case 2. will have commit_pager_choice() called inside run_builtin() if
a command is found. Case 1. and 3. won't need a pager, it's short
printout and should be fitted within a screen. So, removing
commit_pager_choice() call after handle_options() is safe.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
git.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/git.c b/git.c
index 1fb478f..060cfe8 100644
--- a/git.c
+++ b/git.c
@@ -521,7 +521,6 @@ int main(int argc, const char **argv)
argv++;
argc--;
handle_options(&argv, &argc, NULL);
- commit_pager_choice();
if (argc > 0) {
if (!prefixcmp(argv[0], "--"))
argv[0] += 2;
--
1.7.0.rc1.541.g2da82.dirty
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH 0/2] fix weird git --paginate behavior
2010-04-05 18:41 ` [PATCH 43/43] builtins: do not commit pager choice early Nguyễn Thái Ngọc Duy
@ 2010-04-06 4:01 ` Jonathan Nieder
2010-04-06 4:03 ` [PATCH 1/2] t7006: test core.pager configuration in subdir of toplevel Jonathan Nieder
` (3 more replies)
0 siblings, 4 replies; 50+ messages in thread
From: Jonathan Nieder @ 2010-04-06 4:01 UTC (permalink / raw)
To: Nguyễn Thái Ngọc Duy; +Cc: git, Junio C Hamano
Hi,
Nguyễn Thái Ngọc Duy wrote:
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Thanks for posting this series. I had not read it in full before.
The series is very long and it is hard to make certain it does not
introduce regressions. Here is my idea for working around this: the
idea is to grab patches from the series to form short, independently
justifiable mini-series. Once most of the functional changes are
merged, it should be a lot easier to evaluate the core code change
that makes setup more brittle (which I like a lot).
What do you think? Is it worth the trouble?
Here’s an example mini-series. Patch 1 adds a test case for
some weird git -p behavior. Patch 2 fixes it.
Jonathan Nieder (1):
t7006: test an edge case for git --paginate
Nguyễn Thái Ngọc Duy (1):
builtins: do not commit pager choice early
git.c | 1 -
t/t7006-pager.sh | 32 ++++++++++++++++++++++++++++++++
2 files changed, 32 insertions(+), 1 deletions(-)
^ permalink raw reply [flat|nested] 50+ messages in thread
* [PATCH 1/2] t7006: test core.pager configuration in subdir of toplevel
2010-04-06 4:01 ` [PATCH 0/2] fix weird git --paginate behavior Jonathan Nieder
@ 2010-04-06 4:03 ` Jonathan Nieder
2010-04-06 4:06 ` [PATCH 2/2] builtins: do not commit pager choice early Jonathan Nieder
` (2 subsequent siblings)
3 siblings, 0 replies; 50+ messages in thread
From: Jonathan Nieder @ 2010-04-06 4:03 UTC (permalink / raw)
To: Nguyễn Thái Ngọc Duy; +Cc: git, Junio C Hamano
If git is passed the --paginate option, committing the pager choice
will require setting up the pager, which requires access to repository
for the core.pager configuration.
Unfortunately, the --paginate option is handled before git has a
chance to search for a git directory. The effect is that with
--paginate and only with --paginate, a repository-local core.pager
setting does not take effect unless the git directory is simply .git
in the cwd (or GIT_DIR or GIT_CONFIG was explicitly set).
Add a test to demonstrate this problem.
Noticed while reading over a patch by Nguyễn Thái Ngọc Duy that
fixes it.
Cc: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
| 32 ++++++++++++++++++++++++++++++++
1 files changed, 32 insertions(+), 0 deletions(-)
--git a/t/t7006-pager.sh b/t/t7006-pager.sh
index d9202d5..4f804ed 100755
--- a/t/t7006-pager.sh
+++ b/t/t7006-pager.sh
@@ -164,6 +164,38 @@ test_expect_success TTY 'core.pager overrides PAGER' '
test -e core.pager_used
'
+unset GIT_PAGER
+rm -f core.pager_used
+rm -fr sub
+test_expect_success TTY 'core.pager in subdir' '
+ PAGER=wc &&
+ stampname=$(pwd)/core.pager_used &&
+ export PAGER stampname &&
+ git config core.pager "wc > \"\$stampname\"" &&
+ mkdir sub &&
+ (
+ cd sub &&
+ test_terminal git log
+ ) &&
+ test -e "$stampname"
+'
+
+unset GIT_PAGER
+rm -f core.pager_used
+rm -fr sub
+test_expect_failure TTY 'core.pager in subdir with --paginate' '
+ PAGER=wc &&
+ stampname=$(pwd)/core.pager_used &&
+ export PAGER stampname &&
+ git config core.pager "wc > \"\$stampname\"" &&
+ mkdir sub &&
+ (
+ cd sub &&
+ test_terminal git --paginate log
+ ) &&
+ test -e "$stampname"
+'
+
rm -f GIT_PAGER_used
test_expect_success TTY 'GIT_PAGER overrides core.pager' '
git config core.pager wc &&
--
1.7.0.4.369.g62d9d
^ permalink raw reply related [flat|nested] 50+ messages in thread
* [PATCH 2/2] builtins: do not commit pager choice early
2010-04-06 4:01 ` [PATCH 0/2] fix weird git --paginate behavior Jonathan Nieder
2010-04-06 4:03 ` [PATCH 1/2] t7006: test core.pager configuration in subdir of toplevel Jonathan Nieder
@ 2010-04-06 4:06 ` Jonathan Nieder
2010-04-06 4:16 ` Jonathan Nieder
2010-04-06 7:00 ` [PATCH 0/2] fix weird git --paginate behavior Nguyen Thai Ngoc Duy
2010-04-06 7:17 ` Junio C Hamano
3 siblings, 1 reply; 50+ messages in thread
From: Jonathan Nieder @ 2010-04-06 4:06 UTC (permalink / raw)
To: Nguyễn Thái Ngọc Duy; +Cc: git, Junio C Hamano
If git is passed the --paginate option, committing the pager choice
will require setting up the pager, which requires access to repository
for the core.pager configuration.
After handle_options() is called, the repository has not been searched
for yet. Unless GIT_DIR or GIT_CONFIG is set, attempting to access
the configuration at this point results in git_dir being set to .git,
which is almost certainly not what was wanted.
For example, this breaks git --paginate when used from a subdirectory
of the toplevel directory in a repository with core.pager set.
There are several possible code paths after handle_options() and
commit_pager_choice() are called:
1. list_common_cmds_help() does not need a pager: it’s a printout of
only 29 lines, and most operating systems have some sort of
scrollback that can handle this.
2. run_argv() will run commit_pager_choice() inside run_builtin() if a
command is found.
3. help_unknown_cmd() prints out only a few lines.
So removing the commit_pager_choice() after handle_options() is safe.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
That’s the end of the series (based against master).
Thoughts welcome.
git.c | 1 -
| 2 +-
2 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/git.c b/git.c
index 6bae305..75bd387 100644
--- a/git.c
+++ b/git.c
@@ -502,7 +502,6 @@ int main(int argc, const char **argv)
argv++;
argc--;
handle_options(&argv, &argc, NULL);
- commit_pager_choice();
if (argc > 0) {
if (!prefixcmp(argv[0], "--"))
argv[0] += 2;
--git a/t/t7006-pager.sh b/t/t7006-pager.sh
index 4f804ed..c373342 100755
--- a/t/t7006-pager.sh
+++ b/t/t7006-pager.sh
@@ -183,7 +183,7 @@ test_expect_success TTY 'core.pager in subdir' '
unset GIT_PAGER
rm -f core.pager_used
rm -fr sub
-test_expect_failure TTY 'core.pager in subdir with --paginate' '
+test_expect_success TTY 'core.pager in subdir with --paginate' '
PAGER=wc &&
stampname=$(pwd)/core.pager_used &&
export PAGER stampname &&
--
1.7.0.4.369.g62d9d
^ permalink raw reply related [flat|nested] 50+ messages in thread
* Re: [PATCH 2/2] builtins: do not commit pager choice early
2010-04-06 4:06 ` [PATCH 2/2] builtins: do not commit pager choice early Jonathan Nieder
@ 2010-04-06 4:16 ` Jonathan Nieder
0 siblings, 0 replies; 50+ messages in thread
From: Jonathan Nieder @ 2010-04-06 4:16 UTC (permalink / raw)
To: Nguyễn Thái Ngọc Duy; +Cc: git, Junio C Hamano
Jonathan Nieder wrote:
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
I forgot a pseudo-header field:
From: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Sorry for the trouble.
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH 0/2] fix weird git --paginate behavior
2010-04-06 4:01 ` [PATCH 0/2] fix weird git --paginate behavior Jonathan Nieder
2010-04-06 4:03 ` [PATCH 1/2] t7006: test core.pager configuration in subdir of toplevel Jonathan Nieder
2010-04-06 4:06 ` [PATCH 2/2] builtins: do not commit pager choice early Jonathan Nieder
@ 2010-04-06 7:00 ` Nguyen Thai Ngoc Duy
2010-04-06 7:17 ` Junio C Hamano
3 siblings, 0 replies; 50+ messages in thread
From: Nguyen Thai Ngoc Duy @ 2010-04-06 7:00 UTC (permalink / raw)
To: Jonathan Nieder; +Cc: git, Junio C Hamano
2010/4/6 Jonathan Nieder <jrnieder@gmail.com>:
> Hi,
>
> Nguyễn Thái Ngọc Duy wrote:
>
>> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
>> Signed-off-by: Junio C Hamano <gitster@pobox.com>
>
> Thanks for posting this series. I had not read it in full before.
>
> The series is very long and it is hard to make certain it does not
> introduce regressions. Here is my idea for working around this: the
> idea is to grab patches from the series to form short, independently
> justifiable mini-series. Once most of the functional changes are
> merged, it should be a lot easier to evaluate the core code change
> that makes setup more brittle (which I like a lot).
>
> What do you think? Is it worth the trouble?
I don't know. There are few independent patches like this. Most of
them will need startup_info struct, introduced in 01/43. I splitted
the series in two parts, with hope that the first (simpler) part could
graduate early. But as you pointed out, even the first part introduced
a regression.
Anyway if you want to pick them out, candidates are:
- 19-20/43: calculate prefix anyway and remove the hack in index-pack
- 22-23/43: moving enter_repo(). This makes enter_repo() more
consistent with setup_git_dir*, no real gain.
- 24/43: the bug only exposes when set_git_dir() is used extensively
in setup_git_dir*, so this patch alone seems useless.
So that's 7 patches shorter if all of them are sent independently.
--
Duy
^ permalink raw reply [flat|nested] 50+ messages in thread
* Re: [PATCH 0/2] fix weird git --paginate behavior
2010-04-06 4:01 ` [PATCH 0/2] fix weird git --paginate behavior Jonathan Nieder
` (2 preceding siblings ...)
2010-04-06 7:00 ` [PATCH 0/2] fix weird git --paginate behavior Nguyen Thai Ngoc Duy
@ 2010-04-06 7:17 ` Junio C Hamano
3 siblings, 0 replies; 50+ messages in thread
From: Junio C Hamano @ 2010-04-06 7:17 UTC (permalink / raw)
To: Jonathan Nieder; +Cc: Nguyễn Thái Ngọc Duy, git
Jonathan Nieder <jrnieder@gmail.com> writes:
> Nguyễn Thái Ngọc Duy wrote:
>
>> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
>> Signed-off-by: Junio C Hamano <gitster@pobox.com>
>
> Thanks for posting this series. I had not read it in full before.
>
> The series is very long and it is hard to make certain it does not
> introduce regressions. Here is my idea for working around this: the
> idea is to grab patches from the series to form short, independently
> justifiable mini-series.
Thanks for trying out your idea.
I've been having trouble reviewing this series. I can read bits and
pieces and find things that I mostly agree with, or things that I find
questionable. But in either case, I cannot be sure about my judgement
without having a clear idea of where the series is trying to go upfront.
While a re-roll will certainly give us a chance to review the series
"cover-to-cover", it would make it much easier to swallow if this can be
split into independently digestable bite-sized pieces. I am somewhat
skeptical if a major part of the series will become that smaller,
though...
^ permalink raw reply [flat|nested] 50+ messages in thread
end of thread, other threads:[~2010-04-06 7:17 UTC | newest]
Thread overview: 50+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-05 18:40 [PATCH 00/43] nd/setup update Nguyễn Thái Ngọc Duy
2010-04-05 18:40 ` [PATCH 01/43] builtin: introduce startup_info struct Nguyễn Thái Ngọc Duy
2010-04-05 18:40 ` [PATCH 02/43] builtin: Support RUN_SETUP_GENTLY to set up repository early if found Nguyễn Thái Ngọc Duy
2010-04-05 18:40 ` [PATCH 03/43] config: use RUN_SETUP_GENTLY Nguyễn Thái Ngọc Duy
2010-04-05 18:40 ` [PATCH 04/43] hash-object: " Nguyễn Thái Ngọc Duy
2010-04-05 18:40 ` [PATCH 05/43] shortlog: " Nguyễn Thái Ngọc Duy
2010-04-05 18:40 ` [PATCH 06/43] grep: " Nguyễn Thái Ngọc Duy
2010-04-05 18:40 ` [PATCH 07/43] builtin: USE_PAGER should not be used without RUN_SETUP* Nguyễn Thái Ngọc Duy
2010-04-05 18:40 ` [PATCH 08/43] archive: use RUN_SETUP_GENTLY Nguyễn Thái Ngọc Duy
2010-04-05 18:40 ` [PATCH 09/43] mailinfo: " Nguyễn Thái Ngọc Duy
2010-04-05 18:40 ` [PATCH 10/43] check-ref-format: " Nguyễn Thái Ngọc Duy
2010-04-05 18:40 ` [PATCH 11/43] verify-pack: " Nguyễn Thái Ngọc Duy
2010-04-05 18:40 ` [PATCH 12/43] apply: " Nguyễn Thái Ngọc Duy
2010-04-05 18:40 ` [PATCH 13/43] bundle: " Nguyễn Thái Ngọc Duy
2010-04-05 18:40 ` [PATCH 14/43] diff: " Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 15/43] help: take note why this command is not applicable for RUN_SETUP_GENTLY Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 16/43] ls-remote: use RUN_SETUP_GENTLY Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 17/43] var: " Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 18/43] merge-file: " Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 19/43] worktree setup: calculate prefix even if no worktree is found Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 20/43] index-pack: trust the prefix returned by setup_git_directory_gently() Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 21/43] index-pack: use RUN_SETUP_GENTLY Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 22/43] Move enter_repo() to setup.c Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 23/43] enter_repo(): initialize other variables as setup_git_directory_gently() does Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 24/43] rev-parse --git-dir: print relative gitdir correctly Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 25/43] worktree setup: call set_git_dir explicitly Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 26/43] Add git_config_early() Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 27/43] Use git_config_early() instead of git_config() during repo setup Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 28/43] worktree setup: restore original state when things go wrong Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 29/43] init/clone: turn on startup->have_repository properly Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 30/43] git_config(): do not read .git/config if there is no repository Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 31/43] Do not read .git/info/exclude " Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 32/43] Do not read .git/info/attributes " Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 33/43] apply: do not check sha1 " Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 34/43] config: do not read .git/config " Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 35/43] run_builtin(): save "-h" detection result for later use Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 36/43] builtins: utilize startup_info->help where possible Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 37/43] builtins: check for startup_info->help, print and exit early Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 38/43] Allow to undo setup_git_directory_gently() gracefully (and fix alias code) Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 39/43] alias: keep repository found while collecting aliases as long as possible Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 40/43] Guard unallowed access to repository when it's not set up Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 41/43] t0001: Add test cases for "git init" with aliases Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 42/43] builtins: setup repository before print unknown command error Nguyễn Thái Ngọc Duy
2010-04-05 18:41 ` [PATCH 43/43] builtins: do not commit pager choice early Nguyễn Thái Ngọc Duy
2010-04-06 4:01 ` [PATCH 0/2] fix weird git --paginate behavior Jonathan Nieder
2010-04-06 4:03 ` [PATCH 1/2] t7006: test core.pager configuration in subdir of toplevel Jonathan Nieder
2010-04-06 4:06 ` [PATCH 2/2] builtins: do not commit pager choice early Jonathan Nieder
2010-04-06 4:16 ` Jonathan Nieder
2010-04-06 7:00 ` [PATCH 0/2] fix weird git --paginate behavior Nguyen Thai Ngoc Duy
2010-04-06 7:17 ` Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).