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

Skip to content

USE_NSECS fixes #3638

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
Feb 25, 2016
Merged

USE_NSECS fixes #3638

merged 2 commits into from
Feb 25, 2016

Conversation

ethomson
Copy link
Member

Include some nanosecond handling fixes for Android NDK's struct stat, which uses neither st_mtim nor st_mtimespec to contain a struct timespec, and instead simply lays down an st_mtime_nsec field next to st_mtime.

Move us over to using that by default, and then setting:

#define st_mtime_nsec mtim.tv_nsec

for compatibility with saner platforms. This is akin to the backcompat behavior with st_mtime and so should seem relatively normal everywhere.

Also, fix a unit test that assumed that it would not be run in a USE_NSECS=ON environment: it validated that when writing a new index entry that the nanoseconds would be truncated and thus 0. (It was meant to ensure that we did not propagate old nanosecond entries that git.git wrote. We should, of course, validate that we write our own values when we're running with nanoseconds enabled.)

Edward Thomson added 2 commits February 25, 2016 11:40
The index::nsec::staging_maintains_other_nanos test was created to
ensure that when we stage an entry when GIT_USE_NSECS is *unset* that
we truncate the index entry and do not persist the (old, invalid)
nanosec values.  Ensure that when GIT_USE_NSECS is *set* that we do
not do that, and actually write the correct nanosecond values.
Android NDK does not have a `struct timespec` in its `struct stat`
for nanosecond support, instead it has a single nanosecond member inside
the struct stat itself.  We will use that and use a macro to expand to
the `st_mtim` / `st_mtimespec` definition on other systems (much like
the existing `st_mtime` backcompat definition).
@ethomson
Copy link
Member Author

Fixes #3635

@ethomson
Copy link
Member Author

(Note that #3635 failed when USE_NSECS=ON or not, because we always assumed there was a struct timespec in struct stat, even when building without USE_NSECS=ON).

@carlosmn
Copy link
Member

This is beautiful in a train-crash kind of way 👍

@ethomson
Copy link
Member Author

This is beautiful in a train-crash kind of way

That's not the first time that's been said about me.

carlosmn added a commit that referenced this pull request Feb 25, 2016
@carlosmn carlosmn merged commit 9f4e7c8 into libgit2:master Feb 25, 2016
@ethomson ethomson deleted the nsec branch February 29, 2016 20:57
tomas added a commit to tomas/libgit2 that referenced this pull request Jan 31, 2018
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’
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