-
Notifications
You must be signed in to change notification settings - Fork 2.5k
worktree: Read worktree specific reflog for HEAD #4577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/refdb_fs.c
Outdated
@@ -1603,6 +1603,8 @@ static int create_new_reflog_file(const char *filepath) | |||
|
|||
GIT_INLINE(int) retrieve_reflog_path(git_buf *path, git_repository *repo, const char *name) | |||
{ | |||
if (strcmp("HEAD", name) == 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We would prefer the constant GIT_HEAD_FILE
here, eg:
if (strcmp(name, GIT_HEAD_FILE) == 0)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, haven't found that constant when coding.
tests/worktree/reflog.c
Outdated
|
||
entry = git_reflog_entry_byindex(reflog, 0); | ||
cl_assert(entry != NULL); | ||
cl_assert_equal_s(git_reflog_entry_message(entry), "checkout: moving from 099fabac3a9ea935598528c27f866e34089c2eff to testrepo-worktree"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our cl_assert
tests are for expected
followed by actual
. Could you please flip-flop these, eg:
`cl_assert_equal_i(1, git_reflog_entrycount)refcount)`, and
`cl_assert_equal_s("checkout: ...", git_reflog_entry_message(entry))`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just copied the test case from this file, so it's also flipped there...
tests/worktree/reflog.c
Outdated
|
||
cl_git_pass(git_reflog_read(&reflog, fixture.repo, "HEAD")); | ||
// there is no logs/HEAD in the common repo | ||
cl_assert_equal_i(git_reflog_entrycount(reflog), 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here also, if you would please flip-flop these values:
cl_assert_equal_i(0, git_reflog...)
I have a few minor comments on the codestyle - I think that it would make sense for @pks-t to weigh in on the actual functionality, since he's the worktree expert. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR, looks good to me. Only thing left is a C++-style comment. Other than that, I'm fine with it
tests/worktree/reflog.c
Outdated
git_reflog *reflog; | ||
|
||
cl_git_pass(git_reflog_read(&reflog, fixture.repo, "HEAD")); | ||
// there is no logs/HEAD in the parent repo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C++-style comments are not allowed in libgit2 due to us using C90
Signed-off-by: Sven Strickroth <[email protected]>
Thanks @csware, looks good! |
Wrong reflog for
HEAD
is read for worktree.Fixes issue #4566.