{"thread":{"id":"19197","subject":"[PATCH] git-remote: make remote name optional for prune operation","startedAt":"2009-05-06T14:37:01Z","lastAt":"2009-05-06T17:55:00Z","messageCount":9,"participants":["Julien Danjou","Francis Galiegue","Jacob Helwig","Michael J Gruber","Junio C Hamano","Finn Arne Gangstad"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"113085","messageId":"1241620621-12188-1-git-send-email-julien@danjou.info","threadId":"19197","inReplyTo":null,"subject":"[PATCH] git-remote: make remote name optional for prune operation","fromName":"Julien Danjou","fromEmail":"julien@danjou.info","sentAt":"2009-05-06T14:37:01Z","receivedAt":"2009-05-06T14:37:01Z","isPatch":true,"sender":{"key":"julien@danjou.info","avatar":"https://gravatar.com/avatar/ffa7d412ada4692aa7869967c20c24a63a8c44c7b6012792f9018a4a89b03743?d=mp&s=160"},"body":"We consider that if `git remote prune` is called without a name, we\nactually want to prune all remotes.\n\nSigned-off-by: Julien Danjou <julien@danjou.info>\n---\n Documentation/git-remote.txt |    2 +-\n builtin-remote.c             |   26 +++++++++++++++++++++-----\n 2 files changed, 22 insertions(+), 6 deletions(-)\n\ndiff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt\nindex 9e2b4ea..c566061 100644\n--- a/Documentation/git-remote.txt\n+++ b/Documentation/git-remote.txt\n@@ -15,7 +15,7 @@ SYNOPSIS\n 'git remote rm' <name>\n 'git remote set-head' <name> [-a | -d | <branch>]\n 'git remote show' [-n] <name>\n-'git remote prune' [-n | --dry-run] <name>\n+'git remote prune' [-n | --dry-run] [name]\n 'git remote update' [-p | --prune] [group | remote]...\n \n DESCRIPTION\ndiff --git a/builtin-remote.c b/builtin-remote.c\nindex 2ed752c..053d886 100644\n--- a/builtin-remote.c\n+++ b/builtin-remote.c\n@@ -14,7 +14,7 @@ static const char * const builtin_remote_usage[] = {\n \t\"git remote rm <name>\",\n \t\"git remote set-head <name> [-a | -d | <branch>]\",\n \t\"git remote show [-n] <name>\",\n-\t\"git remote prune [-n | --dry-run] <name>\",\n+\t\"git remote prune [-n | --dry-run] [name]\",\n \t\"git remote [-v | --verbose] update [-p | --prune] [group]\",\n \tNULL\n };\n@@ -25,6 +25,7 @@ static const char * const builtin_remote_usage[] = {\n \n static int verbose;\n \n+static int get_one_entry(struct remote *remote, void *priv);\n static int show_all(void);\n static int prune_remote(const char *remote, int dry_run);\n \n@@ -1133,10 +1134,25 @@ static int prune(int argc, const char **argv)\n \targc = parse_options(argc, argv, options, builtin_remote_usage, 0);\n \n \tif (argc < 1)\n-\t\tusage_with_options(builtin_remote_usage, options);\n+\t{\n+\t\tstruct string_list list = { NULL, 0, 0 };\n+\t\tint result = for_each_remote(get_one_entry, &list);\n+\n+\t\tif (!result) {\n+\t\t\tint i;\n \n-\tfor (; argc; argc--, argv++)\n-\t\tresult |= prune_remote(*argv, dry_run);\n+\t\t\tsort_string_list(&list);\n+\t\t\tfor (i = 0; i < list.nr; i++) {\n+\t\t\t\tstruct string_list_item *item = list.items + i;\n+\t\t\t\tif (i && !strcmp((item - 1)->string, item->string))\n+\t\t\t\t       continue;\n+\t\t\t\tresult |= prune_remote(item->string, dry_run);\n+\t\t\t}\n+\t\t}\n+\t}\n+\telse\n+\t\tfor (; argc; argc--, argv++)\n+\t\t\tresult |= prune_remote(*argv, dry_run);\n \n \treturn result;\n }\n-- \n1.6.2.4\n"},{"id":"113086","messageId":"200905061649.25351.fge@one2team.com","threadId":"19197","inReplyTo":"1241620621-12188-1-git-send-email-julien@danjou.info","subject":"Re: [PATCH] git-remote: make remote name optional for prune operation","fromName":"Francis Galiegue","fromEmail":"fge@one2team.com","sentAt":"2009-05-06T14:49:25Z","receivedAt":"2009-05-06T14:49:25Z","isPatch":true,"sender":{"key":"fge@one2team.com","avatar":null},"body":"Le mercredi 06 mai 2009, Julien Danjou a écrit :\n\n[...]\n\nDidn't you forget a little something in your patch?\n\n[...]\n> diff --git a/builtin-remote.c b/builtin-remote.c\n[...]\n> @@ -25,6 +25,7 @@ static const char * const builtin_remote_usage[] = {\n>  \n>  static int verbose;\n>  \n> +static int get_one_entry(struct remote *remote, void *priv);\n>  static int show_all(void);\n[...]\n>  \n>  \tif (argc < 1)\n> -\t\tusage_with_options(builtin_remote_usage, options);\n> +\t{\n> +\t\tstruct string_list list = { NULL, 0, 0 };\n> +\t\tint result = for_each_remote(get_one_entry, &list);\n\n\n\n-- \nFrancis Galiegue\nONE2TEAM\nIngénieur système\nMob : +33 (0) 683 877 875\nTel : +33 (0) 178 945 552\nfge@one2team.com\n40 avenue Raymond Poincaré\n75116 Paris\n"},{"id":"113089","messageId":"20090506153212.GF10701@abydos.adm.naquadah.org","threadId":"19197","inReplyTo":"200905061649.25351.fge@one2team.com","subject":"Re: [PATCH] git-remote: make remote name optional for prune operation","fromName":"Julien Danjou","fromEmail":"julien@danjou.info","sentAt":"2009-05-06T15:32:12Z","receivedAt":"2009-05-06T15:32:12Z","isPatch":true,"sender":{"key":"julien@danjou.info","avatar":"https://gravatar.com/avatar/ffa7d412ada4692aa7869967c20c24a63a8c44c7b6012792f9018a4a89b03743?d=mp&s=160"},"body":"At 1241621365 time_t, Francis Galiegue wrote:\n> Didn't you forget a little something in your patch?\n\nIf so, I really can't see what.\n\nCheers,\n-- \nJulien Danjou\n// ᐰ <julien@danjou.info>   http://julien.danjou.info\n// 9A0D 5FD9 EB42 22F6 8974  C95C A462 B51E C2FE E5CD\n// Tomorrow I was nothing, yesterday I'll be.\n"},{"id":"113090","messageId":"8c9a060905060846o1a7b26b0m78ff0cbe48648873@mail.gmail.com","threadId":"19197","inReplyTo":"20090506153212.GF10701@abydos.adm.naquadah.org","subject":"Re: [PATCH] git-remote: make remote name optional for prune operation","fromName":"Jacob Helwig","fromEmail":"jacob.helwig@gmail.com","sentAt":"2009-05-06T15:46:48Z","receivedAt":"2009-05-06T15:46:48Z","isPatch":true,"sender":{"key":"jacob.helwig@gmail.com","avatar":"https://avatars.githubusercontent.com/u/14557?v=4"},"body":"On Wed, May 6, 2009 at 08:32, Julien Danjou <julien@danjou.info> wrote:\n> At 1241621365 time_t, Francis Galiegue wrote:\n>> Didn't you forget a little something in your patch?\n>\n> If so, I really can't see what.\n>\n> Cheers,\n> --\n> Julien Danjou\n> // ᐰ <julien@danjou.info>   http://julien.danjou.info\n> // 9A0D 5FD9 EB42 22F6 8974  C95C A462 B51E C2FE E5CD\n> // Tomorrow I was nothing, yesterday I'll be.\n>\n> -----BEGIN PGP SIGNATURE-----\n> Version: GnuPG v1.4.9 (GNU/Linux)\n>\n> iEYEARECAAYFAkoBrXoACgkQpGK1HsL+5c1TdwCgltFTU6aZmLUWzXFzNkq7Dqo5\n> FywAoJTEUtDJO2LrzQyu+jB0vf9XCbe2\n> =pF1M\n> -----END PGP SIGNATURE-----\n>\n>\n\nI'm guessing, but perhaps Francis means a test for this behavior?\n"},{"id":"113094","messageId":"4A01B7A7.9020308@drmicha.warpmail.net","threadId":"19197","inReplyTo":"8c9a060905060846o1a7b26b0m78ff0cbe48648873@mail.gmail.com","subject":"Re: [PATCH] git-remote: make remote name optional for prune operation","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-05-06T16:15:35Z","receivedAt":"2009-05-06T16:15:35Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Jacob Helwig venit, vidit, dixit 06.05.2009 17:46:\n> On Wed, May 6, 2009 at 08:32, Julien Danjou <julien@danjou.info> wrote:\n>> At 1241621365 time_t, Francis Galiegue wrote:\n>>> Didn't you forget a little something in your patch?\n>>\n>> If so, I really can't see what.\n>>\n>> Cheers,\n>> --\n>> Julien Danjou\n> \n> I'm guessing, but perhaps Francis means a test for this behavior?\n\nDocumentation (besides changing <> to []), test.\nAlso, it looks as if a get_one_entry() declaration is added without a\ndefinition. But the definition is there already.\n\nMichael\n"},{"id":"113097","messageId":"1241629081-11122-1-git-send-email-julien@danjou.info","threadId":"19197","inReplyTo":"4A01B7A7.9020308@drmicha.warpmail.net","subject":"[PATCH] git-remote: make remote name optional for prune operation","fromName":"Julien Danjou","fromEmail":"julien@danjou.info","sentAt":"2009-05-06T16:58:01Z","receivedAt":"2009-05-06T16:58:01Z","isPatch":true,"sender":{"key":"julien@danjou.info","avatar":"https://gravatar.com/avatar/ffa7d412ada4692aa7869967c20c24a63a8c44c7b6012792f9018a4a89b03743?d=mp&s=160"},"body":"If `git remote prune` is called without a name, prune all remotes.\n\nSigned-off-by: Julien Danjou <julien@danjou.info>\n---\n Documentation/git-remote.txt |    4 +++-\n builtin-remote.c             |   26 +++++++++++++++++++++-----\n t/t5505-remote.sh            |   21 +++++++++++++++++++++\n 3 files changed, 45 insertions(+), 6 deletions(-)\n\ndiff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt\nindex 9e2b4ea..5c8477e 100644\n--- a/Documentation/git-remote.txt\n+++ b/Documentation/git-remote.txt\n@@ -15,7 +15,7 @@ SYNOPSIS\n 'git remote rm' <name>\n 'git remote set-head' <name> [-a | -d | <branch>]\n 'git remote show' [-n] <name>\n-'git remote prune' [-n | --dry-run] <name>\n+'git remote prune' [-n | --dry-run] [name]\n 'git remote update' [-p | --prune] [group | remote]...\n \n DESCRIPTION\n@@ -116,6 +116,8 @@ referenced by <name>, but are still locally available in\n +\n With `--dry-run` option, report what branches will be pruned, but do no\n actually prune them.\n+If <name> is not set, all stale branches from all remote repositories will\n+be deleted.\n \n 'update'::\n \ndiff --git a/builtin-remote.c b/builtin-remote.c\nindex 2ed752c..053d886 100644\n--- a/builtin-remote.c\n+++ b/builtin-remote.c\n@@ -14,7 +14,7 @@ static const char * const builtin_remote_usage[] = {\n \t\"git remote rm <name>\",\n \t\"git remote set-head <name> [-a | -d | <branch>]\",\n \t\"git remote show [-n] <name>\",\n-\t\"git remote prune [-n | --dry-run] <name>\",\n+\t\"git remote prune [-n | --dry-run] [name]\",\n \t\"git remote [-v | --verbose] update [-p | --prune] [group]\",\n \tNULL\n };\n@@ -25,6 +25,7 @@ static const char * const builtin_remote_usage[] = {\n \n static int verbose;\n \n+static int get_one_entry(struct remote *remote, void *priv);\n static int show_all(void);\n static int prune_remote(const char *remote, int dry_run);\n \n@@ -1133,10 +1134,25 @@ static int prune(int argc, const char **argv)\n \targc = parse_options(argc, argv, options, builtin_remote_usage, 0);\n \n \tif (argc < 1)\n-\t\tusage_with_options(builtin_remote_usage, options);\n+\t{\n+\t\tstruct string_list list = { NULL, 0, 0 };\n+\t\tint result = for_each_remote(get_one_entry, &list);\n+\n+\t\tif (!result) {\n+\t\t\tint i;\n \n-\tfor (; argc; argc--, argv++)\n-\t\tresult |= prune_remote(*argv, dry_run);\n+\t\t\tsort_string_list(&list);\n+\t\t\tfor (i = 0; i < list.nr; i++) {\n+\t\t\t\tstruct string_list_item *item = list.items + i;\n+\t\t\t\tif (i && !strcmp((item - 1)->string, item->string))\n+\t\t\t\t       continue;\n+\t\t\t\tresult |= prune_remote(item->string, dry_run);\n+\t\t\t}\n+\t\t}\n+\t}\n+\telse\n+\t\tfor (; argc; argc--, argv++)\n+\t\t\tresult |= prune_remote(*argv, dry_run);\n \n \treturn result;\n }\ndiff --git a/t/t5505-remote.sh b/t/t5505-remote.sh\nindex 5ec668d..cfb7922 100755\n--- a/t/t5505-remote.sh\n+++ b/t/t5505-remote.sh\n@@ -223,6 +223,27 @@ test_expect_success 'prune' '\n \t test_must_fail git rev-parse refs/remotes/origin/side)\n '\n \n+test_expect_success 'prune-all' '\n+\t(cd one &&\n+\t git branch side3 side2) &&\n+        (cd test &&\n+         git fetch origin) &&\n+        (cd one &&\n+         git branch -D side3) &&\n+        (cd two &&\n+         git branch side2 side) &&\n+        (cd test &&\n+         git fetch two) &&\n+        (cd two &&\n+         git branch -D side2) &&\n+\t(cd test &&\n+\t git fetch origin &&\n+         git fetch two &&\n+\t git remote prune &&\n+\t test_must_fail git rev-parse refs/remotes/origin/side3 &&\n+\t test_must_fail git rev-parse refs/remotes/two/side2)\n+'\n+\n test_expect_success 'set-head --delete' '\n \t(cd test &&\n \t git symbolic-ref refs/remotes/origin/HEAD &&\n-- \n1.6.2.4\n"},{"id":"113098","messageId":"7vab5qw3nr.fsf@alter.siamese.dyndns.org","threadId":"19197","inReplyTo":"1241620621-12188-1-git-send-email-julien@danjou.info","subject":"Re: [PATCH] git-remote: make remote name optional for prune operation","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-05-06T17:18:48Z","receivedAt":"2009-05-06T17:18:48Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Julien Danjou <julien@danjou.info> writes:\n\n> We consider that if `git remote prune` is called without a name, we\n> actually want to prune all remotes.\n\nI think we try to make an opearation that discards information from many\nthings at once by mistake, and it feels that this patch goes against it.\n\nIn what situation does this new short-cut make things convenient, and how\noften does such a situation come up?  The only one I can think of is when\nyou are interacting with many volatile remotes that create and delete\nbranches all the time, and when you are trying to repack/pack-ref your\nlocal repository with as much cruft removed, but in such a set-up, next\ntime you interact with your remotes, you will get their \"branch of the\nday\" in your remote tracking namespace that will disappear shortly, and it\ndoes not sound like it is such a big deal if you did not run \"remote\nprune\" to all of them at once anyway.\n\nHaving said all that...\n\n> diff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt\n> index 9e2b4ea..c566061 100644\n> --- a/Documentation/git-remote.txt\n> +++ b/Documentation/git-remote.txt\n> @@ -15,7 +15,7 @@ SYNOPSIS\n>  'git remote rm' <name>\n>  'git remote set-head' <name> [-a | -d | <branch>]\n>  'git remote show' [-n] <name>\n> -'git remote prune' [-n | --dry-run] <name>\n> +'git remote prune' [-n | --dry-run] [name]\n>  'git remote update' [-p | --prune] [group | remote]...\n\nI think you would want to say [<name>] here, but looking at this list, I\nwonder if it would be more appropriate to allow \"remote group\" to be given\nto \"prune\" (and perhaps \"show\").\n"},{"id":"113100","messageId":"7vr5z2ungj.fsf@alter.siamese.dyndns.org","threadId":"19197","inReplyTo":"7vab5qw3nr.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] git-remote: make remote name optional for prune operation","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-05-06T17:54:04Z","receivedAt":"2009-05-06T17:54:04Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> I think we try to make an opearation that discards information from many\n> things at once by mistake, and it feels that this patch goes against it.\n\nSorry, \"by mistake\" should have read \"harder to trigger by mistake\".\n"},{"id":"113101","messageId":"20090506175500.GA19976@pvv.org","threadId":"19197","inReplyTo":"7vab5qw3nr.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] git-remote: make remote name optional for prune operation","fromName":"Finn Arne Gangstad","fromEmail":"finnag@pvv.org","sentAt":"2009-05-06T17:55:00Z","receivedAt":"2009-05-06T17:55:00Z","isPatch":true,"sender":{"key":"finnag@pvv.org","avatar":"https://gravatar.com/avatar/b421ddd58c3f0f93aa473e17b98bb8d53c221fef741746bc8cb59fae4ec6d95e?d=mp&s=160"},"body":"On Wed, May 06, 2009 at 10:18:48AM -0700, Junio C Hamano wrote:\n> Julien Danjou <julien@danjou.info> writes:\n> \n> > We consider that if `git remote prune` is called without a name, we\n> > actually want to prune all remotes.\n> \n> I think we try to make an opearation that discards information from many\n> things at once by mistake, and it feels that this patch goes against it.\n> \n> In what situation does this new short-cut make things convenient, and how\n> often does such a situation come up?  The only one I can think of is when\n> you are interacting with many volatile remotes that create and delete\n> branches all the time, and when you are trying to repack/pack-ref your\n> local repository with as much cruft removed, but in such a set-up, next\n> time you interact with your remotes, you will get their \"branch of the\n> day\" in your remote tracking namespace that will disappear shortly, and it\n> does not sound like it is such a big deal if you did not run \"remote\n> prune\" to all of them at once anyway.\n> \n> Having said all that...\n> \n> > diff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt\n> > index 9e2b4ea..c566061 100644\n> > --- a/Documentation/git-remote.txt\n> > +++ b/Documentation/git-remote.txt\n> > @@ -15,7 +15,7 @@ SYNOPSIS\n> >  'git remote rm' <name>\n> >  'git remote set-head' <name> [-a | -d | <branch>]\n> >  'git remote show' [-n] <name>\n> > -'git remote prune' [-n | --dry-run] <name>\n> > +'git remote prune' [-n | --dry-run] [name]\n> >  'git remote update' [-p | --prune] [group | remote]...\n> \n> I think you would want to say [<name>] here, but looking at this list, I\n> wonder if it would be more appropriate to allow \"remote group\" to be given\n> to \"prune\" (and perhaps \"show\").\n\nI also think that if we want to change prune, we should change it to\ninterpret its parameters identically to update. This means that no\nargument will not expand to \"all remotes\", but rather to the possibly\nconfigured \"default\" group.\n\nIn other words: I think \"git remote update -p\" and \"git remote prune\"\nshould prune the same remotes (both with and without additional arguments).\n\n- Finn Arne\n"}]}