<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/pack-refs.c, branch main</title>
<subtitle>Fork of git SCM with my patches.</subtitle>
<id>http://git.kilabit.info/git/atom?h=main</id>
<link rel='self' href='http://git.kilabit.info/git/atom?h=main'/>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/'/>
<updated>2025-11-04T15:35:12Z</updated>
<entry>
<title>refs: rename 'pack_refs_opts' to 'refs_optimize_opts'</title>
<updated>2025-11-04T15:35:12Z</updated>
<author>
<name>Karthik Nayak</name>
<email>karthik.188@gmail.com</email>
</author>
<published>2025-10-20T08:18:30Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=2cd99d984122f7f1cd7c3b153ee0a0d566831b30'/>
<id>urn:sha1:2cd99d984122f7f1cd7c3b153ee0a0d566831b30</id>
<content type='text'>
The previous commit removed all references to 'pack_refs()' within
the refs subsystem. Continue this cleanup by also renaming
'pack_refs_opts' to 'refs_optimize_opts' and the respective flags
accordingly. Keeping the naming consistent will make the code easier to
maintain.

Signed-off-by: Karthik Nayak &lt;karthik.188@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>builtin/pack-refs: factor out core logic into a shared library</title>
<updated>2025-09-19T17:02:55Z</updated>
<author>
<name>Meet Soni</name>
<email>meetsoni3017@gmail.com</email>
</author>
<published>2025-09-19T08:26:43Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=0d4ec339227d04bcba89390bdef22d4dce30d271'/>
<id>urn:sha1:0d4ec339227d04bcba89390bdef22d4dce30d271</id>
<content type='text'>
The implementation of `git pack-refs` is monolithic within
`cmd_pack_refs()`, making it impossible to share its logic with other
commands. To enable code reuse for the upcoming `git refs optimize`
subcommand, refactor the core logic into a shared helper function.

Split the original `builtin/pack-refs.c` file into two parts:

- A new shared library file, `pack-refs.c`, which contains the
  core option parsing and packing logic in a new `pack_refs_core()`
  helper function.

- The original `builtin/pack-refs.c`, which is now a thin wrapper
  responsible only for defining the `git pack-refs` command and
  calling the shared helper.

A new `pack-refs.h` header is also introduced to define the public
interface for this shared logic.

Mentored-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Mentored-by: shejialuo &lt;shejialuo@gmail.com&gt;
Signed-off-by: Meet Soni &lt;meetsoni3017@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>pack-refs: merge code from pack-refs.{c,h} into refs.{c,h}</title>
<updated>2013-05-01T22:33:11Z</updated>
<author>
<name>Michael Haggerty</name>
<email>mhagger@alum.mit.edu</email>
</author>
<published>2013-04-22T19:52:32Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=32d462cea80cd52b2c3fa0d538aba7fcf079ba77'/>
<id>urn:sha1:32d462cea80cd52b2c3fa0d538aba7fcf079ba77</id>
<content type='text'>
pack-refs.c doesn't contain much code, and the code it does contain is
closely related to reference handling.  Moreover, there is some
duplication between pack_refs() and repack_without_ref().  Therefore,
merge pack-refs.c into refs.c and pack-refs.h into refs.h.

The code duplication will be addressed in future commits.

Signed-off-by: Michael Haggerty &lt;mhagger@alum.mit.edu&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>pack-refs: rename handle_one_ref() to pack_one_ref()</title>
<updated>2013-05-01T22:33:10Z</updated>
<author>
<name>Michael Haggerty</name>
<email>mhagger@alum.mit.edu</email>
</author>
<published>2013-04-22T19:52:31Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=0c0c0bd25e4bea1fb1f48e8bca3ce9b68d69ee93'/>
<id>urn:sha1:0c0c0bd25e4bea1fb1f48e8bca3ce9b68d69ee93</id>
<content type='text'>
This code is about to be moved, so name the function more
distinctively.

Signed-off-by: Michael Haggerty &lt;mhagger@alum.mit.edu&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>pack-refs: add fully-peeled trait</title>
<updated>2013-03-18T15:06:28Z</updated>
<author>
<name>Michael Haggerty</name>
<email>mhagger@alum.mit.edu</email>
</author>
<published>2013-03-18T11:37:32Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=c29c46fa2e21e608ce2e603649af5bf38e7969c2'/>
<id>urn:sha1:c29c46fa2e21e608ce2e603649af5bf38e7969c2</id>
<content type='text'>
Older versions of pack-refs did not write peel lines for
refs outside of refs/tags. This meant that on reading the
pack-refs file, we might set the REF_KNOWS_PEELED flag for
such a ref, even though we do not know anything about its
peeled value.

The previous commit updated the writer to always peel, no
matter what the ref is. That means that packed-refs files
written by newer versions of git are fine to be read by both
old and new versions of git. However, we still have the
problem of reading packed-refs files written by older
versions of git, or by other implementations which have not
yet learned the same trick.

The simplest fix would be to always unset the
REF_KNOWS_PEELED flag for refs outside of refs/tags that do
not have a peel line (if it has a peel line, we know it is
valid, but we cannot assume a missing peel line means
anything). But that loses an important optimization, as
upload-pack should not need to load the object pointed to by
refs/heads/foo to determine that it is not a tag.

Instead, we add a "fully-peeled" trait to the packed-refs
file. If it is set, we know that we can trust a missing peel
line to mean that a ref cannot be peeled. Otherwise, we fall
back to assuming nothing.

[commit message and tests by Jeff King &lt;peff@peff.net&gt;]

Signed-off-by: Michael Haggerty &lt;mhagger@alum.mit.edu&gt;
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>pack-refs: write peeled entry for non-tags</title>
<updated>2013-03-17T19:52:20Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2013-03-17T08:23:46Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=03a8eddfd1bd7cdce0b2361753691f53c00e5ba6'/>
<id>urn:sha1:03a8eddfd1bd7cdce0b2361753691f53c00e5ba6</id>
<content type='text'>
When we pack an annotated tag ref, we write not only the
sha1 of the tag object along with the ref, but also the sha1
obtained by peeling the tag. This lets readers of the
pack-refs file know the peeled value without having to
actually load the object, speeding up upload-pack's ref
advertisement.

The writer marks a packed-refs file with peeled refs using
the "peeled" trait at the top of the file. When the reader
sees this trait, it knows that each ref is either followed
by its peeled value, or it is not an annotated tag.

However, there is a mismatch between the assumptions of the
reader and writer. The writer will only peel refs under
refs/tags, but the reader does not know this; it will assume
a ref without a peeled value must not be a tag object. Thus
an annotated tag object placed outside of the refs/tags
hierarchy will not have its peeled value printed by
upload-pack.

The simplest way to fix this is to start writing peel values
for all refs. This matches what the reader expects for both
new and old versions of git.

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>avoid segfaults on parse_object failure</title>
<updated>2013-03-17T19:49:03Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2013-03-17T08:22:36Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=75a95490474ab6e991cbbbd10d980498a9109648'/>
<id>urn:sha1:75a95490474ab6e991cbbbd10d980498a9109648</id>
<content type='text'>
Many call-sites of parse_object assume that they will get a
non-NULL return value; this is not the case if we encounter
an error while parsing the object.

This patch adds a wrapper function around parse_object that
handles dying automatically, and uses it anywhere we
immediately try to access the return value as a non-NULL
pointer (i.e., anywhere that we would currently segfault).

This wrapper may also be useful in other places. The most
obvious one is code like:

  o = parse_object(sha1);
  if (!o)
	  die(...);

However, these should not be mechanically converted to
parse_object_or_die, as the die message is sometimes
customized. Later patches can address these sites on a
case-by-case basis.

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>pack_refs(): remove redundant check</title>
<updated>2012-01-17T19:41:41Z</updated>
<author>
<name>Michael Haggerty</name>
<email>mhagger@alum.mit.edu</email>
</author>
<published>2012-01-17T05:50:31Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=e45a59955ec78bca12930bcf6aa9642fd94c9e7c'/>
<id>urn:sha1:e45a59955ec78bca12930bcf6aa9642fd94c9e7c</id>
<content type='text'>
handle_one_ref() only adds refs to the cbdata.ref_to_prune list if
(cbdata.flags &amp; PACK_REFS_PRUNE) is set.  So any references in this
list at the end of pack_refs() can be pruned unconditionally.

Signed-off-by: Michael Haggerty &lt;mhagger@alum.mit.edu&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Change check_ref_format() to take a flags argument</title>
<updated>2011-10-05T20:45:29Z</updated>
<author>
<name>Michael Haggerty</name>
<email>mhagger@alum.mit.edu</email>
</author>
<published>2011-09-15T21:10:25Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=8d9c50105f908b2adde4b7c77537cf95f19cd893'/>
<id>urn:sha1:8d9c50105f908b2adde4b7c77537cf95f19cd893</id>
<content type='text'>
Change check_ref_format() to take a flags argument that indicates what
is acceptable in the reference name (analogous to "git
check-ref-format"'s "--allow-onelevel" and "--refspec-pattern").  This
is more convenient for callers and also fixes a failure in the test
suite (and likely elsewhere in the code) by enabling "onelevel" and
"refspec-pattern" to be allowed independently of each other.

Also rename check_ref_format() to check_refname_format() to make it
obvious that it deals with refnames rather than references themselves.

Signed-off-by: Michael Haggerty &lt;mhagger@alum.mit.edu&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>pack-refs: remove newly empty directories</title>
<updated>2010-07-07T16:11:37Z</updated>
<author>
<name>Greg Price</name>
<email>price@ksplice.com</email>
</author>
<published>2010-07-06T23:29:19Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/git/commit/?id=be7c6d467e8cc4104e1a15e8ff2d7b207624c685'/>
<id>urn:sha1:be7c6d467e8cc4104e1a15e8ff2d7b207624c685</id>
<content type='text'>
In a large repository which uses directories to organize many refs,
"git pack-refs --all --prune" does not improve performance so much
as it should, unless we remove all the now-empty directories as well.

Signed-off-by: Greg Price &lt;price@ksplice.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
