Update Scintilla to 4.0.4
[TortoiseGit.git] / ext / libgit2-0009-worktree-Read-worktree-specific-reflog-for-HEAD.patch
blobb9ee0aa818ec0275f25bf631926b8e71a3052e91
1 From 7e313e4b25c664a10c55a57b6ed1c45c609553fe Mon Sep 17 00:00:00 2001
2 From: Sven Strickroth <email@cs-ware.de>
3 Date: Sun, 11 Mar 2018 15:35:56 +0100
4 Subject: [PATCH] worktree: Read worktree specific reflog for HEAD
6 Signed-off-by: Sven Strickroth <email@cs-ware.de>
7 ---
8 src/refdb_fs.c | 2 ++
9 tests/worktree/reflog.c | 26 ++++++++++++++++++++++++++
10 2 files changed, 28 insertions(+)
12 diff --git a/src/refdb_fs.c b/src/refdb_fs.c
13 index 140879d233..9432df8c9b 100644
14 --- a/src/refdb_fs.c
15 +++ b/src/refdb_fs.c
16 @@ -1603,6 +1603,8 @@ static int create_new_reflog_file(const char *filepath)
18 GIT_INLINE(int) retrieve_reflog_path(git_buf *path, git_repository *repo, const char *name)
20 + if (strcmp(name, GIT_HEAD_FILE) == 0)
21 + return git_buf_join3(path, '/', repo->gitdir, GIT_REFLOG_DIR, name);
22 return git_buf_join3(path, '/', repo->commondir, GIT_REFLOG_DIR, name);
25 diff --git a/tests/worktree/reflog.c b/tests/worktree/reflog.c
26 index 6152eb3853..47e482bd32 100644
27 --- a/tests/worktree/reflog.c
28 +++ b/tests/worktree/reflog.c
29 @@ -22,6 +22,32 @@ void test_worktree_reflog__cleanup(void)
30 cleanup_fixture_worktree(&fixture);
33 +void test_worktree_reflog__read_worktree_HEAD(void)
35 + git_reflog *reflog;
36 + const git_reflog_entry *entry;
38 + cl_git_pass(git_reflog_read(&reflog, fixture.worktree, "HEAD"));
39 + cl_assert_equal_i(1, git_reflog_entrycount(reflog));
41 + entry = git_reflog_entry_byindex(reflog, 0);
42 + cl_assert(entry != NULL);
43 + cl_assert_equal_s("checkout: moving from 099fabac3a9ea935598528c27f866e34089c2eff to testrepo-worktree", git_reflog_entry_message(entry));
45 + git_reflog_free(reflog);
48 +void test_worktree_reflog__read_parent_HEAD(void)
50 + git_reflog *reflog;
52 + cl_git_pass(git_reflog_read(&reflog, fixture.repo, "HEAD"));
53 + // there is no logs/HEAD in the parent repo
54 + cl_assert_equal_i(0, git_reflog_entrycount(reflog));
56 + git_reflog_free(reflog);
59 void test_worktree_reflog__read(void)
61 git_reflog *reflog;