}
if (include_root_refs)
- flags |= FILTER_REFS_ROOT_REFS;
+ flags |= FILTER_REFS_ROOT_REFS | FILTER_REFS_DETACHED_HEAD;
filter.match_as_path = 1;
filter_and_format_refs(&filter, flags, sorting, &format);
each_ref_fn cb,
void *cb_data)
{
- if (filter->kind == FILTER_REFS_KIND_MASK) {
+ if (filter->kind & FILTER_REFS_ROOT_REFS) {
/* In this case, we want to print all refs including root refs. */
return refs_for_each_include_root_refs(get_main_ref_store(the_repository),
cb, cb_data);
return ref_kind[i].kind;
}
- if (is_root_ref(refname))
+ if (is_pseudo_ref(refname))
return FILTER_REFS_PSEUDOREFS;
+ if (is_root_ref(refname))
+ return FILTER_REFS_ROOT_REFS;
return FILTER_REFS_OTHERS;
}
/*
* Generally HEAD refs are printed with special description denoting a rebase,
* detached state and so forth. This is useful when only printing the HEAD ref
- * But when it is being printed along with other pseudorefs, it makes sense to
- * keep the formatting consistent. So we mask the type to act like a pseudoref.
+ * But when it is being printed along with other root refs, it makes sense to
+ * keep the formatting consistent. So we mask the type to act like a root ref.
*/
- if (filter->kind == FILTER_REFS_KIND_MASK && kind == FILTER_REFS_DETACHED_HEAD)
- kind = FILTER_REFS_PSEUDOREFS;
+ if (filter->kind & FILTER_REFS_ROOT_REFS && kind == FILTER_REFS_DETACHED_HEAD)
+ kind = FILTER_REFS_ROOT_REFS;
else if (!(kind & filter->kind))
return NULL;
* When printing all ref types, HEAD is already included,
* so we don't want to print HEAD again.
*/
- if (!ret && (filter->kind != FILTER_REFS_KIND_MASK) &&
+ if (!ret && !(filter->kind & FILTER_REFS_ROOT_REFS) &&
(filter->kind & FILTER_REFS_DETACHED_HEAD))
head_ref(fn, cb_data);
}
FILTER_REFS_REMOTES | FILTER_REFS_OTHERS)
#define FILTER_REFS_DETACHED_HEAD 0x0020
#define FILTER_REFS_PSEUDOREFS 0x0040
-#define FILTER_REFS_ROOT_REFS (FILTER_REFS_DETACHED_HEAD | FILTER_REFS_PSEUDOREFS)
+#define FILTER_REFS_ROOT_REFS 0x0080
#define FILTER_REFS_KIND_MASK (FILTER_REFS_REGULAR | FILTER_REFS_DETACHED_HEAD | \
- FILTER_REFS_PSEUDOREFS)
+ FILTER_REFS_PSEUDOREFS | FILTER_REFS_ROOT_REFS)
struct atom_value;
struct ref_sorting;
starts_with(refname, "refs/rewritten/");
}
-static int is_pseudo_ref(const char *refname)
+int is_pseudo_ref(const char *refname)
{
- /*
- * Pseudorefs are refs that have different semantics compared to
- * "normal" refs. These refs can thus not be stored in the ref backend,
- * but must always be accessed via the filesystem. The following refs
- * are pseudorefs:
- *
- * - FETCH_HEAD may contain multiple object IDs, and each one of them
- * carries additional metadata like where it came from.
- *
- * - MERGE_HEAD may contain multiple object IDs when merging multiple
- * heads.
- *
- * Reading, writing or deleting references must consistently go either
- * through the filesystem (pseudorefs) or through the reference
- * backend (normal ones).
- */
static const char * const pseudo_refs[] = {
"FETCH_HEAD",
"MERGE_HEAD",
*/
int is_root_ref(const char *refname);
+/*
+ * Pseudorefs are refs that have different semantics compared to
+ * "normal" refs. These refs can thus not be stored in the ref backend,
+ * but must always be accessed via the filesystem. The following refs
+ * are pseudorefs:
+ *
+ * - FETCH_HEAD may contain multiple object IDs, and each one of them
+ * carries additional metadata like where it came from.
+ *
+ * - MERGE_HEAD may contain multiple object IDs when merging multiple
+ * heads.
+ *
+ * Reading, writing or deleting references must consistently go either
+ * through the filesystem (pseudorefs) or through the reference
+ * backend (normal ones).
+ */
+int is_pseudo_ref(const char *refname);
+
#endif /* REFS_H */