<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/fetch-pack.c, branch v2.6.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.6.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.6.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2015-08-10T22:37:14Z</updated>
<entry>
<title>memoize common git-path "constant" files</title>
<updated>2015-08-10T22:37:14Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2015-08-10T09:38:57Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=f932729cc7707390f4d6739be1573e93ceb9df22'/>
<id>urn:sha1:f932729cc7707390f4d6739be1573e93ceb9df22</id>
<content type='text'>
One of the most common uses of git_path() is to pass a
constant, like git_path("MERGE_MSG"). This has two
drawbacks:

  1. The return value is a static buffer, and the lifetime
     is dependent on other calls to git_path, etc.

  2. There's no compile-time checking of the pathname. This
     is OK for a one-off (after all, we have to spell it
     correctly at least once), but many of these constant
     strings appear throughout the code.

This patch introduces a series of functions to "memoize"
these strings, which are essentially globals for the
lifetime of the program. We compute the value once, take
ownership of the buffer, and return the cached value for
subsequent calls.  cache.h provides a helper macro for
defining these functions as one-liners, and defines a few
common ones for global use.

Using a macro is a little bit gross, but it does nicely
document the purpose of the functions. If we need to touch
them all later (e.g., because we learned how to change the
git_dir variable at runtime, and need to invalidate all of
the stored values), it will be much easier to have the
complete list.

Note that the shared-global functions have separate, manual
declarations. We could do something clever with the macros
(e.g., expand it to a declaration in some places, and a
declaration _and_ a definition in path.c). But there aren't
that many, and it's probably better to stay away from
too-magical macros.

Likewise, if we abandon the C preprocessor in favor of
generating these with a script, we could get much fancier.
E.g., normalizing "FOO/BAR-BAZ" into "git_path_foo_bar_baz".
But the small amount of saved typing is probably not worth
the resulting confusion to readers who want to grep for the
function's definition.

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 'me/fetch-into-shallow-safety'</title>
<updated>2015-07-01T21:02:33Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2015-07-01T21:02:33Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=58eb0122f3f4799a1b7a3ce836e52dcb2dad45bd'/>
<id>urn:sha1:58eb0122f3f4799a1b7a3ce836e52dcb2dad45bd</id>
<content type='text'>
"git fetch --depth=&lt;depth&gt;" and "git clone --depth=&lt;depth&gt;" issued
a shallow transfer request even to an upload-pack that does not
support the capability.

* me/fetch-into-shallow-safety:
  fetch-pack: check for shallow if depth given
</content>
</entry>
<entry>
<title>fetch-pack: check for shallow if depth given</title>
<updated>2015-06-17T19:03:58Z</updated>
<author>
<name>Mike Edgar</name>
<email>adgar@google.com</email>
</author>
<published>2015-06-17T11:48:14Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=eb86a507a150b8fbb34fb4e59bf9edbefbbad778'/>
<id>urn:sha1:eb86a507a150b8fbb34fb4e59bf9edbefbbad778</id>
<content type='text'>
When a repository is first fetched as a shallow clone, either by
git-clone or by fetching into an empty repo, the server's capabilities
are not currently consulted. The client will send shallow requests even
if the server does not understand them, and the resulting error may be
unhelpful to the user. This change pre-emptively checks so we can exit
with a helpful error if necessary.

Signed-off-by: Mike Edgar &lt;adgar@google.com&gt;
Reviewed-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 'bc/object-id'</title>
<updated>2015-06-05T19:17:37Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2015-06-05T19:17:37Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=5455ee0573a22bb793a7083d593ae1ace909cd4c'/>
<id>urn:sha1:5455ee0573a22bb793a7083d593ae1ace909cd4c</id>
<content type='text'>
for_each_ref() callback functions were taught to name the objects
not with "unsigned char sha1[20]" but with "struct object_id".

* bc/object-id: (56 commits)
  struct ref_lock: convert old_sha1 member to object_id
  warn_if_dangling_symref(): convert local variable "junk" to object_id
  each_ref_fn_adapter(): remove adapter
  rev_list_insert_ref(): remove unneeded arguments
  rev_list_insert_ref_oid(): new function, taking an object_oid
  mark_complete(): remove unneeded arguments
  mark_complete_oid(): new function, taking an object_oid
  clear_marks(): rewrite to take an object_id argument
  mark_complete(): rewrite to take an object_id argument
  send_ref(): convert local variable "peeled" to object_id
  upload-pack: rewrite functions to take object_id arguments
  find_symref(): convert local variable "unused" to object_id
  find_symref(): rewrite to take an object_id argument
  write_one_ref(): rewrite to take an object_id argument
  write_refs_to_temp_dir(): convert local variable sha1 to object_id
  submodule: rewrite to take an object_id argument
  shallow: rewrite functions to take object_id arguments
  handle_one_ref(): rewrite to take an object_id argument
  add_info_ref(): rewrite to take an object_id argument
  handle_one_reflog(): rewrite to take an object_id argument
  ...
</content>
</entry>
<entry>
<title>rev_list_insert_ref(): remove unneeded arguments</title>
<updated>2015-05-25T19:19:39Z</updated>
<author>
<name>Michael Haggerty</name>
<email>mhagger@alum.mit.edu</email>
</author>
<published>2015-05-25T18:39:19Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=c38cd1c89d662dc0f4fd30f98cc8904c2143c7ab'/>
<id>urn:sha1:c38cd1c89d662dc0f4fd30f98cc8904c2143c7ab</id>
<content type='text'>
Now that the function is not being used as an each_ref_sha1_fn, we can
delete the unused arguments in its signature.

Signed-off-by: Michael Haggerty &lt;mhagger@alum.mit.edu&gt;
Signed-off-by: brian m. carlson &lt;sandals@crustytoothpaste.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>rev_list_insert_ref_oid(): new function, taking an object_oid</title>
<updated>2015-05-25T19:19:39Z</updated>
<author>
<name>Michael Haggerty</name>
<email>mhagger@alum.mit.edu</email>
</author>
<published>2015-05-25T18:39:18Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=b1b49c6eb607b3f5697db7dae51e5152a3af3423'/>
<id>urn:sha1:b1b49c6eb607b3f5697db7dae51e5152a3af3423</id>
<content type='text'>
This function can be used with for_each_ref() without having to be
wrapped.

Signed-off-by: Michael Haggerty &lt;mhagger@alum.mit.edu&gt;
Signed-off-by: brian m. carlson &lt;sandals@crustytoothpaste.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>mark_complete(): remove unneeded arguments</title>
<updated>2015-05-25T19:19:38Z</updated>
<author>
<name>Michael Haggerty</name>
<email>mhagger@alum.mit.edu</email>
</author>
<published>2015-05-25T18:39:17Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=6e20a51a8096059ecba6c7959d308c52f9fe8900'/>
<id>urn:sha1:6e20a51a8096059ecba6c7959d308c52f9fe8900</id>
<content type='text'>
Now that the function is not being used as an each_ref_sha1_fn, we can
delete the unused arguments in its signature.

Signed-off-by: Michael Haggerty &lt;mhagger@alum.mit.edu&gt;
Signed-off-by: brian m. carlson &lt;sandals@crustytoothpaste.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>mark_complete_oid(): new function, taking an object_oid</title>
<updated>2015-05-25T19:19:38Z</updated>
<author>
<name>Michael Haggerty</name>
<email>mhagger@alum.mit.edu</email>
</author>
<published>2015-05-25T18:39:16Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=f8ee4d85229a26ec6d4ce403d953eea6b53c6396'/>
<id>urn:sha1:f8ee4d85229a26ec6d4ce403d953eea6b53c6396</id>
<content type='text'>
This function can be used with for_each_ref() without having to be
wrapped.

Signed-off-by: Michael Haggerty &lt;mhagger@alum.mit.edu&gt;
Signed-off-by: brian m. carlson &lt;sandals@crustytoothpaste.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>clear_marks(): rewrite to take an object_id argument</title>
<updated>2015-05-25T19:19:38Z</updated>
<author>
<name>Michael Haggerty</name>
<email>mhagger@alum.mit.edu</email>
</author>
<published>2015-05-25T18:39:15Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=c50fb6cee6627ab9355e2d1e09fcab9dfe92cdb7'/>
<id>urn:sha1:c50fb6cee6627ab9355e2d1e09fcab9dfe92cdb7</id>
<content type='text'>
Signed-off-by: Michael Haggerty &lt;mhagger@alum.mit.edu&gt;
Signed-off-by: brian m. carlson &lt;sandals@crustytoothpaste.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>each_ref_fn: change to take an object_id parameter</title>
<updated>2015-05-25T19:19:27Z</updated>
<author>
<name>Michael Haggerty</name>
<email>mhagger@alum.mit.edu</email>
</author>
<published>2015-05-25T18:38:28Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=2b2a5be394bc67bed86bc009195c664dca740bd6'/>
<id>urn:sha1:2b2a5be394bc67bed86bc009195c664dca740bd6</id>
<content type='text'>
Change typedef each_ref_fn to take a "const struct object_id *oid"
parameter instead of "const unsigned char *sha1".

To aid this transition, implement an adapter that can be used to wrap
old-style functions matching the old typedef, which is now called
"each_ref_sha1_fn"), and make such functions callable via the new
interface. This requires the old function and its cb_data to be
wrapped in a "struct each_ref_fn_sha1_adapter", and that object to be
used as the cb_data for an adapter function, each_ref_fn_adapter().

This is an enormous diff, but most of it consists of simple,
mechanical changes to the sites that call any of the "for_each_ref"
family of functions. Subsequent to this change, the call sites can be
rewritten one by one to use the new interface.

Signed-off-by: Michael Haggerty &lt;mhagger@alum.mit.edu&gt;
Signed-off-by: brian m. carlson &lt;sandals@crustytoothpaste.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
