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

Skip to content

Honor 'GIT_USE_NSEC' option in filesystem_iterator_set_current #4507

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

Merged
merged 2 commits into from
Jan 31, 2018

Conversation

tomas
Copy link
Contributor

@tomas tomas commented Jan 31, 2018

This should have been part of PR #3638 (for issue #3635). Without this, we still get nsec-related errors, even when using -DGIT_USE_NSEC:

error: ‘struct stat’ has no member named ‘st_mtime_nsec’

This should have been part of PR libgit2#3638. Without this we still get 
nsec-related errors, even when using -DGIT_USE_NSEC:

 error: ‘struct stat’ has no member named ‘st_mtime_nsec’
@ethomson
Copy link
Member

ethomson commented Jan 31, 2018

Thanks for catching this oversight. Shouldn't we be zero'ing the nanoseconds field in this case? eg:

#if defined(GIT_USE_NSEC)
    iter->entry.ctime.nanoseconds = entry->st.st_ctime_nsec;
    iter->entry.mtime.nanoseconds = entry->st.st_mtime_nsec;
#else
    iter->entry.ctime.nanoseconds = 0;
    iter->entry.mtime.nanoseconds = 0;
#endif

@tomas
Copy link
Contributor Author

tomas commented Jan 31, 2018

@ethomson I guess. I just followed the implementation on the original PR though, so that would also require updating. :)

@ethomson
Copy link
Member

Sorry, which original change are you looking at?

Generally we zero structs, but I think that in this particular case, we're iterating an index entry from an on-disk index that we've loaded. That on-disk index may have been written with a nanosecond supporting git client. If so, the nanoseconds field in the entry would be nonzero. If that's true, then we need to clear it, and not persist it...

@tomas
Copy link
Contributor Author

tomas commented Jan 31, 2018

This one.

@ethomson
Copy link
Member

git_index_entry__from_stat is called on new, zero'd out index entries that we're creating. They're generated in index_entry_create which callocs its memory.

The index iterators are very different beasts - we don't create new index entries with them, that we know will have zero'd nanosecond entries - we're refreshing index entries that we've loaded from the index on disk. They may have non-zero nanosecond entries that we need to clear.

@tomas
Copy link
Contributor Author

tomas commented Jan 31, 2018

Alrighty. Just updated the patch.

@ethomson
Copy link
Member

Thanks!

@ethomson ethomson merged commit 341608d into libgit2:master Jan 31, 2018
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.

2 participants