*
*/
#include "cache.h"
-#include <regex.h>
#define MAXNAME (256)
* $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"));
}
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");
}
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;
}
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;
}