diff options
| author | SZEDER Gábor <szeder.dev@gmail.com> | 2017-06-07 17:36:28 +0200 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2017-06-21 15:44:35 -0700 |
| commit | eb0c621d1ec952048bc0b2222e2dd81f1fe58dbd (patch) | |
| tree | a72fb52c89a388ea302bd602592b33e6eb5cdfb5 /builtin/commit-tree.c | |
| parent | f87599d4be11b3aac97562c78b7f0f2af99eb8fa (diff) | |
| download | git-eb0c621d1ec952048bc0b2222e2dd81f1fe58dbd.tar.gz | |
remote.c: eliminate remote->fetch_refspec
'struct remote' stores fetch refspecs twice: once in their original
string form in remote->fetch_refspecs and once in their parsed form in
remote->fetch.
The main reason for this is that we want to read the configuration
only once, but we don't want to error out while doing so because of a
bogus refspec in a remote that we aren't accessing at all. Therefore,
when the configuration is read all refspecs are simply stored in
string arrays for each remote, and then refspecs of a particular
remote are parsed lazily, only when that remote is actually accessed.
However, storing refspecs in both forms has some drawbacks:
- The same information is stored twice, wasting memory.
- remote->fetch_refspecs, i.e. the string array is conveniently
ALLOC_GROW()-able with associated 'fetch_refspec_{nr,alloc}'
fields, but remote->fetch is not.
- Wherever remote->fetch are accessed, the number of parsed refspecs
in there is specified by remote->fetch_refspec_nr. This requires
us to keep the two arrays in sync and makes adding additional
refspecs cumbersome and error prone.
So eliminate remote->fetch_refspec and parse fetch refspecs right away
while they are being read from the configuration. However, to avoid
erroring out on bogus refspecs in "uninteresting" remotes, parse them
gently: instead of die()ing, store the problematic refspec in
remote->bogus_refspec, so it will be available later when that remote
is actually accessed and we can use it in the error message. Make
remote->fetch ALLOC_GROW()-able. Add a new add_fetch_refspec()
function to the remote API, replacing an old function with the same
name and add_and_parse_fetch_refspec(), to encompass memory
management of remote->fetch and parsing the new refspec (gently or
otherwise). Update all sites accessing fetch-refspec-related fields
to use the new field names.
Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Diffstat (limited to 'builtin/commit-tree.c')
0 files changed, 0 insertions, 0 deletions
