Patrick Steinhardt <ps@xxxxxx> writes: >> @@ -96,8 +97,12 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix) >> filter.name_patterns = argv; >> } >> >> + if (include_root_refs) { >> + flags |= FILTER_REFS_ROOT_REFS; >> + } > > Nit: we don't use braces for single-line blocks. > Right, thanks, I always trip on this. >> diff --git a/ref-filter.c b/ref-filter.c >> index acb960e35c..0e83e29390 100644 >> --- a/ref-filter.c >> +++ b/ref-filter.c >> @@ -2628,6 +2628,12 @@ static int for_each_fullref_in_pattern(struct ref_filter *filter, >> each_ref_fn cb, >> void *cb_data) >> { >> + if (filter->kind == FILTER_REFS_KIND_MASK) { >> + /* in this case, we want to print all refs including root refs. */ > > Nit: s/in/In, as this is a full sentence. > Will change >> @@ -2781,6 +2790,16 @@ static struct ref_array_item *apply_ref_filter(const char *refname, const struct >> >> /* Obtain the current ref kind from filter_ref_kind() and ignore unwanted refs. */ >> kind = filter_ref_kind(filter, refname); >> + >> + /* >> + * When printing HEAD with all other refs, we want to apply the same formatting >> + * rules as the other refs, so we simply ask it to be treated as a pseudoref. >> + */ >> + if (filter->kind == FILTER_REFS_KIND_MASK && kind == FILTER_REFS_DETACHED_HEAD) >> + kind = FILTER_REFS_PSEUDOREFS; > > I'm not sure why exactly we need to munge the kind here. Would be great > if the comment explained what the actual difference would be. > So the difference is $ git for-each-ref --include-root-refs 9eda75497d43f2f9c70c1e14afb865108f9b4b49 commit FETCH_HEAD ee99ac41aeb4129866710fc5771f11e1c1742dee commit HEAD 96c8a0712e569dd2812bf4fb5e72113caf326500 commit ORIG_HEAD vs $ git for-each-ref --include-root-refs | grep -v refs/ b4b94355057280749620c47999a4b45dc60f2681 commit (HEAD detached at b4b9435505) 9eda75497d43f2f9c70c1e14afb865108f9b4b49 commit FETCH_HEAD ee99ac41aeb4129866710fc5771f11e1c1742dee commit ORIG_HEAD This is because in `get_refname` we provide head description. But in git-for-each-ref we don't want this, we want the format to be consistent. >> + else if (!(kind & filter->kind)) >> + return NULL; >> + >> if (!(kind & filter->kind)) >> return NULL; > > This condition here is duplicated now, isn't it? > > Patrick > Seems like a bad merge on my end. Will fix. Thanks for the review. Will send a new version soon.
Attachment:
signature.asc
Description: PGP signature