{"thread":{"id":"6346","subject":"[PATCH] Make git-repack explain what it's doing during prune","startedAt":"2007-01-12T02:46:23Z","lastAt":"2007-01-12T22:55:43Z","messageCount":2,"participants":["Steven Grimm","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"31537","messageId":"20070112024623.GA9787@midwinter.com","threadId":"6346","inReplyTo":null,"subject":"[PATCH] Make git-repack explain what it's doing during prune","fromName":"Steven Grimm","fromEmail":"koreth@midwinter.com","sentAt":"2007-01-12T02:46:23Z","receivedAt":"2007-01-12T02:46:23Z","isPatch":true,"sender":{"key":"koreth@midwinter.com","avatar":"https://gravatar.com/avatar/71b4d2e8b62f168bdc9e9205341159e3567003b4f9e2127c617c5fa0a1f5bad2?d=mp&s=160"},"body":"git-pack-objects reports its progress as it runs, but as soon as it\nfinishes and git-repack (with -d option) runs git-prune-packed, the\nuser is left in the dark about what's going on. That makes git-repack\nfeel inconsistent: it starts off with a bunch of progress reports then\nappears to just sit there for a while before finishing.\n\nSigned-off-by: Steven Grimm <koreth@midwinter.com>\n---\n git-repack.sh |    3 +++\n 1 files changed, 3 insertions(+), 0 deletions(-)\n\ndiff --git a/git-repack.sh b/git-repack.sh\nindex 375434b..a69d915 100755\n--- a/git-repack.sh\n+++ b/git-repack.sh\n@@ -110,6 +110,9 @@ then\n \t\t  done\n \t\t)\n \tfi\n+\tif test \"$quiet\" != '-q'; then\n+\t    echo \"Removing unused objects...\"\n+\tfi\n \tgit-prune-packed\n fi\n \n-- \n1.4.4.4.g1295-dirty\n"},{"id":"31605","messageId":"7v8xg7rh1s.fsf@assigned-by-dhcp.cox.net","threadId":"6346","inReplyTo":"20070112024623.GA9787@midwinter.com","subject":"Re: [PATCH] Make git-repack explain what it's doing during prune","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-01-12T22:55:43Z","receivedAt":"2007-01-12T22:55:43Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Steven Grimm <koreth@midwinter.com> writes:\n\n> git-pack-objects reports its progress as it runs, but as soon as it\n> finishes and git-repack (with -d option) runs git-prune-packed, the\n> user is left in the dark about what's going on. That makes git-repack\n> feel inconsistent: it starts off with a bunch of progress reports then\n> appears to just sit there for a while before finishing.\n\nI think this is a very good idea, but why don't we go all the\nway?  Perhaps like this?\n\n-- >8 --\n\ndiff --git a/git-repack.sh b/git-repack.sh\nindex 375434b..da8e67f 100755\n--- a/git-repack.sh\n+++ b/git-repack.sh\n@@ -110,7 +110,7 @@ then\n \t\t  done\n \t\t)\n \tfi\n-\tgit-prune-packed\n+\tgit-prune-packed $quiet\n fi\n \n case \"$no_update_info\" in\ndiff --git a/builtin-prune-packed.c b/builtin-prune-packed.c\nindex 24e3b0a..e67d371 100644\n--- a/builtin-prune-packed.c\n+++ b/builtin-prune-packed.c\n@@ -4,7 +4,10 @@\n static const char prune_packed_usage[] =\n \"git-prune-packed [-n]\";\n \n-static void prune_dir(int i, DIR *dir, char *pathname, int len, int dryrun)\n+#define DRY_RUN 01\n+#define VERBOSE 02\n+\n+static void prune_dir(int i, DIR *dir, char *pathname, int len, int opts)\n {\n \tstruct dirent *de;\n \tchar hex[40];\n@@ -20,7 +23,7 @@ static void prune_dir(int i, DIR *dir, char *pathname, int len, int dryrun)\n \t\tif (!has_sha1_pack(sha1, NULL))\n \t\t\tcontinue;\n \t\tmemcpy(pathname + len, de->d_name, 38);\n-\t\tif (dryrun)\n+\t\tif (opts & DRY_RUN)\n \t\t\tprintf(\"rm -f %s\\n\", pathname);\n \t\telse if (unlink(pathname) < 0)\n \t\t\terror(\"unable to unlink %s\", pathname);\n@@ -29,7 +32,7 @@ static void prune_dir(int i, DIR *dir, char *pathname, int len, int dryrun)\n \trmdir(pathname);\n }\n \n-void prune_packed_objects(int dryrun)\n+void prune_packed_objects(int opts)\n {\n \tint i;\n \tstatic char pathname[PATH_MAX];\n@@ -48,22 +51,29 @@ void prune_packed_objects(int dryrun)\n \t\td = opendir(pathname);\n \t\tif (!d)\n \t\t\tcontinue;\n-\t\tprune_dir(i, d, pathname, len + 3, dryrun);\n+\t\tprune_dir(i, d, pathname, len + 3, opts);\n \t\tclosedir(d);\n+\t\tif (opts == VERBOSE)\n+\t\t\tfprintf(stderr, \"Prune-packed %d%%...\\015\",\n+\t\t\t\t((i+1) * 100) / 256);\n \t}\n+\tif (opts == VERBOSE)\n+\t\tfprintf(stderr, \"\\nDone.\\n\");\n }\n \n int cmd_prune_packed(int argc, const char **argv, const char *prefix)\n {\n \tint i;\n-\tint dryrun = 0;\n+\tint opts = VERBOSE;\n \n \tfor (i = 1; i < argc; i++) {\n \t\tconst char *arg = argv[i];\n \n \t\tif (*arg == '-') {\n \t\t\tif (!strcmp(arg, \"-n\"))\n-\t\t\t\tdryrun = 1;\n+\t\t\t\topts |= DRY_RUN;\n+\t\t\telse if (!strcmp(arg, \"-q\"))\n+\t\t\t\topts &= ~VERBOSE;\n \t\t\telse\n \t\t\t\tusage(prune_packed_usage);\n \t\t\tcontinue;\n@@ -72,6 +82,6 @@ int cmd_prune_packed(int argc, const char **argv, const char *prefix)\n \t\tusage(prune_packed_usage);\n \t}\n \tsync();\n-\tprune_packed_objects(dryrun);\n+\tprune_packed_objects(opts);\n \treturn 0;\n }\n"}]}