read_raw_ref(): rename flags argument to type

This will hopefully reduce confusion with the "flags" arguments that are used in many functions in this module as an input parameter to choose how the function should operate. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>

Michael Haggerty committed Apr 26, 2016 at 03:06 UTC 3a0b6b9aba844075e802a6dc4c24622b34ab535b
2 files changed +10 -10
refs/files-backend.c
+9 -9
@@ -1395,18 +1395,18 @@ static int resolve_missing_loose_ref(const char *refname,
1395 *
1396 * If the ref is symbolic, fill in *symref with the referrent
1397 * (e.g. "refs/heads/master") and return 0. The caller is responsible
1398 - * for validating the referrent. Set REF_ISSYMREF in flags.
1398 + * for validating the referrent. Set REF_ISSYMREF in type.
1399 *
1400 * If the ref doesn't exist, set errno to ENOENT and return -1.
1401 *
1402 * If the ref exists but is neither a symbolic ref nor a sha1, it is
1403 - * broken. Set REF_ISBROKEN in flags, set errno to EINVAL, and return
1403 + * broken. Set REF_ISBROKEN in type, set errno to EINVAL, and return
1404 * -1.
1405 *
1406 * If there is another error reading the ref, set errno appropriately and
1407 * return -1.
1408 *
1409 - * Backend-specific flags might be set in flags as well, regardless of
1409 + * Backend-specific flags might be set in type as well, regardless of
1410 * outcome.
1411 *
1412 * sb_path is workspace: the caller should allocate and free it.
@@ -1419,7 +1419,7 @@ static int resolve_missing_loose_ref(const char *refname,
1419 * refname will still be valid and unchanged.
1420 */
1421 int read_raw_ref(const char *refname, unsigned char *sha1,
1422 - struct strbuf *symref, unsigned int *flags)
1422 + struct strbuf *symref, unsigned int *type)
1423 {
1424 struct strbuf sb_contents = STRBUF_INIT;
1425 struct strbuf sb_path = STRBUF_INIT;
@@ -1448,7 +1448,7 @@ stat_ref:
1448 if (lstat(path, &st) < 0) {
1449 if (errno != ENOENT)
1450 goto out;
1451 - if (resolve_missing_loose_ref(refname, sha1, flags)) {
1451 + if (resolve_missing_loose_ref(refname, sha1, type)) {
1452 errno = ENOENT;
1453 goto out;
1454 }
@@ -1469,7 +1469,7 @@ stat_ref:
1469 if (starts_with(sb_contents.buf, "refs/") &&
1470 !check_refname_format(sb_contents.buf, 0)) {
1471 strbuf_swap(&sb_contents, symref);
1472 - *flags |= REF_ISSYMREF;
1472 + *type |= REF_ISSYMREF;
1473 ret = 0;
1474 goto out;
1475 }
@@ -1482,7 +1482,7 @@ stat_ref:
1482 * ref is supposed to be, there could still be a
1483 * packed ref:
1484 */
1485 - if (resolve_missing_loose_ref(refname, sha1, flags)) {
1485 + if (resolve_missing_loose_ref(refname, sha1, type)) {
1486 errno = EISDIR;
1487 goto out;
1488 }
@@ -1519,7 +1519,7 @@ stat_ref:
1519
1520 strbuf_reset(symref);
1521 strbuf_addstr(symref, buf);
1522 - *flags |= REF_ISSYMREF;
1522 + *type |= REF_ISSYMREF;
1523 ret = 0;
1524 goto out;
1525 }
@@ -1530,7 +1530,7 @@ stat_ref:
1530 */
1531 if (get_sha1_hex(buf, sha1) ||
1532 (buf[40] != '\0' && !isspace(buf[40]))) {
1533 - *flags |= REF_ISBROKEN;
1533 + *type |= REF_ISBROKEN;
1534 errno = EINVAL;
1535 goto out;
1536 }
refs/refs-internal.h
+1 -1
@@ -210,6 +210,6 @@ int do_for_each_ref(const char *submodule, const char *base,
210 each_ref_fn fn, int trim, int flags, void *cb_data);
211
212 int read_raw_ref(const char *refname, unsigned char *sha1,
213 - struct strbuf *symref, unsigned int *flags);
213 + struct strbuf *symref, unsigned int *type);
214
215 #endif /* REFS_REFS_INTERNAL_H */