Skip to contentSkip to conversation

http*: refactor fetching code

PATCH New Tay Ray Chuan 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

cover http*: refactor fetching code

This patch series moves out fetching code from http-push.c and http-walker.c into http.c to reduce code duplicity, and does not attempt to change git's behaviour.

Patch #1 adds rigour to http fetch tests by testing fetching of packed objects, in an effort to ensure that this patch series does not break functionality or change behaviour.

Patch #2 introduces some style fixes, to reduce the number of trivial differences between http-push.c and http-walker.c.

Patch #3 and #5 add features and fixes that were applied on to fetching code in http-push.c or http-walker.c, but not the other. Patch #4, like patch #3, applies onto the code for fetching pack indices (pack-*.idx), and fixes the issue of "mutating" value of the hex variable in fetch_index (especially likely to be encountered when using http-walker.c).

Patch #6 does some simple refactoring of variables and macros.

Patch #7 refactors the logic for appending slashes in quote_ref_url, creating a new method, end_url_with_slash. The latter method will be used in the following patches, since the base urls in http-walker.c and http-push.c are handled differently (ie. the former doesn't include a trailing slash, while the latter does). By using this method throughout, fetching code need not use different printf formatters or differentiate between invocations from http-push.c and http-walker.c.

Patch #8 to #11 refactors code that handles fetching of:
*pack indices (pack-*.idx)
*packs
*pack index (objects/info/packs)
*loose objects

Tay Ray Chuan (11):
t5550-http-fetch: test fetching of packed objects http-push, http-walker: style fixes
http-walker: verify remote packs
http*: copy string returned by sha1_to_hex
http-push: do not SEGV after fetching a bad pack idx file http*: move common variables and macros to http.[ch]
http: create function end_url_with_slash
http*: add fetch_http_pack_index
http*: add helper methods for fetching packs http*: add helper methods for fetching objects/info/packs http*: add helper methods for fetching objects (loose)

 http-push.c           |  472 +++++-------------------------------------
 http-walker.c         |  525 +++++++++-------------------------------------
 http.c                |  554 ++++++++++++++++++++++++++++++++++++++++++++++++-
 http.h                |   73 +++++++
 t/t5550-http-fetch.sh |    8 +
 5 files changed, 779 insertions(+), 853 deletions(-)