summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2017-06-18 15:39:42 +0200
committerJunio C Hamano <gitster@pobox.com>2017-06-18 22:13:59 -0700
commit57e3c38f8bbe8b2ebf1a621fd35b5a3860174728 (patch)
tree4f2990a629d87e3b39af05ac7f2b9513b0271c3f
parent03df567fbf6afeca32f6a27d04656c1a3a162453 (diff)
downloadgit-mh/packed-ref-store-prep-extra.tar.gz
prefix_ref_iterator_advance(): relax the check of trim lengthmh/packed-ref-store-prep-extra
Before the previous commit, `for_each_bad_bisect_ref()` called `for_each_fullref_in_submodule()` in such a way as to trim the whole refname away. This is a questionable use of the API, but is not ipso facto dangerous, so tolerate it in case there are other callers relying on this behavior. But continue to refuse to trim *more* characters than the refname contains, as that really makes no sense. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--refs/iterator.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/refs/iterator.c b/refs/iterator.c
index 4cf449ef66..de52d5fe93 100644
--- a/refs/iterator.c
+++ b/refs/iterator.c
@@ -298,11 +298,11 @@ static int prefix_ref_iterator_advance(struct ref_iterator *ref_iterator)
* you haven't already checked for via a
* prefix check, whether via this
* `prefix_ref_iterator` or upstream in
- * `iter0`). So if there wouldn't be at least
- * one character left in the refname after
- * trimming, report it as a bug:
+ * `iter0`. So consider it a bug if we are
+ * asked to trim off more characters than the
+ * refname contains:
*/
- if (strlen(iter->iter0->refname) <= iter->trim)
+ if (strlen(iter->iter0->refname) < iter->trim)
die("BUG: attempt to trim too many characters");
iter->base.refname = iter->iter0->refname + iter->trim;
} else {