diff options
Diffstat (limited to 'src/metastore.c')
-rw-r--r-- | src/metastore.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/metastore.c b/src/metastore.c index 2bc2a89..bc5787e 100644 --- a/src/metastore.c +++ b/src/metastore.c @@ -43,7 +43,7 @@ /* metastore settings */ static struct metasettings settings = { .metafile = METAFILE, - .do_mtime = false, + .do_mtime = 0, .do_emptydirs = false, .do_removeemptydirs = false, .do_git = false, @@ -286,7 +286,7 @@ compare_fix(struct metaentry *real, struct metaentry *stored, int cmp) * recreating them. */ static void -fixup_emptydirs(void) +fixup_emptydirs(int do_mtime) { struct metaentry *entry; struct metaentry *cur; @@ -364,7 +364,7 @@ fixup_emptydirs(void) } msg(MSG_QUIET, "ok\n"); - new = mentry_create(cur->path); + new = mentry_create(cur->path, do_mtime >= 0); if (!new) { msg(MSG_QUIET, "Failed to get metadata for %s\n", cur->path); continue; @@ -459,6 +459,7 @@ usage(const char *arg0, const char *message) " -v, --verbose Print more verbose messages\n" " -q, --quiet Print less verbose messages\n" " -m, --mtime Also take mtime into account for diff or apply\n" +" -M, --no-mtime Do not save mtime into metadata\n" " -e, --empty-dirs Recreate missing empty directories\n" " -E, --remove-empty-dirs Remove extra empty directories\n" " -g, --git Do not omit .git directories\n" @@ -480,6 +481,7 @@ static struct option long_options[] = { { "verbose", no_argument, NULL, 'v' }, { "quiet", no_argument, NULL, 'q' }, { "mtime", no_argument, NULL, 'm' }, + { "no-mtime", no_argument, NULL, 'M' }, { "empty-dirs", no_argument, NULL, 'e' }, { "remove-empty-dirs", no_argument, NULL, 'E' }, { "git", no_argument, NULL, 'g' }, @@ -501,7 +503,7 @@ main(int argc, char **argv) i = 0; while (1) { int option_index = 0; - c = getopt_long(argc, argv, "csadVhvqmeEgf:r:", + c = getopt_long(argc, argv, "csadVhvqmMeEgf:r:", long_options, &option_index); if (c == -1) break; @@ -514,7 +516,8 @@ main(int argc, char **argv) case 'h': /* help */ action |= ACTION_HELP; i++; break; case 'v': /* verbose */ adjust_verbosity(1); break; case 'q': /* quiet */ adjust_verbosity(-1); break; - case 'm': /* mtime */ settings.do_mtime = true; break; + case 'm': /* mtime */ settings.do_mtime = 1; break; + case 'M': /* no-mtime */ settings.do_mtime = -1; break; case 'e': /* empty-dirs */ settings.do_emptydirs = true; break; case 'E': /* remove-empty-dirs */ settings.do_removeemptydirs = true; break; @@ -577,7 +580,7 @@ main(int argc, char **argv) case ACTION_APPLY: mentries_compare(real, stored, compare_fix, &settings); if (settings.do_emptydirs) - fixup_emptydirs(); + fixup_emptydirs(settings.do_mtime); if (settings.do_removeemptydirs) fixup_newemptydirs(); break; |