rev-list: remove last static vars used in "show_commit"
This patch removes the last static variables that were used in the "show_commit" function. To do that, we create a new "rev_list_info" struct that we will pass in the "void *data" argument to "show_commit". This means that we have to change the first argument to "show_bisect_vars" too. While at it, we also remove a "struct commit_list *list" variable in "cmd_rev_list" that is not really needed. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
11c211fa06
commit
d797257eb2
6
bisect.c
6
bisect.c
@ -535,8 +535,12 @@ static void bisect_rev_setup(struct rev_info *revs, const char *prefix)
|
|||||||
int bisect_next_vars(const char *prefix)
|
int bisect_next_vars(const char *prefix)
|
||||||
{
|
{
|
||||||
struct rev_info revs;
|
struct rev_info revs;
|
||||||
|
struct rev_list_info info;
|
||||||
int reaches = 0, all = 0;
|
int reaches = 0, all = 0;
|
||||||
|
|
||||||
|
memset(&info, 0, sizeof(info));
|
||||||
|
info.revs = &revs;
|
||||||
|
|
||||||
bisect_rev_setup(&revs, prefix);
|
bisect_rev_setup(&revs, prefix);
|
||||||
|
|
||||||
if (prepare_revision_walk(&revs))
|
if (prepare_revision_walk(&revs))
|
||||||
@ -547,6 +551,6 @@ int bisect_next_vars(const char *prefix)
|
|||||||
revs.commits = find_bisection(revs.commits, &reaches, &all,
|
revs.commits = find_bisection(revs.commits, &reaches, &all,
|
||||||
!!skipped_sha1_nr);
|
!!skipped_sha1_nr);
|
||||||
|
|
||||||
return show_bisect_vars(&revs, reaches, all,
|
return show_bisect_vars(&info, reaches, all,
|
||||||
BISECT_SHOW_TRIED | BISECT_SHOW_STRINGED);
|
BISECT_SHOW_TRIED | BISECT_SHOW_STRINGED);
|
||||||
}
|
}
|
||||||
|
14
bisect.h
14
bisect.h
@ -14,12 +14,14 @@ extern struct commit_list *filter_skipped(struct commit_list *list,
|
|||||||
#define BISECT_SHOW_TRIED (1<<1)
|
#define BISECT_SHOW_TRIED (1<<1)
|
||||||
#define BISECT_SHOW_STRINGED (1<<2)
|
#define BISECT_SHOW_STRINGED (1<<2)
|
||||||
|
|
||||||
/*
|
struct rev_list_info {
|
||||||
* The flag BISECT_SHOW_ALL should not be set if this function is called
|
struct rev_info *revs;
|
||||||
* from outside "builtin-rev-list.c" as otherwise it would use
|
int show_timestamp;
|
||||||
* static "revs" from this file.
|
int hdr_termination;
|
||||||
*/
|
const char *header_prefix;
|
||||||
extern int show_bisect_vars(struct rev_info *revs, int reaches, int all,
|
};
|
||||||
|
|
||||||
|
extern int show_bisect_vars(struct rev_list_info *info, int reaches, int all,
|
||||||
int flags);
|
int flags);
|
||||||
|
|
||||||
extern int bisect_next_vars(const char *prefix);
|
extern int bisect_next_vars(const char *prefix);
|
||||||
|
@ -42,21 +42,18 @@ static const char rev_list_usage[] =
|
|||||||
" --bisect-all"
|
" --bisect-all"
|
||||||
;
|
;
|
||||||
|
|
||||||
static int show_timestamp;
|
|
||||||
static int hdr_termination;
|
|
||||||
static const char *header_prefix;
|
|
||||||
|
|
||||||
static void finish_commit(struct commit *commit, void *data);
|
static void finish_commit(struct commit *commit, void *data);
|
||||||
static void show_commit(struct commit *commit, void *data)
|
static void show_commit(struct commit *commit, void *data)
|
||||||
{
|
{
|
||||||
struct rev_info *revs = data;
|
struct rev_list_info *info = data;
|
||||||
|
struct rev_info *revs = info->revs;
|
||||||
|
|
||||||
graph_show_commit(revs->graph);
|
graph_show_commit(revs->graph);
|
||||||
|
|
||||||
if (show_timestamp)
|
if (info->show_timestamp)
|
||||||
printf("%lu ", commit->date);
|
printf("%lu ", commit->date);
|
||||||
if (header_prefix)
|
if (info->header_prefix)
|
||||||
fputs(header_prefix, stdout);
|
fputs(info->header_prefix, stdout);
|
||||||
|
|
||||||
if (!revs->graph) {
|
if (!revs->graph) {
|
||||||
if (commit->object.flags & BOUNDARY)
|
if (commit->object.flags & BOUNDARY)
|
||||||
@ -138,7 +135,7 @@ static void show_commit(struct commit *commit, void *data)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (buf.len)
|
if (buf.len)
|
||||||
printf("%s%c", buf.buf, hdr_termination);
|
printf("%s%c", buf.buf, info->hdr_termination);
|
||||||
}
|
}
|
||||||
strbuf_release(&buf);
|
strbuf_release(&buf);
|
||||||
} else {
|
} else {
|
||||||
@ -236,11 +233,13 @@ static void show_tried_revs(struct commit_list *tried, int stringed)
|
|||||||
printf(stringed ? "' &&\n" : "'\n");
|
printf(stringed ? "' &&\n" : "'\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
int show_bisect_vars(struct rev_info *revs, int reaches, int all, int flags)
|
int show_bisect_vars(struct rev_list_info *info, int reaches, int all,
|
||||||
|
int flags)
|
||||||
{
|
{
|
||||||
int cnt;
|
int cnt;
|
||||||
char hex[41] = "", *format;
|
char hex[41] = "", *format;
|
||||||
struct commit_list *tried;
|
struct commit_list *tried;
|
||||||
|
struct rev_info *revs = info->revs;
|
||||||
|
|
||||||
if (!revs->commits && !(flags & BISECT_SHOW_TRIED))
|
if (!revs->commits && !(flags & BISECT_SHOW_TRIED))
|
||||||
return 1;
|
return 1;
|
||||||
@ -264,7 +263,7 @@ int show_bisect_vars(struct rev_info *revs, int reaches, int all, int flags)
|
|||||||
strcpy(hex, sha1_to_hex(revs->commits->item->object.sha1));
|
strcpy(hex, sha1_to_hex(revs->commits->item->object.sha1));
|
||||||
|
|
||||||
if (flags & BISECT_SHOW_ALL) {
|
if (flags & BISECT_SHOW_ALL) {
|
||||||
traverse_commit_list(revs, show_commit, show_object, revs);
|
traverse_commit_list(revs, show_commit, show_object, info);
|
||||||
printf("------\n");
|
printf("------\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -298,7 +297,7 @@ int show_bisect_vars(struct rev_info *revs, int reaches, int all, int flags)
|
|||||||
int cmd_rev_list(int argc, const char **argv, const char *prefix)
|
int cmd_rev_list(int argc, const char **argv, const char *prefix)
|
||||||
{
|
{
|
||||||
struct rev_info revs;
|
struct rev_info revs;
|
||||||
struct commit_list *list;
|
struct rev_list_info info;
|
||||||
int i;
|
int i;
|
||||||
int read_from_stdin = 0;
|
int read_from_stdin = 0;
|
||||||
int bisect_list = 0;
|
int bisect_list = 0;
|
||||||
@ -313,6 +312,9 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
|
|||||||
revs.commit_format = CMIT_FMT_UNSPECIFIED;
|
revs.commit_format = CMIT_FMT_UNSPECIFIED;
|
||||||
argc = setup_revisions(argc, argv, &revs, NULL);
|
argc = setup_revisions(argc, argv, &revs, NULL);
|
||||||
|
|
||||||
|
memset(&info, 0, sizeof(info));
|
||||||
|
info.revs = &revs;
|
||||||
|
|
||||||
quiet = DIFF_OPT_TST(&revs.diffopt, QUIET);
|
quiet = DIFF_OPT_TST(&revs.diffopt, QUIET);
|
||||||
for (i = 1 ; i < argc; i++) {
|
for (i = 1 ; i < argc; i++) {
|
||||||
const char *arg = argv[i];
|
const char *arg = argv[i];
|
||||||
@ -322,7 +324,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!strcmp(arg, "--timestamp")) {
|
if (!strcmp(arg, "--timestamp")) {
|
||||||
show_timestamp = 1;
|
info.show_timestamp = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!strcmp(arg, "--bisect")) {
|
if (!strcmp(arg, "--bisect")) {
|
||||||
@ -352,19 +354,17 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
|
|||||||
}
|
}
|
||||||
if (revs.commit_format != CMIT_FMT_UNSPECIFIED) {
|
if (revs.commit_format != CMIT_FMT_UNSPECIFIED) {
|
||||||
/* The command line has a --pretty */
|
/* The command line has a --pretty */
|
||||||
hdr_termination = '\n';
|
info.hdr_termination = '\n';
|
||||||
if (revs.commit_format == CMIT_FMT_ONELINE)
|
if (revs.commit_format == CMIT_FMT_ONELINE)
|
||||||
header_prefix = "";
|
info.header_prefix = "";
|
||||||
else
|
else
|
||||||
header_prefix = "commit ";
|
info.header_prefix = "commit ";
|
||||||
}
|
}
|
||||||
else if (revs.verbose_header)
|
else if (revs.verbose_header)
|
||||||
/* Only --header was specified */
|
/* Only --header was specified */
|
||||||
revs.commit_format = CMIT_FMT_RAW;
|
revs.commit_format = CMIT_FMT_RAW;
|
||||||
|
|
||||||
list = revs.commits;
|
if ((!revs.commits &&
|
||||||
|
|
||||||
if ((!list &&
|
|
||||||
(!(revs.tag_objects||revs.tree_objects||revs.blob_objects) &&
|
(!(revs.tag_objects||revs.tree_objects||revs.blob_objects) &&
|
||||||
!revs.pending.nr)) ||
|
!revs.pending.nr)) ||
|
||||||
revs.diff)
|
revs.diff)
|
||||||
@ -387,14 +387,14 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
|
|||||||
bisect_find_all);
|
bisect_find_all);
|
||||||
|
|
||||||
if (bisect_show_vars)
|
if (bisect_show_vars)
|
||||||
return show_bisect_vars(&revs, reaches, all,
|
return show_bisect_vars(&info, reaches, all,
|
||||||
bisect_show_all ? BISECT_SHOW_ALL : 0);
|
bisect_show_all ? BISECT_SHOW_ALL : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
traverse_commit_list(&revs,
|
traverse_commit_list(&revs,
|
||||||
quiet ? finish_commit : show_commit,
|
quiet ? finish_commit : show_commit,
|
||||||
quiet ? finish_object : show_object,
|
quiet ? finish_object : show_object,
|
||||||
&revs);
|
&info);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user