Karthik Nayak <karthik.188@xxxxxxxxx> writes: > + /* > + * First we obtain all regular branch refs and if the HEAD is > + * detached then we insert that ref to the end of the ref_fist > + * so that it can be printed and removed first. > + */ > for_each_rawref(append_ref, &cb); > + if (detached) > + head_ref(append_ref, &cb); > + index = ref_list.index; > + > + /* Print detached HEAD before sorting and printing the rest */ > + if (detached && (ref_list.list[index - 1].kind == REF_DETACHED_HEAD) && > + !strcmp(ref_list.list[index - 1].name, head)) { > + print_ref_item(&ref_list.list[index - 1], maxwidth, verbose, abbrev, > + 1, remote_prefix); > + index -= 1; > + } > > + qsort(ref_list.list, index, sizeof(struct ref_item), ref_cmp); This looks somewhat strange. Wouldn't it be more consistent to teach ref_cmp that HEAD sorts where in the collection of refs (I presume that kind is checked first and then name, so if you give REF_DETACHED_HEAD a low number than others, it would automatically give you the ordering you want) without all of the above special casing? -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html