git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Archiving off old branches
@ 2014-04-23 17:08 Tim Chase
  2014-04-23 17:43 ` Junio C Hamano
  2014-04-23 17:58 ` Jonathan Nieder
  0 siblings, 2 replies; 5+ messages in thread
From: Tim Chase @ 2014-04-23 17:08 UTC (permalink / raw)
  To: git

I've got a branch for each bug/issue and it was getting a bit
unwieldy.  A little searching suggested this

  # archive off the BUG-123 branch
  git update-ref refs/closed/BUG-123 BUG-123
  git branch -D BUG-123

which seems to do exactly what I want -- branches are archived off so
they still have refs, but they don't appear in the output of "git
branch".

Reading up on "git help update-ref", it states that it updates the
name "safely".  As best I can tell, the above process does something
like

  cd .git/refs
  mkdir -p closed
  mv heads/BUG-123 closed

Is there something unsafe about this?  The advantage to the latter
would be that I could do a bunch of them easily:

  mv heads/BUG-{123,234,345,456,567} closed

but I want to make sure I'm not screwing something up unsafely.  Is
there some key element to "update-ref"'s safety that I'm missing?

-tkc

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Archiving off old branches
  2014-04-23 17:08 Archiving off old branches Tim Chase
@ 2014-04-23 17:43 ` Junio C Hamano
  2014-04-23 17:58 ` Jonathan Nieder
  1 sibling, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2014-04-23 17:43 UTC (permalink / raw)
  To: Tim Chase; +Cc: git

Tim Chase <git@tim.thechases.com> writes:

> Reading up on "git help update-ref", it states that it updates the
> name "safely".

I think that description is well intended but is misleading.  There
are many potential sources of risk, and the "safely" refers to
protection against a particular kind of risk: updating from a value
that you did not intend to (i.e. you examined and decided the update
is good, time passes while somebody else might have mucked with the
ref, and then you execute the update you decided to do).  And the
safety afforded to you is with "git update-ref ref newvalue oldvalue"
that makes sure the ref still points at the oldvalue and refuses to
update it to newvalue if it doesn't.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Archiving off old branches
  2014-04-23 17:08 Archiving off old branches Tim Chase
  2014-04-23 17:43 ` Junio C Hamano
@ 2014-04-23 17:58 ` Jonathan Nieder
  2014-04-23 18:06   ` Tim Chase
  2014-04-23 18:15   ` Junio C Hamano
  1 sibling, 2 replies; 5+ messages in thread
From: Jonathan Nieder @ 2014-04-23 17:58 UTC (permalink / raw)
  To: Tim Chase; +Cc: git

Hi,

Tim Chase wrote:

>   cd .git/refs
>   mkdir -p closed
>   mv heads/BUG-123 closed

That breaks with packed refs (see git-pack-refs(1)), which are a normal
thing to encounter after garbage collection.

Hope that helps,
Jonathan

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Archiving off old branches
  2014-04-23 17:58 ` Jonathan Nieder
@ 2014-04-23 18:06   ` Tim Chase
  2014-04-23 18:15   ` Junio C Hamano
  1 sibling, 0 replies; 5+ messages in thread
From: Tim Chase @ 2014-04-23 18:06 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: Tim Chase, git

On 2014-04-23 10:58, Jonathan Nieder wrote:
> Tim Chase wrote:
> >   cd .git/refs
> >   mkdir -p closed
> >   mv heads/BUG-123 closed
> 
> That breaks with packed refs (see git-pack-refs(1)), which are a
> normal thing to encounter after garbage collection.
> 
> Hope that helps,

Very much so.  Alrighty...based on that alone, I'll stick to my
archive script that calls update-ref and then deletes the branch.

Thanks,

-tkc

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Archiving off old branches
  2014-04-23 17:58 ` Jonathan Nieder
  2014-04-23 18:06   ` Tim Chase
@ 2014-04-23 18:15   ` Junio C Hamano
  1 sibling, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2014-04-23 18:15 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: Tim Chase, git

Jonathan Nieder <jrnieder@gmail.com> writes:

> Tim Chase wrote:
>
>>   cd .git/refs
>>   mkdir -p closed
>>   mv heads/BUG-123 closed
>
> That breaks with packed refs (see git-pack-refs(1)), which are a normal
> thing to encounter after garbage collection.

Specifically,

 - if BUG-123 branch was placed in packed-refs file in the past
   (which may be older than what you have right now at heads/BUG-123
   as a loose ref), the above procedure will still make it appear in
   your "git branch --list" output, pointing at a possibly old
   commit that may even have been pruned away.

 - if BUG-123 branch was placed in packed-refs file and you haven't
   touched that branch since then, heads/BUG-123 file would not
   exist, "mv" will fail, and you won't see closed/BUG-123 at the
   end of the procedure.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-04-23 18:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-23 17:08 Archiving off old branches Tim Chase
2014-04-23 17:43 ` Junio C Hamano
2014-04-23 17:58 ` Jonathan Nieder
2014-04-23 18:06   ` Tim Chase
2014-04-23 18:15   ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).