aboutsummaryrefslogtreecommitdiff
path: root/rerere.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-08-19 14:48:56 -0700
committerJunio C Hamano <gitster@pobox.com>2015-08-19 14:48:56 -0700
commit8c9155e031869293b99531a25b585e49f74beaba (patch)
tree4ed3a2872b4011806c28a0c38cf977a4de68a51e /rerere.c
parent51a22ce1477b991793c20d3143d72f0ae6e38c76 (diff)
parentf932729cc7707390f4d6739be1573e93ceb9df22 (diff)
downloadgit-8c9155e031869293b99531a25b585e49f74beaba.tar.gz
git-8c9155e031869293b99531a25b585e49f74beaba.tar.xz
Merge branch 'jk/git-path'
git_path() and mkpath() are handy helper functions but it is easy to misuse, as the callers need to be careful to keep the number of active results below 4. Their uses have been reduced. * jk/git-path: memoize common git-path "constant" files get_repo_path: refactor path-allocation find_hook: keep our own static buffer refs.c: remove_empty_directories can take a strbuf refs.c: avoid git_path assignment in lock_ref_sha1_basic refs.c: avoid repeated git_path calls in rename_tmp_log refs.c: simplify strbufs in reflog setup and writing path.c: drop git_path_submodule refs.c: remove extra git_path calls from read_loose_refs remote.c: drop extraneous local variable from migrate_file prefer mkpathdup to mkpath in assignments prefer git_pathdup to git_path in some possibly-dangerous cases add_to_alternates_file: don't add duplicate entries t5700: modernize style cache.h: complete set of git_path_submodule helpers cache.h: clarify documentation for git_path, et al
Diffstat (limited to 'rerere.c')
-rw-r--r--rerere.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/rerere.c b/rerere.c
index 94aea9a36..6a517aa38 100644
--- a/rerere.c
+++ b/rerere.c
@@ -20,8 +20,6 @@ static int rerere_enabled = -1;
/* automatically update cleanly resolved paths to the index */
static int rerere_autoupdate;
-static char *merge_rr_path;
-
const char *rerere_path(const char *hex, const char *file)
{
return git_path("rr-cache/%s/%s", hex, file);
@@ -37,7 +35,7 @@ static void read_rr(struct string_list *rr)
{
unsigned char sha1[20];
char buf[PATH_MAX];
- FILE *in = fopen(merge_rr_path, "r");
+ FILE *in = fopen(git_path_merge_rr(), "r");
if (!in)
return;
while (fread(buf, 40, 1, in) == 1) {
@@ -577,21 +575,21 @@ static void git_rerere_config(void)
git_config(git_default_config, NULL);
}
+static GIT_PATH_FUNC(git_path_rr_cache, "rr-cache")
+
static int is_rerere_enabled(void)
{
- const char *rr_cache;
int rr_cache_exists;
if (!rerere_enabled)
return 0;
- rr_cache = git_path("rr-cache");
- rr_cache_exists = is_directory(rr_cache);
+ rr_cache_exists = is_directory(git_path_rr_cache());
if (rerere_enabled < 0)
return rr_cache_exists;
- if (!rr_cache_exists && mkdir_in_gitdir(rr_cache))
- die("Could not create directory %s", rr_cache);
+ if (!rr_cache_exists && mkdir_in_gitdir(git_path_rr_cache()))
+ die("Could not create directory %s", git_path_rr_cache());
return 1;
}
@@ -605,8 +603,7 @@ int setup_rerere(struct string_list *merge_rr, int flags)
if (flags & (RERERE_AUTOUPDATE|RERERE_NOAUTOUPDATE))
rerere_autoupdate = !!(flags & RERERE_AUTOUPDATE);
- merge_rr_path = git_pathdup("MERGE_RR");
- fd = hold_lock_file_for_update(&write_lock, merge_rr_path,
+ fd = hold_lock_file_for_update(&write_lock, git_path_merge_rr(),
LOCK_DIE_ON_ERROR);
read_rr(merge_rr);
return fd;
@@ -741,5 +738,5 @@ void rerere_clear(struct string_list *merge_rr)
if (!has_rerere_resolution(name))
unlink_rr_item(name);
}
- unlink_or_warn(git_path("MERGE_RR"));
+ unlink_or_warn(git_path_merge_rr());
}