git-2.22.0/refs/packed-backend.c
/*
 * Move the iterator to the next record in the snapshot, without
 * respect for whether the record is actually required by the current
 * iteration. Adjust the fields in `iter` and return `ITER_OK` or
 * `ITER_DONE`. This function does not free the iterator in the case
 * of `ITER_DONE`.
 */
Move the iterator to the next record in the snapshot, without
respect for whether the record is actually required by the current
iteration.
Move the iterator to the next record in the snapshot without respect for whether the record is actually required by the current iteration .
static int next_record(struct packed_ref_iterator *iter)
{
	const char *p = iter->pos, *eol;
	strbuf_reset(&iter->refname_buf);
	if (iter->pos == iter->eof)
		return ITER_DONE;
	iter->base.flags = REF_ISPACKED;
	if (iter->eof - p < the_hash_algo->hexsz + 2 ||
	    parse_oid_hex(p, &iter->oid, &p) ||
	    !isspace(*p++))
		die_invalid_line(iter->snapshot->refs->path,
				 iter->pos, iter->eof - iter->pos);
	eol = memchr(p, '\n', iter->eof - p);
	if (!eol)
		die_unterminated_line(iter->snapshot->refs->path,
				      iter->pos, iter->eof - iter->pos);
	strbuf_add(&iter->refname_buf, p, eol - p);
	iter->base.refname = iter->refname_buf.buf;
	if (check_refname_format(iter->base.refname, REFNAME_ALLOW_ONELEVEL)) {
		if (!refname_is_safe(iter->base.refname))
			die("packed refname is dangerous: %s",
			    iter->base.refname);
		oidclr(&iter->oid);
		iter->base.flags |= REF_BAD_NAME | REF_ISBROKEN;
	}
	if (iter->snapshot->peeled == PEELED_FULLY ||
	    (iter->snapshot->peeled == PEELED_TAGS &&
	     starts_with(iter->base.refname, "refs/tags/")))
		iter->base.flags |= REF_KNOWS_PEELED;
	iter->pos = eol + 1;
	if (iter->pos < iter->eof && *iter->pos == '^') {
		p = iter->pos + 1;
		if (iter->eof - p < the_hash_algo->hexsz + 1 ||
		    parse_oid_hex(p, &iter->peeled, &p) ||
		    *p++ != '\n')
			die_invalid_line(iter->snapshot->refs->path,
					 iter->pos, iter->eof - iter->pos);
		iter->pos = p;
		if ((iter->base.flags & REF_ISBROKEN)) {
			oidclr(&iter->peeled);
			iter->base.flags &= ~REF_KNOWS_PEELED;
		} else {
			iter->base.flags |= REF_KNOWS_PEELED;
		}
	} else {
		oidclr(&iter->peeled);
	}
	return ITER_OK;
}
static int next_record ( struct packed_ref_iterator * iter ) { const char * p = iter -> pos , * eol ; strbuf_reset ( & iter -> refname_buf ) ; if ( iter -> pos == iter -> eof ) return ITER_DONE ; iter -> base . flags = REF_ISPACKED ; if ( iter -> eof - p < the_hash_algo -> hexsz + 2 || parse_oid_hex ( p , & iter -> oid , & p ) || ! isspace ( * p ++ ) ) die_invalid_line ( iter -> snapshot -> refs -> path , iter -> pos , iter -> eof - iter -> pos ) ; eol = memchr ( p , ' \n ' , iter -> eof - p ) ; if ( ! eol ) die_unterminated_line ( iter -> snapshot -> refs -> path , iter -> pos , iter -> eof - iter -> pos ) ; strbuf_add ( & iter -> refname_buf , p , eol - p ) ; iter -> base . refname = iter -> refname_buf . buf ; if ( check_refname_format ( iter -> base . refname , REFNAME_ALLOW_ONELEVEL ) ) { if ( ! refname_is_safe ( iter -> base . refname ) ) die ( " " , iter -> base . refname ) ; oidclr ( & iter -> oid ) ; iter -> base . flags |= REF_BAD_NAME | REF_ISBROKEN ; } if ( iter -> snapshot -> peeled == PEELED_FULLY || ( iter -> snapshot -> peeled == PEELED_TAGS && starts_with ( iter -> base . refname , " " ) ) ) iter -> base . flags |= REF_KNOWS_PEELED ; iter -> pos = eol + 1 ; if ( iter -> pos < iter -> eof && * iter -> pos == ' ' ) { p = iter -> pos + 1 ; if ( iter -> eof - p < the_hash_algo -> hexsz + 1 || parse_oid_hex ( p , & iter -> peeled , & p ) || * p ++ != ' \n ' ) die_invalid_line ( iter -> snapshot -> refs -> path , iter -> pos , iter -> eof - iter -> pos ) ; iter -> pos = p ; if ( ( iter -> base . flags & REF_ISBROKEN ) ) { oidclr ( & iter -> peeled ) ; iter -> base . flags &= ~ REF_KNOWS_PEELED ; } else { iter -> base . flags |= REF_KNOWS_PEELED ; } } else { oidclr ( & iter -> peeled ) ; } return ITER_OK ; }
Move the iterator to the next record in the snapshot, without
 respect for whether the record is actually required by the current
 iteration.
Move the iterator to the next record in the snapshot without respect for whether the record is actually required by the current iteration .
/*
		 * Regardless of what the file header said, we
		 * definitely know the value of *this* reference. But
		 * we suppress it if the reference is broken:
		 */