<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/refs.c, branch v2.4.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.4.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.4.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2015-03-25T19:54:26Z</updated>
<entry>
<title>Merge branch 'jk/prune-with-corrupt-refs'</title>
<updated>2015-03-25T19:54:26Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2015-03-25T19:54:26Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=05e816e37f4eb023a3606b2942192390566c6107'/>
<id>urn:sha1:05e816e37f4eb023a3606b2942192390566c6107</id>
<content type='text'>
"git prune" used to largely ignore broken refs when deciding which
objects are still being used, which could spread an existing small
damage and make it a larger one.

* jk/prune-with-corrupt-refs:
  refs.c: drop curate_packed_refs
  repack: turn on "ref paranoia" when doing a destructive repack
  prune: turn on ref_paranoia flag
  refs: introduce a "ref paranoia" flag
  t5312: test object deletion code paths in a corrupted repository
</content>
</entry>
<entry>
<title>refs.c: drop curate_packed_refs</title>
<updated>2015-03-20T19:41:41Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2015-03-20T18:43:17Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=ea56c4e02fc1d5ce6a6b5083c284e32ffc6367e6'/>
<id>urn:sha1:ea56c4e02fc1d5ce6a6b5083c284e32ffc6367e6</id>
<content type='text'>
When we delete a ref, we have to rewrite the entire
packed-refs file. We take this opportunity to "curate" the
packed-refs file and drop any entries that are crufty or
broken.

Dropping broken entries (e.g., with bogus names, or ones
that point to missing objects) is actively a bad idea, as it
means that we lose any notion that the data was there in the
first place. Aside from the general hackiness that we might
lose any information about ref "foo" while deleting an
unrelated ref "bar", this may seriously hamper any attempts
by the user at recovering from the corruption in "foo".

They will lose the sha1 and name of "foo"; the exact pointer
may still be useful even if they recover missing objects
from a different copy of the repository. But worse, once the
ref is gone, there is no trace of the corruption. A
follow-up "git prune" may delete objects, even though it
would otherwise bail when seeing corruption.

We could just drop the "broken" bits from
curate_packed_refs, and continue to drop the "crufty" bits:
refs whose loose counterpart exists in the filesystem. This
is not wrong to do, and it does have the advantage that we
may write out a slightly smaller packed-refs file. But it
has two disadvantages:

  1. It is a potential source of races or mistakes with
     respect to these refs that are otherwise unrelated to
     the operation. To my knowledge, there aren't any active
     problems in this area, but it seems like an unnecessary
     risk.

  2. We have to spend time looking up the matching loose
     refs for every item in the packed-refs file. If you
     have a large number of packed refs that do not change,
     that outweighs the benefit from writing out a smaller
     packed-refs file (it doesn't get smaller, and you do a
     bunch of directory traversal to find that out).

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>refs: introduce a "ref paranoia" flag</title>
<updated>2015-03-20T19:40:49Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2015-03-20T18:43:06Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=49672f26d9a3826a6a74c6ff4d2409b7b0c74495'/>
<id>urn:sha1:49672f26d9a3826a6a74c6ff4d2409b7b0c74495</id>
<content type='text'>
Most operations that iterate over refs are happy to ignore
broken cruft. However, some operations should be performed
with knowledge of these broken refs, because it is better
for the operation to choke on a missing object than it is to
silently pretend that the ref did not exist (e.g., if we are
computing the set of reachable tips in order to prune
objects).

These processes could just call for_each_rawref, except that
ref iteration is often hidden behind other interfaces. For
instance, for a destructive "repack -ad", we would have to
inform "pack-objects" that we are destructive, and then it
would in turn have to tell the revision code that our
"--all" should include broken refs.

It's much simpler to just set a global for "dangerous"
operations that includes broken refs in all iterations.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'mh/expire-updateref-fixes'</title>
<updated>2015-03-10T20:52:40Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2015-03-10T20:52:39Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=82b7e651990dce7016a903cb020e3dc0eba2ecfe'/>
<id>urn:sha1:82b7e651990dce7016a903cb020e3dc0eba2ecfe</id>
<content type='text'>
Various issues around "reflog expire", e.g. using --updateref when
expiring a reflog for a symbolic reference, have been corrected
and/or made saner.

* mh/expire-updateref-fixes:
  reflog_expire(): never update a reference to null_sha1
  reflog_expire(): ignore --updateref for symbolic references
  reflog: improve and update documentation
  struct ref_lock: delete the force_write member
  lock_ref_sha1_basic(): do not set force_write for missing references
  write_ref_sha1(): move write elision test to callers
  write_ref_sha1(): remove check for lock == NULL
</content>
</entry>
<entry>
<title>reflog_expire(): never update a reference to null_sha1</title>
<updated>2015-03-05T20:35:37Z</updated>
<author>
<name>Michael Haggerty</name>
<email>mhagger@alum.mit.edu</email>
</author>
<published>2015-03-03T11:43:17Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=423c688b855c328ecda0b6a79c4b1af78d09a10c'/>
<id>urn:sha1:423c688b855c328ecda0b6a79c4b1af78d09a10c</id>
<content type='text'>
Currently, if --updateref is specified and the very last reflog entry
is expired or deleted, the reference's value is set to 0{40}. This is
an invalid state of the repository, and breaks, for example, "git
fsck" and "git for-each-ref".

The only place we use --updateref in our own code is when dropping
stash entries. In that code, the very next step is to check if the
reflog has been made empty, and if so, delete the "refs/stash"
reference entirely. Thus that code path ultimately leaves the
repository in a valid state.

But we don't want to the repository in an invalid state even
temporarily, and we don't want to leave an invalid state if other
callers of "git reflog expire|delete --updateref" don't think to do
the extra cleanup step.

So, if "git reflog expire|delete" leaves no more entries in the
reflog, just leave the reference unchanged.

Signed-off-by: Michael Haggerty &lt;mhagger@alum.mit.edu&gt;
Reviewed-by: Stefan Beller &lt;sbeller@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>reflog_expire(): ignore --updateref for symbolic references</title>
<updated>2015-03-05T20:35:37Z</updated>
<author>
<name>Michael Haggerty</name>
<email>mhagger@alum.mit.edu</email>
</author>
<published>2015-03-03T11:43:16Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=5e6f003ca8aed546d50a4f3fbf1e011186047bc0'/>
<id>urn:sha1:5e6f003ca8aed546d50a4f3fbf1e011186047bc0</id>
<content type='text'>
If we are expiring reflog entries for a symbolic reference, then how
should --updateref be handled if the newest reflog entry is expired?

Option 1: Update the referred-to reference. (This is what the current
code does.) This doesn't make sense, because the referred-to reference
has its own reflog, which hasn't been rewritten.

Option 2: Update the symbolic reference itself (as in, REF_NODEREF).
This would convert the symbolic reference into a non-symbolic
reference (e.g., detaching HEAD), which is surely not what a user
would expect.

Option 3: Error out. This is plausible, but it would make the
following usage impossible:

    git reflog expire ... --updateref --all

Option 4: Ignore --updateref for symbolic references.

We choose to implement option 4.

Note: another problem in this code will be fixed in a moment.

Signed-off-by: Michael Haggerty &lt;mhagger@alum.mit.edu&gt;
Reviewed-by: Stefan Beller &lt;sbeller@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>struct ref_lock: delete the force_write member</title>
<updated>2015-03-05T20:35:36Z</updated>
<author>
<name>Stefan Beller</name>
<email>sbeller@google.com</email>
</author>
<published>2015-03-03T11:43:14Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=5a6f47077b31be45bfadd6cef3b8b1a79ad57de5'/>
<id>urn:sha1:5a6f47077b31be45bfadd6cef3b8b1a79ad57de5</id>
<content type='text'>
Instead, compute the value when it is needed.

Signed-off-by: Stefan Beller &lt;sbeller@google.com&gt;
Edited-by: Michael Haggerty &lt;mhagger@alum.mit.edu&gt;
Signed-off-by: Michael Haggerty &lt;mhagger@alum.mit.edu&gt;
Reviewed-by: Stefan Beller &lt;sbeller@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>lock_ref_sha1_basic(): do not set force_write for missing references</title>
<updated>2015-03-05T20:35:36Z</updated>
<author>
<name>Michael Haggerty</name>
<email>mhagger@alum.mit.edu</email>
</author>
<published>2015-03-02T09:29:53Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=074336e5ed4ff10577f22c6812e092e3f6607405'/>
<id>urn:sha1:074336e5ed4ff10577f22c6812e092e3f6607405</id>
<content type='text'>
If a reference is missing, its SHA-1 will be null_sha1, which can't
possibly match a new value that ref_transaction_commit() is trying to
update it to. So there is no need to set force_write in this scenario.

Signed-off-by: Michael Haggerty &lt;mhagger@alum.mit.edu&gt;
Reviewed-by: Stefan Beller &lt;sbeller@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>write_ref_sha1(): move write elision test to callers</title>
<updated>2015-03-05T20:35:36Z</updated>
<author>
<name>Michael Haggerty</name>
<email>mhagger@alum.mit.edu</email>
</author>
<published>2015-03-02T09:29:52Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=706d5f816fbcb1299c19f4d41bea60f1e229165e'/>
<id>urn:sha1:706d5f816fbcb1299c19f4d41bea60f1e229165e</id>
<content type='text'>
write_ref_sha1() previously skipped the write if the reference already
had the desired value, unless lock-&gt;force_write was set. Instead,
perform that test at the callers.

Two of the callers (in rename_ref()) unconditionally set force_write
just before calling write_ref_sha1(), so they don't need the extra
check at all. Nor do they need to set force_write anymore.

The last caller, in ref_transaction_commit(), still needs the test.

Signed-off-by: Michael Haggerty &lt;mhagger@alum.mit.edu&gt;
Reviewed-by: Stefan Beller &lt;sbeller@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>write_ref_sha1(): remove check for lock == NULL</title>
<updated>2015-03-05T20:35:36Z</updated>
<author>
<name>Michael Haggerty</name>
<email>mhagger@alum.mit.edu</email>
</author>
<published>2015-03-02T09:29:51Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=8280bbebd1ecc4633b969a439ed4ca653d1bc958'/>
<id>urn:sha1:8280bbebd1ecc4633b969a439ed4ca653d1bc958</id>
<content type='text'>
None of the callers pass NULL to this function, and there doesn't seem
to be any usefulness to allowing them to do so.

Signed-off-by: Michael Haggerty &lt;mhagger@alum.mit.edu&gt;
Reviewed-by: Stefan Beller &lt;sbeller@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
