@matheusbsbs / matheus-bagliano / commits / 6d91da6d3c
Fork 0

read-cache.c: introduce is_racy_timestamp() helper

This moves a common boolean expression into a helper function, and makes the comparison between filesystem timestamp and index timestamp done in the function in line with the other places. st.st_mtime should be casted to (unsigned int) when compared to an index timestamp ce_mtime. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Jan 21, 2008 at 00:44 UTC 6d91da6d3c170d026f2d7f79bbd7b657a6908cc8
1 file changed +8 -5
read-cache.c
+8 -5
@@ -181,6 +181,12 @@ static int ce_match_stat_basic(struct cache_entry *ce, struct stat *st)
181 return changed;
182 }
183
184 +static int is_racy_timestamp(struct index_state *istate, struct cache_entry *ce)
185 +{
186 + return (istate->timestamp &&
187 + ((unsigned int)istate->timestamp) <= ce->ce_mtime);
188 +}
189 +
190 int ie_match_stat(struct index_state *istate,
191 struct cache_entry *ce, struct stat *st,
192 unsigned int options)
@@ -214,9 +220,7 @@ int ie_match_stat(struct index_state *istate,
220 * whose mtime are the same as the index file timestamp more
221 * carefully than others.
222 */
217 - if (!changed &&
218 - istate->timestamp &&
219 - istate->timestamp <= ce->ce_mtime) {
223 + if (!changed && is_racy_timestamp(istate, ce)) {
224 if (assume_racy_is_modified)
225 changed |= DATA_CHANGED;
226 else
@@ -1233,8 +1237,7 @@ int write_index(struct index_state *istate, int newfd)
1237 struct cache_entry *ce = cache[i];
1238 if (ce->ce_flags & CE_REMOVE)
1239 continue;
1236 - if (istate->timestamp &&
1237 - istate->timestamp <= ce->ce_mtime)
1240 + if (is_racy_timestamp(istate, ce))
1241 ce_smudge_racily_clean_entry(ce);
1242 if (ce_write_entry(&c, newfd, ce) < 0)
1243 return -1;