]> asedeno.scripts.mit.edu Git - git.git/blobdiff - builtin-prune.c
Merge branch 'jk/maint-diffstat-overflow' into maint
[git.git] / builtin-prune.c
index 8459aec8e8ea9d24a13448cf950d2e160361fd9d..81f915ec315eb75e529fed8f2f6bab436755f598 100644 (file)
@@ -18,13 +18,11 @@ static unsigned long expire;
 static int prune_tmp_object(const char *path, const char *filename)
 {
        const char *fullpath = mkpath("%s/%s", path, filename);
-       if (expire) {
-               struct stat st;
-               if (lstat(fullpath, &st))
-                       return error("Could not stat '%s'", fullpath);
-               if (st.st_mtime > expire)
-                       return 0;
-       }
+       struct stat st;
+       if (lstat(fullpath, &st))
+               return error("Could not stat '%s'", fullpath);
+       if (st.st_mtime > expire)
+               return 0;
        printf("Removing stale temporary file %s\n", fullpath);
        if (!show_only)
                unlink_or_warn(fullpath);
@@ -34,13 +32,11 @@ static int prune_tmp_object(const char *path, const char *filename)
 static int prune_object(char *path, const char *filename, const unsigned char *sha1)
 {
        const char *fullpath = mkpath("%s/%s", path, filename);
-       if (expire) {
-               struct stat st;
-               if (lstat(fullpath, &st))
-                       return error("Could not stat '%s'", fullpath);
-               if (st.st_mtime > expire)
-                       return 0;
-       }
+       struct stat st;
+       if (lstat(fullpath, &st))
+               return error("Could not stat '%s'", fullpath);
+       if (st.st_mtime > expire)
+               return 0;
        if (show_only || verbose) {
                enum object_type type = sha1_object_info(sha1, NULL);
                printf("%s %s\n", sha1_to_hex(sha1),
@@ -106,7 +102,7 @@ static void prune_object_dir(const char *path)
 /*
  * Write errors (particularly out of space) can result in
  * failed temporary packs (and more rarely indexes and other
- * files begining with "tmp_") accumulating in the object
+ * files beginning with "tmp_") accumulating in the object
  * and the pack directories.
  */
 static void remove_temporary_files(const char *path)
@@ -139,6 +135,7 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
        };
        char *s;
 
+       expire = ULONG_MAX;
        save_commit_buffer = 0;
        read_replace_refs = 0;
        init_revisions(&revs, prefix);