From: Junio C Hamano Date: Sat, 24 Jun 2017 21:28:39 +0000 (-0700) Subject: Merge branch 'js/alias-early-config' X-Git-Tag: v2.14.0-rc0~61 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1c3d87cf5594cc7e57d71c7b2d99dd4982285951;p=thirdparty%2Fgit.git Merge branch 'js/alias-early-config' 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 --- 1c3d87cf5594cc7e57d71c7b2d99dd4982285951 diff --cc git.c index 1b8b7f51a6,58ef570294..6150d6d281 --- a/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 list_builtins(void); + - 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 commit_pager_choice(void) { switch (use_pager) { case 0: