@@ -79,7 +79,7 @@ static bool diff_pathspec_match(
79
79
git_diff * diff ,
80
80
const git_index_entry * entry )
81
81
{
82
- bool disable_pathspec_match =
82
+ bool disable_pathspec_match =
83
83
DIFF_FLAG_IS_SET (diff , GIT_DIFF_DISABLE_PATHSPEC_MATCH );
84
84
85
85
/* If we're disabling fnmatch, then the iterator has already applied
@@ -703,6 +703,31 @@ static bool diff_time_eq(
703
703
(!use_nanos || a -> nanoseconds == b -> nanoseconds );
704
704
}
705
705
706
+ /*
707
+ * Test if the given index time is newer than the given existing index entry.
708
+ * If the timestamps are exactly equivalent, then the given index time is
709
+ * considered "racily newer" than the existing index entry.
710
+ */
711
+ static bool diff_newer_than_index (
712
+ const git_index_time * a , const git_index * b , bool use_nanos )
713
+ {
714
+ bool is_newer = false;
715
+
716
+ if (!b )
717
+ return false;
718
+
719
+ is_newer = is_newer || (a -> seconds > (int32_t ) b -> stamp .mtime .tv_sec );
720
+ is_newer = is_newer || (!use_nanos &&
721
+ (a -> seconds == (int32_t ) b -> stamp .mtime .tv_sec ));
722
+ if (use_nanos )
723
+ {
724
+ is_newer = is_newer || ((a -> seconds == (int32_t ) b -> stamp .mtime .tv_sec ) &&
725
+ (a -> nanoseconds >= (uint32_t ) b -> stamp .mtime .tv_nsec ));
726
+ }
727
+
728
+ return is_newer ;
729
+ }
730
+
706
731
typedef struct {
707
732
git_repository * repo ;
708
733
git_iterator * old_iter ;
@@ -864,10 +889,7 @@ static int maybe_modified(
864
889
oitem -> ino != nitem -> ino ||
865
890
oitem -> uid != nitem -> uid ||
866
891
oitem -> gid != nitem -> gid ||
867
- (index &&
868
- ((nitem -> mtime .seconds > (int32_t ) index -> stamp .mtime .tv_sec ) ||
869
- ((nitem -> mtime .seconds == (int32_t ) index -> stamp .mtime .tv_sec ) &&
870
- (nitem -> mtime .nanoseconds >= (uint32_t ) index -> stamp .mtime .tv_nsec )))))
892
+ diff_newer_than_index (& nitem -> mtime , index , use_nanos ))
871
893
{
872
894
status = GIT_DELTA_MODIFIED ;
873
895
modified_uncertain = true;
0 commit comments