* [PATCH] Do not perform cross-directory renames when creating packs
@ 2008-09-22 17:20 Petr Baudis
2008-09-22 17:31 ` Linus Torvalds
2008-09-22 23:34 ` [PATCH] builtin-prune.c: prune temporary packs in <object_dir>/pack directory Brandon Casey
0 siblings, 2 replies; 4+ messages in thread
From: Petr Baudis @ 2008-09-22 17:20 UTC (permalink / raw)
To: git, git; +Cc: gitster
A comment on top of create_tmpfile() describes caveats ('can have
problems on various systems (FAT, NFS, Coda)') that should apply
in this situation as well. This in the end did not end up solving
any of my personal problems, but it might be a useful cleanup patch
nevertheless.
Signed-off-by: Petr Baudis <pasky@suse.cz>
---
If this one gets dropped now, I don't intend pursuing it further.
builtin-pack-objects.c | 2 +-
fast-import.c | 4 ++--
index-pack.c | 2 +-
pack-write.c | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index 5fc1b8c..1158e42 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -465,7 +465,7 @@ static void write_pack_file(void)
char tmpname[PATH_MAX];
int fd;
snprintf(tmpname, sizeof(tmpname),
- "%s/tmp_pack_XXXXXX", get_object_directory());
+ "%s/pack/tmp_pack_XXXXXX", get_object_directory());
fd = xmkstemp(tmpname);
pack_tmp_name = xstrdup(tmpname);
f = sha1fd(fd, pack_tmp_name);
diff --git a/fast-import.c b/fast-import.c
index ccdf2e5..ab6689a 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -816,7 +816,7 @@ static void start_packfile(void)
int pack_fd;
snprintf(tmpfile, sizeof(tmpfile),
- "%s/tmp_pack_XXXXXX", get_object_directory());
+ "%s/pack/tmp_pack_XXXXXX", get_object_directory());
pack_fd = xmkstemp(tmpfile);
p = xcalloc(1, sizeof(*p) + strlen(tmpfile) + 2);
strcpy(p->pack_name, tmpfile);
@@ -878,7 +878,7 @@ static char *create_index(void)
}
snprintf(tmpfile, sizeof(tmpfile),
- "%s/tmp_idx_XXXXXX", get_object_directory());
+ "%s/pack/tmp_idx_XXXXXX", get_object_directory());
idx_fd = xmkstemp(tmpfile);
f = sha1fd(idx_fd, tmpfile);
sha1write(f, array, 256 * sizeof(int));
diff --git a/index-pack.c b/index-pack.c
index a6e91fe..530d820 100644
--- a/index-pack.c
+++ b/index-pack.c
@@ -172,7 +172,7 @@ static char *open_pack_file(char *pack_name)
if (!pack_name) {
static char tmpfile[PATH_MAX];
snprintf(tmpfile, sizeof(tmpfile),
- "%s/tmp_pack_XXXXXX", get_object_directory());
+ "%s/pack/tmp_pack_XXXXXX", get_object_directory());
output_fd = xmkstemp(tmpfile);
pack_name = xstrdup(tmpfile);
} else
diff --git a/pack-write.c b/pack-write.c
index 939ed56..3621f1d 100644
--- a/pack-write.c
+++ b/pack-write.c
@@ -45,7 +45,7 @@ char *write_idx_file(char *index_name, struct pack_idx_entry **objects,
if (!index_name) {
static char tmpfile[PATH_MAX];
snprintf(tmpfile, sizeof(tmpfile),
- "%s/tmp_idx_XXXXXX", get_object_directory());
+ "%s/pack/tmp_idx_XXXXXX", get_object_directory());
fd = xmkstemp(tmpfile);
index_name = xstrdup(tmpfile);
} else {
--
tg: (fe33b33..) t/pack/crossdir (depends on: vanilla/master)
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Do not perform cross-directory renames when creating packs
2008-09-22 17:20 [PATCH] Do not perform cross-directory renames when creating packs Petr Baudis
@ 2008-09-22 17:31 ` Linus Torvalds
2008-09-22 23:34 ` [PATCH] builtin-prune.c: prune temporary packs in <object_dir>/pack directory Brandon Casey
1 sibling, 0 replies; 4+ messages in thread
From: Linus Torvalds @ 2008-09-22 17:31 UTC (permalink / raw)
To: Petr Baudis; +Cc: Git Mailing List, Junio C Hamano
On Mon, 22 Sep 2008, Petr Baudis wrote:
>
> A comment on top of create_tmpfile() describes caveats ('can have
> problems on various systems (FAT, NFS, Coda)') that should apply
> in this situation as well. This in the end did not end up solving
> any of my personal problems, but it might be a useful cleanup patch
> nevertheless.
Side note: the cross-directory avoidance for loose object creation _did_
seem to clear up the original problems reported on NFS, so yes, this is
worth doing. Even if pack-file creation is such a heavy event that I
suspect that none of the timing/caching/whatever issues that were present
for loose objects really ever trigger in practice.
> Signed-off-by: Petr Baudis <pasky@suse.cz>
Looks obvious enough. So:
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Linus
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] builtin-prune.c: prune temporary packs in <object_dir>/pack directory
2008-09-22 17:20 [PATCH] Do not perform cross-directory renames when creating packs Petr Baudis
2008-09-22 17:31 ` Linus Torvalds
@ 2008-09-22 23:34 ` Brandon Casey
2008-09-23 5:37 ` David Tweed
1 sibling, 1 reply; 4+ messages in thread
From: Brandon Casey @ 2008-09-22 23:34 UTC (permalink / raw)
To: Petr Baudis; +Cc: Git Mailing List, Junio C Hamano
Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
---
Re: [PATCH] Do not perform cross-directory renames when creating packs
I think something like this should be applied on top.
-brandon
builtin-prune.c | 18 ++++++++++--------
1 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/builtin-prune.c b/builtin-prune.c
index c767a0a..fc8be45 100644
--- a/builtin-prune.c
+++ b/builtin-prune.c
@@ -13,7 +13,7 @@ static const char * const prune_usage[] = {
static int show_only;
static unsigned long expire;
-static int prune_tmp_object(char *path, const char *filename)
+static int prune_tmp_object(const char *path, const char *filename)
{
const char *fullpath = mkpath("%s/%s", path, filename);
if (expire) {
@@ -113,21 +113,19 @@ static void prune_object_dir(const char *path)
* files begining with "tmp_") accumulating in the
* object directory.
*/
-static void remove_temporary_files(void)
+static void remove_temporary_files(const char *path)
{
DIR *dir;
struct dirent *de;
- char* dirname=get_object_directory();
- dir = opendir(dirname);
+ dir = opendir(path);
if (!dir) {
- fprintf(stderr, "Unable to open object directory %s\n",
- dirname);
+ fprintf(stderr, "Unable to open directory %s\n", path);
return;
}
while ((de = readdir(dir)) != NULL)
if (!prefixcmp(de->d_name, "tmp_"))
- prune_tmp_object(dirname, de->d_name);
+ prune_tmp_object(path, de->d_name);
closedir(dir);
}
@@ -141,6 +139,7 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
"expire objects older than <time>"),
OPT_END()
};
+ char *s;
save_commit_buffer = 0;
init_revisions(&revs, prefix);
@@ -163,6 +162,9 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
prune_object_dir(get_object_directory());
prune_packed_objects(show_only);
- remove_temporary_files();
+ remove_temporary_files(get_object_directory());
+ s = xstrdup(mkpath("%s/pack", get_object_directory()));
+ remove_temporary_files(s);
+ free(s);
return 0;
}
--
1.6.0.1.244.gdc19
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] builtin-prune.c: prune temporary packs in <object_dir>/pack directory
2008-09-22 23:34 ` [PATCH] builtin-prune.c: prune temporary packs in <object_dir>/pack directory Brandon Casey
@ 2008-09-23 5:37 ` David Tweed
0 siblings, 0 replies; 4+ messages in thread
From: David Tweed @ 2008-09-23 5:37 UTC (permalink / raw)
To: Brandon Casey; +Cc: Petr Baudis, Git Mailing List, Junio C Hamano
On Tue, Sep 23, 2008 at 12:34 AM, Brandon Casey <casey@nrlssc.navy.mil> wrote:
> Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
> ---
>
> Re: [PATCH] Do not perform cross-directory renames when creating packs
>
> I think something like this should be applied on top.
>
> -brandon
>
>
> builtin-prune.c | 18 ++++++++++--------
> 1 files changed, 10 insertions(+), 8 deletions(-)
>
> diff --git a/builtin-prune.c b/builtin-prune.c
> index c767a0a..fc8be45 100644
> --- a/builtin-prune.c
> +++ b/builtin-prune.c
> @@ -13,7 +13,7 @@ static const char * const prune_usage[] = {
> static int show_only;
> static unsigned long expire;
>
> -static int prune_tmp_object(char *path, const char *filename)
> +static int prune_tmp_object(const char *path, const char *filename)
> {
> const char *fullpath = mkpath("%s/%s", path, filename);
> if (expire) {
> @@ -113,21 +113,19 @@ static void prune_object_dir(const char *path)
> * files begining with "tmp_") accumulating in the
> * object directory.
> */
Good spotting. I haven't been remotely involved with git recently but
for what little it's worth looks the right thing to me. It'd be nice
to modify the patch to keep the comment up to date, something like:
* accumulating in the
* object directory (older git versions) or pack directory.
*/
--
cheers, dave tweed__________________________
david.tweed@gmail.com
Rm 124, School of Systems Engineering, University of Reading.
"while having code so boring anyone can maintain it, use Python." --
attempted insult seen on slashdot
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-09-23 5:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-22 17:20 [PATCH] Do not perform cross-directory renames when creating packs Petr Baudis
2008-09-22 17:31 ` Linus Torvalds
2008-09-22 23:34 ` [PATCH] builtin-prune.c: prune temporary packs in <object_dir>/pack directory Brandon Casey
2008-09-23 5:37 ` David Tweed
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).