OSDN Git Service

Merge branch 'js/alias-early-config'
authorJunio C Hamano <gitster@pobox.com>
Sat, 24 Jun 2017 21:28:39 +0000 (14:28 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sat, 24 Jun 2017 21:28:40 +0000 (14:28 -0700)
The code to pick up and execute command alias definition from the
configuration used to switch to the top of the working tree and
then come back when the expanded alias was executed, which was
unnecessarilyl complex.  Attempt to simplify the logic by using the
early-config mechanism that does not chdir around.

* js/alias-early-config:
  alias: use the early config machinery to expand aliases
  t7006: demonstrate a problem with aliases in subdirectories
  t1308: relax the test verifying that empty alias values are disallowed
  help: use early config when autocorrecting aliases
  config: report correct line number upon error
  discover_git_directory(): avoid setting invalid git_dir

1  2 
config.c
git.c
help.c
setup.c
t/t1300-repo-config.sh
t/t1308-config-set.sh

diff --cc config.c
Simple merge
diff --cc git.c
--- 1/git.c
--- 2/git.c
+++ b/git.c
@@@ -16,53 -16,7 +16,9 @@@ const char git_more_info_string[] 
           "to read about a specific subcommand or concept.");
  
  static int use_pager = -1;
- static char *orig_cwd;
- static const char *env_names[] = {
-       GIT_DIR_ENVIRONMENT,
-       GIT_WORK_TREE_ENVIRONMENT,
-       GIT_IMPLICIT_WORK_TREE_ENVIRONMENT,
-       GIT_PREFIX_ENVIRONMENT
- };
- static char *orig_env[4];
- static int save_restore_env_balance;
  
- static void save_env_before_alias(void)
- {
-       int i;
-       assert(save_restore_env_balance == 0);
-       save_restore_env_balance = 1;
-       orig_cwd = xgetcwd();
-       for (i = 0; i < ARRAY_SIZE(env_names); i++) {
-               orig_env[i] = getenv(env_names[i]);
-               orig_env[i] = xstrdup_or_null(orig_env[i]);
-       }
- }
- static void restore_env(int external_alias)
- {
-       int i;
-       assert(save_restore_env_balance == 1);
-       save_restore_env_balance = 0;
-       if (!external_alias && orig_cwd && chdir(orig_cwd))
-               die_errno("could not move to %s", orig_cwd);
-       free(orig_cwd);
-       for (i = 0; i < ARRAY_SIZE(env_names); i++) {
-               if (external_alias &&
-                   !strcmp(env_names[i], GIT_PREFIX_ENVIRONMENT))
-                       continue;
-               if (orig_env[i]) {
-                       setenv(env_names[i], orig_env[i], 1);
-                       free(orig_env[i]);
-               } else {
-                       unsetenv(env_names[i]);
-               }
-       }
- }
 +static void list_builtins(void);
 +
  static void commit_pager_choice(void) {
        switch (use_pager) {
        case 0:
diff --cc help.c
Simple merge
diff --cc setup.c
Simple merge
Simple merge
Simple merge