Re: [PATCH v4 3/8] branch: roll show_detached HEAD into regular ref_list
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Sep 13, 2015, 16:46 UTC
- Message-ID
- <CAPig+cTzEQ=+FKa2j2RbfHv_NP35_vPDq1NZCeek8LX9fJF3aQ@mail.gmail.com>
- In-Reply-To
- <vpqa8sqv7p1.fsf@anie.imag.fr>
On Sun, Sep 13, 2015 at 8:12 AM, Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> wrote:
Show 21 quoted lines
> Karthik Nayak <karthik.188@gmail.com> writes:
>
>> @@ -679,15 +682,20 @@ static int print_ref_list(int kinds, int detached, int verbose, int abbrev, stru
>> if (verbose)
>> maxwidth = calc_maxwidth(&ref_list, strlen(remote_prefix));
>>
>> - qsort(ref_list.list, ref_list.index, sizeof(struct ref_item), ref_cmp);
>> + 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;
>> + }
>
> I think Eric already mentionned it, but I don't remember the conclusion
> and can't find it in the archives. Wouldn't it be cleaner to actually
> remove the detached head from the array (do "ref_list.index -= 1"
> instead of "index -= 1", and possibly free() what needs to be freed?I think Michael Haggerty mentioned something along those lines...