{"thread":{"id":"24862","subject":"[BUG] git fetch --prune --tags origin deletes all remote branches origin/*","startedAt":"2010-08-25T22:30:01Z","lastAt":"2010-08-26T02:26:31Z","messageCount":3,"participants":["Kevin Ballard","Junio C Hamano","Jay Soffian"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"149013","messageId":"84CF7907-4493-4110-A852-B949BAE0214C@sb.org","threadId":"24862","inReplyTo":null,"subject":"[BUG] git fetch --prune --tags origin deletes all remote branches origin/*","fromName":"Kevin Ballard","fromEmail":"kevin@sb.org","sentAt":"2010-08-25T22:30:01Z","receivedAt":"2010-08-25T22:30:01Z","isPatch":false,"sender":{"key":"kevin@sb.org","avatar":"https://avatars.githubusercontent.com/u/714?v=4"},"body":"Running the simple command `git fetch --prune --tags origin` will delete every single remote branch refs/remotes/origin/*, with the sole exception of refs/remotes/origin/HEAD. This is wildly unexpected behavior. This was reproduced on the tip of the next branch, with version git version 1.7.2.2.440.g49ea7.\n\n> git fetch --prune --tags origin\n x [deleted]         (none)     -> origin/ahaney/login_problem_debug\n x [deleted]         (none)     -> origin/ahaney/tocfixes\n x [deleted]         (none)     -> origin/develop\n   (refs/remotes/origin/HEAD has become dangling)\n x [deleted]         (none)     -> origin/jon/contentupdates\n x [deleted]         (none)     -> origin/jon/ingest_safety\n x [deleted]         (none)     -> origin/jon/overview\n x [deleted]         (none)     -> origin/master\n x [deleted]         (none)     -> origin/v1_rejection/plan_a\n\n> git fetch origin\nFrom [redacted]\n * [new branch]      ahaney/login_problem_debug -> origin/ahaney/login_problem_debug\n * [new branch]      ahaney/tocfixes -> origin/ahaney/tocfixes\n * [new branch]      develop    -> origin/develop\n * [new branch]      jon/contentupdates -> origin/jon/contentupdates\n * [new branch]      jon/ingest_safety -> origin/jon/ingest_safety\n * [new branch]      jon/overview -> origin/jon/overview\n * [new branch]      master     -> origin/master\n * [new branch]      v1_rejection/plan_a -> origin/v1_rejection/plan_a\n\n-Kevin Ballard"},{"id":"149020","messageId":"7vsk22ntcl.fsf@alter.siamese.dyndns.org","threadId":"24862","inReplyTo":"84CF7907-4493-4110-A852-B949BAE0214C@sb.org","subject":"Re: [BUG] git fetch --prune --tags origin deletes all remote branches origin/*","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-08-25T23:52:10Z","receivedAt":"2010-08-25T23:52:10Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Kevin Ballard <kevin@sb.org> writes:\n\n> Running the simple command `git fetch --prune --tags origin` will delete\n> every single remote branch refs/remotes/origin/*, with the sole\n> exception of refs/remotes/origin/HEAD. This is wildly unexpected\n> behavior. This was reproduced on the tip of the next branch, with\n> version git version 1.7.2.2.440.g49ea7.\n\nI suspect \"--prune --tags\" behaved like that from the very beginning of\nthe appearance of \"--prune\", and also it is not limited to --tags.  With\nthis:\n\n    [remote \"origin\"]\n        url = $over_there\n        fetch = refs/heads/master:refs/heads/origin\n        fetch = refs/heads/next:refs/heads/next\n\n\"git fetch --prune origin master\" would probably remove your local next.\n\nget_stale_heads() seems to assume that it has the list of all existing\nrefs from the remote side available to make its decision.  Unless the\nfetch is done using a list of refs configured with remote.<name>.fetch, I\ndo not think that assumption holds.\n\n  f2ef607 (remote: refactor some logic into get_stale_heads(), 2009-11-10)\n  f360d84 (builtin-fetch: add --prune option, 2009-11-10)\n"},{"id":"149024","messageId":"AANLkTi=CEBZOK11uyb1SCF8fTc0CyWaEUxMFAv6-=MyB@mail.gmail.com","threadId":"24862","inReplyTo":"7vsk22ntcl.fsf@alter.siamese.dyndns.org","subject":"Re: [BUG] git fetch --prune --tags origin deletes all remote branches origin/*","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2010-08-26T02:26:31Z","receivedAt":"2010-08-26T02:26:31Z","isPatch":false,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Wed, Aug 25, 2010 at 7:52 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Kevin Ballard <kevin@sb.org> writes:\n>\n>> Running the simple command `git fetch --prune --tags origin` will delete\n>> every single remote branch refs/remotes/origin/*, with the sole\n>> exception of refs/remotes/origin/HEAD. This is wildly unexpected\n>> behavior. This was reproduced on the tip of the next branch, with\n>> version git version 1.7.2.2.440.g49ea7.\n>\n> I suspect \"--prune --tags\" behaved like that from the very beginning of\n> the appearance of \"--prune\",\n\nIndeed. The logic was refactored from \"git remote prune\" which doesn't\nsupport --tags. The quick fix would be to make --prune --tags and\nunsupported combination. However:\n\n> and also it is not limited to --tags.  With\n> this:\n>\n>    [remote \"origin\"]\n>        url = $over_there\n>        fetch = refs/heads/master:refs/heads/origin\n>        fetch = refs/heads/next:refs/heads/next\n>\n> \"git fetch --prune origin master\" would probably remove your local next.\n\nI would think \"remote prune\" suffered the same fate in that situation.\n\n> get_stale_heads() seems to assume that it has the list of all existing\n> refs from the remote side available to make its decision.  Unless the\n> fetch is done using a list of refs configured with remote.<name>.fetch, I\n> do not think that assumption holds.\n>\n>  f2ef607 (remote: refactor some logic into get_stale_heads(), 2009-11-10)\n>  f360d84 (builtin-fetch: add --prune option, 2009-11-10)\n\nI'm not sure what the best fix here is. It would seem prune should\nobey the user's fetch spec.\n\nj.\n"}]}