Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2014-06-06 22:23:04 +0400
committerJunio C Hamano <gitster@pobox.com>2014-06-06 22:23:04 +0400
commitf7f349e1383077fb9e1c03335a372b52a19ab2f0 (patch)
treeaf7577da1619d7d056b967f480c1c371d666488b /refs.c
parent43eb7cb260cb17e28dda12e8dc1eb5554e650841 (diff)
parent482b8f3208e797f00db58edd7ff0d67275e898f5 (diff)
Merge branch 'rs/reflog-exists'
* rs/reflog-exists: checkout.c: use ref_exists instead of file_exist refs.c: add new functions reflog_exists and delete_reflog
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/refs.c b/refs.c
index 728a761648..68982637ed 100644
--- a/refs.c
+++ b/refs.c
@@ -1999,7 +1999,6 @@ int dwim_log(const char *str, int len, unsigned char *sha1, char **log)
*log = NULL;
for (p = ref_rev_parse_rules; *p; p++) {
- struct stat st;
unsigned char hash[20];
char path[PATH_MAX];
const char *ref, *it;
@@ -2008,12 +2007,9 @@ int dwim_log(const char *str, int len, unsigned char *sha1, char **log)
ref = resolve_ref_unsafe(path, hash, 1, NULL);
if (!ref)
continue;
- if (!stat(git_path("logs/%s", path), &st) &&
- S_ISREG(st.st_mode))
+ if (reflog_exists(path))
it = path;
- else if (strcmp(ref, path) &&
- !stat(git_path("logs/%s", ref), &st) &&
- S_ISREG(st.st_mode))
+ else if (strcmp(ref, path) && reflog_exists(ref))
it = ref;
else
continue;
@@ -3046,6 +3042,19 @@ int read_ref_at(const char *refname, unsigned long at_time, int cnt,
return 1;
}
+int reflog_exists(const char *refname)
+{
+ struct stat st;
+
+ return !lstat(git_path("logs/%s", refname), &st) &&
+ S_ISREG(st.st_mode);
+}
+
+int delete_reflog(const char *refname)
+{
+ return remove_path(git_path("logs/%s", refname));
+}
+
static int show_one_reflog_ent(struct strbuf *sb, each_reflog_ent_fn fn, void *cb_data)
{
unsigned char osha1[20], nsha1[20];