{"thread":{"id":"36482","subject":"Archiving off old branches","startedAt":"2014-04-23T17:08:50Z","lastAt":"2014-04-23T18:15:01Z","messageCount":5,"participants":["Tim Chase","Junio C Hamano","Jonathan Nieder"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"239449","messageId":"20140423120850.3f6fb535@bigbox.christie.dr","threadId":"36482","inReplyTo":null,"subject":"Archiving off old branches","fromName":"Tim Chase","fromEmail":"git@tim.thechases.com","sentAt":"2014-04-23T17:08:50Z","receivedAt":"2014-04-23T17:08:50Z","isPatch":false,"sender":{"key":"git@tim.thechases.com","avatar":null},"body":"I've got a branch for each bug/issue and it was getting a bit\nunwieldy.  A little searching suggested this\n\n  # archive off the BUG-123 branch\n  git update-ref refs/closed/BUG-123 BUG-123\n  git branch -D BUG-123\n\nwhich seems to do exactly what I want -- branches are archived off so\nthey still have refs, but they don't appear in the output of \"git\nbranch\".\n\nReading up on \"git help update-ref\", it states that it updates the\nname \"safely\".  As best I can tell, the above process does something\nlike\n\n  cd .git/refs\n  mkdir -p closed\n  mv heads/BUG-123 closed\n\nIs there something unsafe about this?  The advantage to the latter\nwould be that I could do a bunch of them easily:\n\n  mv heads/BUG-{123,234,345,456,567} closed\n\nbut I want to make sure I'm not screwing something up unsafely.  Is\nthere some key element to \"update-ref\"'s safety that I'm missing?\n\n-tkc\n"},{"id":"239454","messageId":"xmqqzjjcymac.fsf@gitster.dls.corp.google.com","threadId":"36482","inReplyTo":"20140423120850.3f6fb535@bigbox.christie.dr","subject":"Re: Archiving off old branches","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-04-23T17:43:07Z","receivedAt":"2014-04-23T17:43:07Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Tim Chase <git@tim.thechases.com> writes:\n\n> Reading up on \"git help update-ref\", it states that it updates the\n> name \"safely\".\n\nI think that description is well intended but is misleading.  There\nare many potential sources of risk, and the \"safely\" refers to\nprotection against a particular kind of risk: updating from a value\nthat you did not intend to (i.e. you examined and decided the update\nis good, time passes while somebody else might have mucked with the\nref, and then you execute the update you decided to do).  And the\nsafety afforded to you is with \"git update-ref ref newvalue oldvalue\"\nthat makes sure the ref still points at the oldvalue and refuses to\nupdate it to newvalue if it doesn't.\n"},{"id":"239457","messageId":"20140423175820.GE15516@google.com","threadId":"36482","inReplyTo":"20140423120850.3f6fb535@bigbox.christie.dr","subject":"Re: Archiving off old branches","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2014-04-23T17:58:20Z","receivedAt":"2014-04-23T17:58:20Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi,\n\nTim Chase wrote:\n\n>   cd .git/refs\n>   mkdir -p closed\n>   mv heads/BUG-123 closed\n\nThat breaks with packed refs (see git-pack-refs(1)), which are a normal\nthing to encounter after garbage collection.\n\nHope that helps,\nJonathan\n"},{"id":"239459","messageId":"20140423130619.495e5e6b@bigbox.christie.dr","threadId":"36482","inReplyTo":"20140423175820.GE15516@google.com","subject":"Re: Archiving off old branches","fromName":"Tim Chase","fromEmail":"git@tim.thechases.com","sentAt":"2014-04-23T18:06:19Z","receivedAt":"2014-04-23T18:06:19Z","isPatch":false,"sender":{"key":"git@tim.thechases.com","avatar":null},"body":"On 2014-04-23 10:58, Jonathan Nieder wrote:\n> Tim Chase wrote:\n> >   cd .git/refs\n> >   mkdir -p closed\n> >   mv heads/BUG-123 closed\n> \n> That breaks with packed refs (see git-pack-refs(1)), which are a\n> normal thing to encounter after garbage collection.\n> \n> Hope that helps,\n\nVery much so.  Alrighty...based on that alone, I'll stick to my\narchive script that calls update-ref and then deletes the branch.\n\nThanks,\n\n-tkc\n"},{"id":"239460","messageId":"xmqqvbtzzzdm.fsf@gitster.dls.corp.google.com","threadId":"36482","inReplyTo":"20140423175820.GE15516@google.com","subject":"Re: Archiving off old branches","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-04-23T18:15:01Z","receivedAt":"2014-04-23T18:15:01Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jonathan Nieder <jrnieder@gmail.com> writes:\n\n> Tim Chase wrote:\n>\n>>   cd .git/refs\n>>   mkdir -p closed\n>>   mv heads/BUG-123 closed\n>\n> That breaks with packed refs (see git-pack-refs(1)), which are a normal\n> thing to encounter after garbage collection.\n\nSpecifically,\n\n - if BUG-123 branch was placed in packed-refs file in the past\n   (which may be older than what you have right now at heads/BUG-123\n   as a loose ref), the above procedure will still make it appear in\n   your \"git branch --list\" output, pointing at a possibly old\n   commit that may even have been pruned away.\n\n - if BUG-123 branch was placed in packed-refs file and you haven't\n   touched that branch since then, heads/BUG-123 file would not\n   exist, \"mv\" will fail, and you won't see closed/BUG-123 at the\n   end of the procedure.\n"}]}