aboutsummaryrefslogtreecommitdiff
path: root/builtin/checkout.c
diff options
context:
space:
mode:
authorRonnie Sahlberg <sahlberg@google.com>2014-05-06 15:45:52 -0700
committerJunio C Hamano <gitster@pobox.com>2014-05-08 14:31:43 -0700
commit4da588357a4a8b73f6a8d9c24435dabee74d0a7e (patch)
tree515b62219289f4f1769a47653f5136af1ccead8e /builtin/checkout.c
parent1dc51c663c0a1c58c935677c614d31ddf687b3f1 (diff)
downloadgit-4da588357a4a8b73f6a8d9c24435dabee74d0a7e.tar.gz
git-4da588357a4a8b73f6a8d9c24435dabee74d0a7e.tar.xz
refs.c: add new functions reflog_exists and delete_reflog
Add two new functions, reflog_exists and delete_reflog, to hide the internal reflog implementation (that they are files under .git/logs/...) from callers. Update checkout.c to use these functions in update_refs_for_switch instead of building pathnames and calling out to file access functions. Update reflog.c to use these to check if the reflog exists. Now there are still many places in reflog.c where we are still leaking the reflog storage implementation but this at least reduces the number of such dependencies by one. Finally change two places in refs.c itself to use the new function to check if a ref exists or not isntead of build-path-and-stat(). Now, this is strictly not all that important since these are in parts of refs that are implementing the actual file storage backend but on the other hand it will not hurt either. Signed-off-by: Ronnie Sahlberg <sahlberg@google.com> Acked-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/checkout.c')
-rw-r--r--builtin/checkout.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 07cf55530..d3fc3a853 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -651,12 +651,11 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
}
}
if (old->path && old->name) {
- char log_file[PATH_MAX], ref_file[PATH_MAX];
+ char ref_file[PATH_MAX];
- git_snpath(log_file, sizeof(log_file), "logs/%s", old->path);
git_snpath(ref_file, sizeof(ref_file), "%s", old->path);
- if (!file_exists(ref_file) && file_exists(log_file))
- remove_path(log_file);
+ if (!file_exists(ref_file) && reflog_exists(old->path))
+ delete_reflog(old->path);
}
}
remove_branch_state();