Only update when file is newer than TAGS and .etags

(Hopefully?)
This commit is contained in:
Dmitry Gutov 2020-12-09 00:09:32 +02:00
parent 5844ad6c38
commit bb625ea36d

View file

@ -1473,6 +1473,8 @@ validate_arguments (const struct parsed_options *options)
}
}
static struct timespec tags_file_time;
int
main (int argc, char **argv)
{
@ -1533,6 +1535,12 @@ main (int argc, char **argv)
linebuffer_init (&filebuf);
linebuffer_init (&token_name);
struct stat st;
/* If no TAGS file, nothing to do here. */
if (stat (tagfile, &st) == 0)
tags_file_time = get_stat_mtime (&st);
if (find_mode)
read_dot_etags ();
@ -7971,7 +7979,6 @@ static void
maybe_set_update_mode (void)
{
struct stat st;
struct timespec mtime;
update = false;
@ -7980,8 +7987,7 @@ maybe_set_update_mode (void)
return;
/* If the TAGS file is newer than the .etags file, just update. */
mtime = get_stat_mtime (&st);
if (time_newer (&mtime, &dot_etags_time))
if (time_newer (&tags_file_time, &dot_etags_time))
update = true;
}
@ -8118,7 +8124,8 @@ walk_directory (const char *dirname)
{
struct timespec t = get_stat_mtime (&st);
if (update && time_newer (&dot_etags_time, &t))
if (update && time_newer (&tags_file_time, &t)
&& time_newer (&dot_etags_time, &t))
{
/* Nothing - .etags is newer. */
}