summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 186458b)
raw | patch | inline | side by side (parent: 186458b)
author | Brandon Casey <casey@nrlssc.navy.mil> | |
Thu, 24 Jul 2008 22:41:12 +0000 (17:41 -0500) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 25 Jul 2008 06:08:07 +0000 (23:08 -0700) |
Since 5723fe7e, temporary objects are now created in their final destination
directories, rather than in .git/objects/. Teach fsck to recognize and
ignore the temporary objects it encounters, and teach prune to remove them.
Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
directories, rather than in .git/objects/. Teach fsck to recognize and
ignore the temporary objects it encounters, and teach prune to remove them.
Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-fsck.c | patch | blob | history | |
builtin-prune.c | patch | blob | history |
diff --git a/builtin-fsck.c b/builtin-fsck.c
index 7326dc33a586dfbadf5bc35ac628b1f8690a6a09..7a4a4f144f7550c5eee67e728ef5ff0df7a5d2ba 100644 (file)
--- a/builtin-fsck.c
+++ b/builtin-fsck.c
if (de->d_name[0] != '.')
break;
continue;
+ case 14:
+ if (prefixcmp(de->d_name, "tmp_obj_"))
+ break;
+ continue;
case 38:
sprintf(name, "%02x", i);
memcpy(name+2, de->d_name, len+1);
diff --git a/builtin-prune.c b/builtin-prune.c
index 7de4cabe078a67e1272ad9a483d302a8642bd4f7..947de8cf258c73d8a327ef3a1daed417ba533f1b 100644 (file)
--- a/builtin-prune.c
+++ b/builtin-prune.c
static int show_only;
static unsigned long expire;
+static int prune_tmp_object(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;
+ }
+ printf("Removing stale temporary file %s\n", fullpath);
+ if (!show_only)
+ unlink(fullpath);
+ return 0;
+}
+
static int prune_object(char *path, const char *filename, const unsigned char *sha1)
{
const char *fullpath = mkpath("%s/%s", path, filename);
if (de->d_name[0] != '.')
break;
continue;
+ case 14:
+ if (prefixcmp(de->d_name, "tmp_obj_"))
+ break;
+ prune_tmp_object(path, de->d_name);
+ continue;
case 38:
sprintf(name, "%02x", i);
memcpy(name+2, de->d_name, len+1);
dirname);
return;
}
- while ((de = readdir(dir)) != NULL) {
- if (!prefixcmp(de->d_name, "tmp_")) {
- char name[PATH_MAX];
- int c = snprintf(name, PATH_MAX, "%s/%s",
- dirname, de->d_name);
- if (c < 0 || c >= PATH_MAX)
- continue;
- if (expire) {
- struct stat st;
- if (stat(name, &st) != 0 || st.st_mtime >= expire)
- continue;
- }
- printf("Removing stale temporary file %s\n", name);
- if (!show_only)
- unlink(name);
- }
- }
+ while ((de = readdir(dir)) != NULL)
+ if (!prefixcmp(de->d_name, "tmp_"))
+ prune_tmp_object(dirname, de->d_name);
closedir(dir);
}