Remove unnecessary variables from ref_list and ref_item which were
used for width computation. This is to make ref_item similar to
ref-filter's ref_array_item. This will ensure a smooth port of
branch.c to use ref-filter APIs in further patches.
Previously the maxwidth was computed when inserting the refs into the
ref_list. Now, we obtain the entire ref_list and then compute
maxwidth.
Based-on-patch-by: Jeff King <peff@peff.net>
Mentored-by: Christian Couder <christian.couder@gmail.com>
Mentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Karthik Nayak10 years agocommitted byJunio C Hamano
@ -282,14 +282,14 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
@@ -282,14 +282,14 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
struct ref_item {
char *name;
char *dest;
unsigned int kind, width;
unsigned int kind;
struct commit *commit;
int ignore;
};
struct ref_list {
struct rev_info revs;
int index, alloc, maxwidth, verbose, abbrev;
int index, alloc, verbose, abbrev;
struct ref_item *list;
struct commit_list *with_commit;
int kinds;
@ -386,15 +386,8 @@ static int append_ref(const char *refname, const struct object_id *oid, int flag
@@ -386,15 +386,8 @@ static int append_ref(const char *refname, const struct object_id *oid, int flag
@ -624,6 +622,16 @@ static int print_ref_list(int kinds, int detached, int verbose, int abbrev, stru
@@ -624,6 +622,16 @@ static int print_ref_list(int kinds, int detached, int verbose, int abbrev, stru
int i;
struct append_ref_cb cb;
struct ref_list ref_list;
int maxwidth = 0;
const char *remote_prefix = "";
/*
* If we are listing more than just remote branches,
* then remote branches will have a "remotes/" prefix.
* We need to account for this in the width.
*/
if (kinds != REF_REMOTE_BRANCH)
remote_prefix = "remotes/";
memset(&ref_list, 0, sizeof(ref_list));
ref_list.kinds = kinds;
@ -667,26 +675,22 @@ static int print_ref_list(int kinds, int detached, int verbose, int abbrev, stru
@@ -667,26 +675,22 @@ static int print_ref_list(int kinds, int detached, int verbose, int abbrev, stru