diff --git a/refspec.c b/refspec.c index 54b6fe0c6d..597ddf8b52 100644 --- a/refspec.c +++ b/refspec.c @@ -122,12 +122,16 @@ static int parse_refspec(struct refspec_item *item, const char *refspec, int fet return 1; } -void refspec_item_init_or_die(struct refspec_item *item, const char *refspec, - int fetch) +int refspec_item_init(struct refspec_item *item, const char *refspec, int fetch) { memset(item, 0, sizeof(*item)); + return parse_refspec(item, refspec, fetch); +} - if (!parse_refspec(item, refspec, fetch)) +void refspec_item_init_or_die(struct refspec_item *item, const char *refspec, + int fetch) +{ + if (!refspec_item_init(item, refspec, fetch)) die("Invalid refspec '%s'", refspec); } diff --git a/refspec.h b/refspec.h index 4caaf1f8e3..9b6e64a824 100644 --- a/refspec.h +++ b/refspec.h @@ -32,6 +32,8 @@ struct refspec { int fetch; }; +int 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);