public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox•com>
To: Russell Steicke <russellsteicke@gmail•com>
Cc: Dongas <dongas86@gmail•com>, git@vger•kernel.org
Subject: Re: A question about changing remote repo name
Date: Tue, 05 Jan 2010 17:02:58 -0800	[thread overview]
Message-ID: <7vd41oqc3h.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <c1b8b6671001051607j6b6398d8gf08f7615a38de64e@mail.gmail.com> (Russell Steicke's message of "Wed\, 6 Jan 2010 08\:07\:48 +0800")

Russell Steicke <russellsteicke@gmail•com> writes:

> Ah yes, I forgot about those files.  I _think_ (but I'm not certain
> without digging into the code) that it's always safe to rm
> packed-refs, as that file is a cache for quicker access to the refs.

No what you think is incorrect, no it is not safe at all, and no it is not
a cache.

refs are created loose as files under $GIT_DIR/refs/.  When pack-refs is
run (either from the toplevel or as part of gc), these loose ref files are
removed and instead written to $GIT_DIR/packed-refs file.  When a new ref
is created or an existing ref is updated, only $GIT_DIR/refs/ is modified.

When reading or enumerating, a loose ref, if found, is used.  Otherwise
a record in packed-refs is consulted.  The consequences are:

 - If you have $GIT_DIR/refs/heads/master and at the same time, an entry
   for refs/heads/master exists in $GIT_DIR/packed-refs, removing the
   entry in packed-refs happens to be safe, because it was already masked.

 - If you do not have $GIT_DIR/refs/heads/old, but an entry for
   refs/heads/old exists in $GIT_DIR/packed-refs, removing the entry in
   packed-refs means you lose the "old" branch.  You don't want to do
   that.

 - When deleting a ref, we remove it from $GIT_DIR/refs/, but at the same
   time, if packed-refs contains an entry for it, we remove it from
   there.  Otherwise, the removal of the loose one will unmask the stale
   entry in packed-refs file.

  parent reply	other threads:[~2010-01-06  1:03 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-04  6:45 A question about changing remote repo name Dongas
2010-01-04 20:09 ` Miklos Vajna
2010-01-05  1:53   ` Dongas
2010-01-05  1:57     ` Erik Faye-Lund
2010-01-05  2:25       ` Dongas
2010-01-05  2:52 ` Russell Steicke
2010-01-05  4:30   ` Dongas
2010-01-05 21:15     ` David Aguilar
2010-01-06  3:55       ` Dongas
2010-01-06  0:07     ` Russell Steicke
2010-01-06  0:27       ` Johannes Schindelin
2010-01-07  1:53         ` Russell Steicke
2010-01-06  1:02       ` Junio C Hamano [this message]
2010-01-06  3:58       ` Dongas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vd41oqc3h.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox$(echo .)com \
    --cc=dongas86@gmail$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=russellsteicke@gmail$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox