Rename the refspec_item_init() function introduced in 6d4c057859 ("refspec: introduce struct refspec", 2018-05-16) to refspec_item_init_or_die(). This follows the convention of other *_or_die() functions, and is done in preparation for making it a wrapper for a non-fatal variant. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> --- builtin/clone.c | 2 +- builtin/pull.c | 2 +- refspec.c | 5 +++-- refspec.h | 3 ++- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/builtin/clone.c b/builtin/clone.c index 99e73dae85..74a804f2e8 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -1077,7 +1077,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix) if (option_required_reference.nr || option_optional_reference.nr) setup_reference(); - refspec_item_init(&refspec, value.buf, REFSPEC_FETCH); + refspec_item_init_or_die(&refspec, value.buf, REFSPEC_FETCH); strbuf_reset(&value); diff --git a/builtin/pull.c b/builtin/pull.c index 1f2ecf3a88..bb64631d98 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -684,7 +684,7 @@ static const char *get_tracking_branch(const char *remote, const char *refspec) const char *spec_src; const char *merge_branch; - refspec_item_init(&spec, refspec, REFSPEC_FETCH); + refspec_item_init_or_die(&spec, refspec, REFSPEC_FETCH); spec_src = spec.src; if (!*spec_src || !strcmp(spec_src, "HEAD")) spec_src = "HEAD"; diff --git a/refspec.c b/refspec.c index 78edc48ae8..0fd392e96b 100644 --- a/refspec.c +++ b/refspec.c @@ -124,7 +124,8 @@ static int parse_refspec(struct refspec_item *item, const char *refspec, int fet return 1; } -void refspec_item_init(struct refspec_item *item, const char *refspec, int fetch) +void refspec_item_init_or_die(struct refspec_item *item, const char *refspec, + int fetch) { memset(item, 0, sizeof(*item)); @@ -152,7 +153,7 @@ void refspec_append(struct refspec *rs, const char *refspec) { struct refspec_item item; - refspec_item_init(&item, refspec, rs->fetch); + refspec_item_init_or_die(&item, refspec, rs->fetch); ALLOC_GROW(rs->items, rs->nr + 1, rs->alloc); rs->items[rs->nr++] = item; diff --git a/refspec.h b/refspec.h index 3a9363887c..4caaf1f8e3 100644 --- a/refspec.h +++ b/refspec.h @@ -32,7 +32,8 @@ struct refspec { int fetch; }; -void refspec_item_init(struct refspec_item *item, const char *refspec, int fetch); +void refspec_item_init_or_die(struct refspec_item *item, const char *refspec, + int fetch); void refspec_item_clear(struct refspec_item *item); void refspec_init(struct refspec *rs, int fetch); void refspec_append(struct refspec *rs, const char *refspec); -- 2.17.0.290.gded63e768a