emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

feature/etags_update_v2 bb625ea: Only update when file is newer than TAG


From: Dmitry Gutov
Subject: feature/etags_update_v2 bb625ea: Only update when file is newer than TAGS and .etags
Date: Tue, 8 Dec 2020 17:16:28 -0500 (EST)

branch: feature/etags_update_v2
commit bb625ea36d56191fe421b6a2790ec4bedad3b06f
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>

    Only update when file is newer than TAGS and .etags
    
    (Hopefully?)
---
 lib-src/etags.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/lib-src/etags.c b/lib-src/etags.c
index 84598fa..e233d94 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -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.  */
                }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]