From: Matthieu Moy Date: Sun, 20 Sep 2015 19:11:48 GMT Subject: Re: [PATCH v5 3/8] branch: roll show_detached HEAD into regular ref_list Message-ID: In-Reply-To: <1442772627-25421-4-git-send-email-Karthik.188@gmail.com> Karthik Nayak writes: > @@ -681,14 +684,12 @@ static int print_ref_list(int kinds, int detached, int verbose, int abbrev, stru > > qsort(ref_list.list, ref_list.index, sizeof(struct ref_item), ref_cmp); > > - detached = (detached && (kinds & REF_LOCAL_BRANCH)); > - if (detached && match_patterns(pattern, "HEAD")) > - show_detached(&ref_list, maxwidth); > - > for (i = 0; i < ref_list.index; i++) { > - int current = !detached && > - (ref_list.list[i].kind == REF_LOCAL_BRANCH) && > + int current = !detached && (ref_list.list[i].kind == REF_LOCAL_BRANCH) && > !strcmp(ref_list.list[i].name, head); > + /* If detached the first ref_item is the current ref */ This relies on the fact that sorting (qsort above) did not move HEAD from its first position. This is OK, as we don't have a --sort option yet. Good. -- Matthieu Moy http://www-verimag.imag.fr/~moy/