From: Junio C Hamano Date: Wed, 20 Dec 2006 21:56:14 +0000 (-0800) Subject: Merge branch 'jc/clone' X-Git-Tag: v1.5.0-rc0~56 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/aa1cef54a2bcc5350df7efe1d1745725c46bf2e3?ds=inline;hp=-c Merge branch 'jc/clone' * jc/clone: Move "no merge candidate" warning into git-pull Use preprocessor constants for environment variable names. Do not create $GIT_DIR/remotes/ directory anymore. Introduce GIT_TEMPLATE_DIR Revert "fix testsuite: make sure they use templates freshly built from the source" fix testsuite: make sure they use templates freshly built from the source git-clone: lose the traditional 'no-separate-remote' layout git-clone: lose the artificial "first" fetch refspec git-pull: refuse default merge without branch.*.merge git-clone: use wildcard specification for tracking branches --- aa1cef54a2bcc5350df7efe1d1745725c46bf2e3 diff --combined builtin-repo-config.c index a7ab4cee58,4885930ca4..90633119d4 --- a/builtin-repo-config.c +++ b/builtin-repo-config.c @@@ -1,5 -1,6 +1,5 @@@ #include "builtin.h" #include "cache.h" -#include static const char git_config_set_usage[] = "git-repo-config [ --global ] [ --bool | --int ] [--get | --get-all | --get-regexp | --replace-all | --add | --unset | --unset-all] name [value [value_regex]] | --rename-section old_name new_name | --list"; @@@ -66,10 -67,10 +66,10 @@@ static int get_value(const char* key_, char *global = NULL, *repo_config = NULL; const char *local; - local = getenv("GIT_CONFIG"); + local = getenv(CONFIG_ENVIRONMENT); if (!local) { const char *home = getenv("HOME"); - local = getenv("GIT_CONFIG_LOCAL"); + local = getenv(CONFIG_LOCAL_ENVIRONMENT); if (!local) local = repo_config = xstrdup(git_path("config")); if (home) diff --combined config.c index e86b2328ab,6a4224e98c..1662a4626e --- a/config.c +++ b/config.c @@@ -6,6 -6,7 +6,6 @@@ * */ #include "cache.h" -#include #define MAXNAME (256) @@@ -349,10 -350,10 +349,10 @@@ int git_config(config_fn_t fn * $GIT_CONFIG_LOCAL will make it process it in addition to the * global config file, the same way it would the per-repository * config file otherwise. */ - filename = getenv("GIT_CONFIG"); + filename = getenv(CONFIG_ENVIRONMENT); if (!filename) { home = getenv("HOME"); - filename = getenv("GIT_CONFIG_LOCAL"); + filename = getenv(CONFIG_LOCAL_ENVIRONMENT); if (!filename) filename = repo_config = xstrdup(git_path("config")); } @@@ -543,9 -544,9 +543,9 @@@ int git_config_set_multivar(const char char* lock_file; const char* last_dot = strrchr(key, '.'); - config_filename = getenv("GIT_CONFIG"); + config_filename = getenv(CONFIG_ENVIRONMENT); if (!config_filename) { - config_filename = getenv("GIT_CONFIG_LOCAL"); + config_filename = getenv(CONFIG_LOCAL_ENVIRONMENT); if (!config_filename) config_filename = git_path("config"); } @@@ -748,28 -749,24 +748,28 @@@ out_free int git_config_rename_section(const char *old_name, const char *new_name) { int ret = 0; - const char *config_filename; + char *config_filename; struct lock_file *lock = xcalloc(sizeof(struct lock_file), 1); int out_fd; char buf[1024]; - config_filename = getenv("GIT_CONFIG"); + config_filename = getenv(CONFIG_ENVIRONMENT); if (!config_filename) { - config_filename = getenv("GIT_CONFIG_LOCAL"); + config_filename = getenv(CONFIG_LOCAL_ENVIRONMENT); if (!config_filename) config_filename = git_path("config"); } config_filename = xstrdup(config_filename); out_fd = hold_lock_file_for_update(lock, config_filename, 0); - if (out_fd < 0) - return error("Could not lock config file!"); + if (out_fd < 0) { + ret = error("Could not lock config file!"); + goto out; + } - if (!(config_file = fopen(config_filename, "rb"))) - return error("Could not open config file!"); + if (!(config_file = fopen(config_filename, "rb"))) { + ret = error("Could not open config file!"); + goto out; + } while (fgets(buf, sizeof(buf), config_file)) { int i; @@@ -809,11 -806,8 +809,11 @@@ } write(out_fd, buf, strlen(buf)); } + fclose(config_file); if (close(out_fd) || commit_lock_file(lock) < 0) - return error("Cannot commit config file!"); + ret = error("Cannot commit config file!"); + out: + free(config_filename); return ret; } diff --combined merge-recursive.c index 1de273ea1e,ae4dcfbe5b..ae7ae4cd2a --- a/merge-recursive.c +++ b/merge-recursive.c @@@ -3,6 -3,13 +3,6 @@@ * Fredrik Kuivinen. * The thieves were Alex Riesen and Johannes Schindelin, in June/July 2006 */ -#include -#include -#include -#include -#include -#include -#include #include "cache.h" #include "cache-tree.h" #include "commit.h" @@@ -1272,7 -1279,7 +1272,7 @@@ int main(int argc, char *argv[] struct commit *result, *h1, *h2; git_config(git_default_config); /* core.filemode */ - original_index_file = getenv("GIT_INDEX_FILE"); + original_index_file = getenv(INDEX_ENVIRONMENT); if (!original_index_file) original_index_file = xstrdup(git_path("index"));