ref-filter: Do not abruptly die when using the 'lstrip=<N>' option

Currently when we use the 'lstrip=<N>' option, if 'N' is greater than
the number of components available in the refname, we abruptly end
program execution by calling die().

This behavior is undesired since a single refname with few components
could end program execution. To avoid this, return an empty string
whenever the value 'N' is greater than the number of components
available, instead of calling die().

Signed-off-by: Karthik Nayak <Karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Karthik Nayak
2017-01-10 14:19:47 +05:30
committed by Junio C Hamano
parent 17938f171f
commit 3a42980f9e
3 changed files with 2 additions and 8 deletions

View File

@ -1099,8 +1099,7 @@ static const char *lstrip_ref_components(const char *refname, unsigned int len)
while (remaining) {
switch (*start++) {
case '\0':
die(_("ref '%s' does not have %ud components to :lstrip"),
refname, len);
return "";
case '/':
remaining--;
break;