Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

csware
Copy link
Contributor

@csware csware commented Mar 11, 2018

Wrong reflog for HEAD is read for worktree.

Fixes issue #4566.

@csware csware changed the title worktree: Read worktree specific reflog for HEAD WIP: worktree: Read worktree specific reflog for HEAD Mar 11, 2018
@csware csware changed the title WIP: worktree: Read worktree specific reflog for HEAD worktree: Read worktree specific reflog for HEAD Mar 11, 2018
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)
Copy link
Member

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)

Copy link
Contributor Author

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.


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");
Copy link
Member

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))`

Copy link
Contributor Author

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...


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);
Copy link
Member

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...)

@ethomson
Copy link
Member

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.

Copy link
Member

@pks-t pks-t left a 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

git_reflog *reflog;

cl_git_pass(git_reflog_read(&reflog, fixture.repo, "HEAD"));
// there is no logs/HEAD in the parent repo
Copy link
Member

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

@csware
Copy link
Contributor Author

csware commented Apr 17, 2018

@ethomson @pks-t All points addressed...

@csware csware mentioned this pull request Apr 20, 2018
@pks-t pks-t merged commit 8d138f8 into libgit2:master Apr 20, 2018
@pks-t
Copy link
Member

pks-t commented Apr 20, 2018

Thanks @csware, looks good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants