Merge branch 'nd/multiple-work-trees'
[gitweb.git] / builtin / prune.c
index f08670a984a9f697e40b12f40dfaa946bb2b5e1f..0c73246c721b3307f0d68b4e58f7c684aebce2e9 100644 (file)
@@ -120,11 +120,15 @@ static int prune_worktree(const char *id, struct strbuf *reason)
                if (!stat(git_path("worktrees/%s/link", id), &st_link) &&
                    st_link.st_nlink > 1)
                        return 0;
-               strbuf_addf(reason, _("Removing worktrees/%s: gitdir file points to non-existent location"), id);
-               return 1;
+               if (st.st_mtime <= expire) {
+                       strbuf_addf(reason, _("Removing worktrees/%s: gitdir file points to non-existent location"), id);
+                       return 1;
+               } else {
+                       return 0;
+               }
        }
        free(path);
-       return st.st_mtime <= expire;
+       return 0;
 }
 
 static void prune_worktrees(void)
@@ -202,6 +206,7 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
        expire = ULONG_MAX;
        save_commit_buffer = 0;
        check_replace_refs = 0;
+       ref_paranoia = 1;
        init_revisions(&revs, prefix);
 
        argc = parse_options(argc, argv, prefix, options, prune_usage, 0);