[PATCH 15/43] help: take note why this command is not applicable for RUN_SETUP_GENTLY

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Jonathan Nieder <jrnieder@xxxxxxxxx>

"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@xxxxxxxxx>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]