{"thread":{"id":"15625","subject":"Re: [PATCH] Do not perform cross-directory renames when creating packs","startedAt":"2008-09-22T17:20:21Z","lastAt":"2008-09-23T05:37:51Z","messageCount":4,"participants":["Linus Torvalds","Brandon Casey","David Tweed","Petr Baudis"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"299064","messageId":"1222104021-28277-1-git-send-email-pasky@suse.cz","threadId":"15625","inReplyTo":null,"subject":"[PATCH] Do not perform cross-directory renames when creating packs","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2008-09-22T17:20:21Z","receivedAt":"2008-09-22T17:20:21Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"A comment on top of create_tmpfile() describes caveats ('can have\nproblems on various systems (FAT, NFS, Coda)') that should apply\nin this situation as well.  This in the end did not end up solving\nany of my personal problems, but it might be a useful cleanup patch\nnevertheless.\n\nSigned-off-by: Petr Baudis <pasky@suse.cz>\n\n---\n\nIf this one gets dropped now, I don't intend pursuing it further.\n\n builtin-pack-objects.c |    2 +-\n fast-import.c          |    4 ++--\n index-pack.c           |    2 +-\n pack-write.c           |    2 +-\n 4 files changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin-pack-objects.c b/builtin-pack-objects.c\nindex 5fc1b8c..1158e42 100644\n--- a/builtin-pack-objects.c\n+++ b/builtin-pack-objects.c\n@@ -465,7 +465,7 @@ static void write_pack_file(void)\n \t\t\tchar tmpname[PATH_MAX];\n \t\t\tint fd;\n \t\t\tsnprintf(tmpname, sizeof(tmpname),\n-\t\t\t\t \"%s/tmp_pack_XXXXXX\", get_object_directory());\n+\t\t\t\t \"%s/pack/tmp_pack_XXXXXX\", get_object_directory());\n \t\t\tfd = xmkstemp(tmpname);\n \t\t\tpack_tmp_name = xstrdup(tmpname);\n \t\t\tf = sha1fd(fd, pack_tmp_name);\ndiff --git a/fast-import.c b/fast-import.c\nindex ccdf2e5..ab6689a 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -816,7 +816,7 @@ static void start_packfile(void)\n \tint pack_fd;\n \n \tsnprintf(tmpfile, sizeof(tmpfile),\n-\t\t\"%s/tmp_pack_XXXXXX\", get_object_directory());\n+\t\t\"%s/pack/tmp_pack_XXXXXX\", get_object_directory());\n \tpack_fd = xmkstemp(tmpfile);\n \tp = xcalloc(1, sizeof(*p) + strlen(tmpfile) + 2);\n \tstrcpy(p->pack_name, tmpfile);\n@@ -878,7 +878,7 @@ static char *create_index(void)\n \t}\n \n \tsnprintf(tmpfile, sizeof(tmpfile),\n-\t\t\"%s/tmp_idx_XXXXXX\", get_object_directory());\n+\t\t\"%s/pack/tmp_idx_XXXXXX\", get_object_directory());\n \tidx_fd = xmkstemp(tmpfile);\n \tf = sha1fd(idx_fd, tmpfile);\n \tsha1write(f, array, 256 * sizeof(int));\ndiff --git a/index-pack.c b/index-pack.c\nindex a6e91fe..530d820 100644\n--- a/index-pack.c\n+++ b/index-pack.c\n@@ -172,7 +172,7 @@ static char *open_pack_file(char *pack_name)\n \t\tif (!pack_name) {\n \t\t\tstatic char tmpfile[PATH_MAX];\n \t\t\tsnprintf(tmpfile, sizeof(tmpfile),\n-\t\t\t\t \"%s/tmp_pack_XXXXXX\", get_object_directory());\n+\t\t\t\t \"%s/pack/tmp_pack_XXXXXX\", get_object_directory());\n \t\t\toutput_fd = xmkstemp(tmpfile);\n \t\t\tpack_name = xstrdup(tmpfile);\n \t\t} else\ndiff --git a/pack-write.c b/pack-write.c\nindex 939ed56..3621f1d 100644\n--- a/pack-write.c\n+++ b/pack-write.c\n@@ -45,7 +45,7 @@ char *write_idx_file(char *index_name, struct pack_idx_entry **objects,\n \tif (!index_name) {\n \t\tstatic char tmpfile[PATH_MAX];\n \t\tsnprintf(tmpfile, sizeof(tmpfile),\n-\t\t\t \"%s/tmp_idx_XXXXXX\", get_object_directory());\n+\t\t\t \"%s/pack/tmp_idx_XXXXXX\", get_object_directory());\n \t\tfd = xmkstemp(tmpfile);\n \t\tindex_name = xstrdup(tmpfile);\n \t} else {\n-- \ntg: (fe33b33..) t/pack/crossdir (depends on: vanilla/master)\n"},{"id":"91329","messageId":"alpine.LFD.1.10.0809221029240.3265@nehalem.linux-foundation.org","threadId":"15625","inReplyTo":"1222104021-28277-1-git-send-email-pasky@suse.cz","subject":"Re: [PATCH] Do not perform cross-directory renames when creating packs","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2008-09-22T17:31:47Z","receivedAt":"2008-09-22T17:31:47Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Mon, 22 Sep 2008, Petr Baudis wrote:\n>\n> A comment on top of create_tmpfile() describes caveats ('can have\n> problems on various systems (FAT, NFS, Coda)') that should apply\n> in this situation as well.  This in the end did not end up solving\n> any of my personal problems, but it might be a useful cleanup patch\n> nevertheless.\n\nSide note: the cross-directory avoidance for loose object creation _did_ \nseem to clear up the original problems reported on NFS, so yes, this is \nworth doing. Even if pack-file creation is such a heavy event that I \nsuspect that none of the timing/caching/whatever issues that were present \nfor loose objects really ever trigger in practice.\n\n> Signed-off-by: Petr Baudis <pasky@suse.cz>\n\nLooks obvious enough. So:\n\nAcked-by: Linus Torvalds <torvalds@linux-foundation.org>\n\n\t\tLinus\n"},{"id":"91346","messageId":"KKSursEoVthEbqc_O82_QIafgU9zgb4bQYP7w6x9ulU85L2Nixe_9g@cipher.nrlssc.navy.mil","threadId":"15625","inReplyTo":"1222104021-28277-1-git-send-email-pasky@suse.cz","subject":"[PATCH] builtin-prune.c: prune temporary packs in <object_dir>/pack directory","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-09-22T23:34:26Z","receivedAt":"2008-09-22T23:34:26Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>\n---\n\nRe: [PATCH] Do not perform cross-directory renames when creating packs\n\nI think something like this should be applied on top.\n\n-brandon\n\n\n builtin-prune.c |   18 ++++++++++--------\n 1 files changed, 10 insertions(+), 8 deletions(-)\n\ndiff --git a/builtin-prune.c b/builtin-prune.c\nindex c767a0a..fc8be45 100644\n--- a/builtin-prune.c\n+++ b/builtin-prune.c\n@@ -13,7 +13,7 @@ static const char * const prune_usage[] = {\n static int show_only;\n static unsigned long expire;\n \n-static int prune_tmp_object(char *path, const char *filename)\n+static int prune_tmp_object(const char *path, const char *filename)\n {\n \tconst char *fullpath = mkpath(\"%s/%s\", path, filename);\n \tif (expire) {\n@@ -113,21 +113,19 @@ static void prune_object_dir(const char *path)\n  * files begining with \"tmp_\") accumulating in the\n  * object directory.\n  */\n-static void remove_temporary_files(void)\n+static void remove_temporary_files(const char *path)\n {\n \tDIR *dir;\n \tstruct dirent *de;\n-\tchar* dirname=get_object_directory();\n \n-\tdir = opendir(dirname);\n+\tdir = opendir(path);\n \tif (!dir) {\n-\t\tfprintf(stderr, \"Unable to open object directory %s\\n\",\n-\t\t\tdirname);\n+\t\tfprintf(stderr, \"Unable to open directory %s\\n\", path);\n \t\treturn;\n \t}\n \twhile ((de = readdir(dir)) != NULL)\n \t\tif (!prefixcmp(de->d_name, \"tmp_\"))\n-\t\t\tprune_tmp_object(dirname, de->d_name);\n+\t\t\tprune_tmp_object(path, de->d_name);\n \tclosedir(dir);\n }\n \n@@ -141,6 +139,7 @@ int cmd_prune(int argc, const char **argv, const char *prefix)\n \t\t\t \"expire objects older than <time>\"),\n \t\tOPT_END()\n \t};\n+\tchar *s;\n \n \tsave_commit_buffer = 0;\n \tinit_revisions(&revs, prefix);\n@@ -163,6 +162,9 @@ int cmd_prune(int argc, const char **argv, const char *prefix)\n \tprune_object_dir(get_object_directory());\n \n \tprune_packed_objects(show_only);\n-\tremove_temporary_files();\n+\tremove_temporary_files(get_object_directory());\n+\ts = xstrdup(mkpath(\"%s/pack\", get_object_directory()));\n+\tremove_temporary_files(s);\n+\tfree(s);\n \treturn 0;\n }\n-- \n1.6.0.1.244.gdc19\n"},{"id":"91353","messageId":"e1dab3980809222237v612bfc82n8865ada7f0e4516d@mail.gmail.com","threadId":"15625","inReplyTo":"KKSursEoVthEbqc_O82_QIafgU9zgb4bQYP7w6x9ulU85L2Nixe_9g@cipher.nrlssc.navy.mil","subject":"Re: [PATCH] builtin-prune.c: prune temporary packs in <object_dir>/pack directory","fromName":"David Tweed","fromEmail":"david.tweed@gmail.com","sentAt":"2008-09-23T05:37:51Z","receivedAt":"2008-09-23T05:37:51Z","isPatch":true,"sender":{"key":"david.tweed@gmail.com","avatar":null},"body":"On Tue, Sep 23, 2008 at 12:34 AM, Brandon Casey <casey@nrlssc.navy.mil> wrote:\n> Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>\n> ---\n>\n> Re: [PATCH] Do not perform cross-directory renames when creating packs\n>\n> I think something like this should be applied on top.\n>\n> -brandon\n>\n>\n>  builtin-prune.c |   18 ++++++++++--------\n>  1 files changed, 10 insertions(+), 8 deletions(-)\n>\n> diff --git a/builtin-prune.c b/builtin-prune.c\n> index c767a0a..fc8be45 100644\n> --- a/builtin-prune.c\n> +++ b/builtin-prune.c\n> @@ -13,7 +13,7 @@ static const char * const prune_usage[] = {\n>  static int show_only;\n>  static unsigned long expire;\n>\n> -static int prune_tmp_object(char *path, const char *filename)\n> +static int prune_tmp_object(const char *path, const char *filename)\n>  {\n>        const char *fullpath = mkpath(\"%s/%s\", path, filename);\n>        if (expire) {\n> @@ -113,21 +113,19 @@ static void prune_object_dir(const char *path)\n>  * files begining with \"tmp_\") accumulating in the\n>  * object directory.\n>  */\n\nGood spotting. I haven't been remotely involved with git recently but\nfor what little it's worth looks the right thing to me. It'd be nice\nto modify the patch to keep the comment up to date, something like:\n\n* accumulating in the\n* object directory (older git versions) or pack directory.\n*/\n\n-- \ncheers, dave tweed__________________________\ndavid.tweed@gmail.com\nRm 124, School of Systems Engineering, University of Reading.\n\"while having code so boring anyone can maintain it, use Python.\" --\nattempted insult seen on slashdot\n"}]}