summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 11c211f)
raw | patch | inline | side by side (parent: 11c211f)
author | Christian Couder <chriscool@tuxfamily.org> | |
Mon, 6 Apr 2009 20:28:00 +0000 (22:28 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 8 Apr 2009 05:12:41 +0000 (22:12 -0700) |
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>
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>
bisect.c | patch | blob | history | |
bisect.h | patch | blob | history | |
builtin-rev-list.c | patch | blob | history |
diff --git a/bisect.c b/bisect.c
index 69f8860ca1ac54ed4bc135017bce8e3ab6d9cbe2..4d2a150df2da769a20a70b909fdc905fc5000583 100644 (file)
--- a/bisect.c
+++ b/bisect.c
int bisect_next_vars(const char *prefix)
{
struct rev_info revs;
+ struct rev_list_info info;
int reaches = 0, all = 0;
+ memset(&info, 0, sizeof(info));
+ info.revs = &revs;
+
bisect_rev_setup(&revs, prefix);
if (prepare_revision_walk(&revs))
revs.commits = find_bisection(revs.commits, &reaches, &all,
!!skipped_sha1_nr);
- return show_bisect_vars(&revs, reaches, all,
+ return show_bisect_vars(&info, reaches, all,
BISECT_SHOW_TRIED | BISECT_SHOW_STRINGED);
}
diff --git a/bisect.h b/bisect.h
index f5d106735c41f9657b5d568ae3453386c9a64c08..b1c334d3492ca9097f97d72487ca531b4244d1ec 100644 (file)
--- a/bisect.h
+++ b/bisect.h
#define BISECT_SHOW_TRIED (1<<1)
#define BISECT_SHOW_STRINGED (1<<2)
-/*
- * The flag BISECT_SHOW_ALL should not be set if this function is called
- * from outside "builtin-rev-list.c" as otherwise it would use
- * static "revs" from this file.
- */
-extern int show_bisect_vars(struct rev_info *revs, int reaches, int all,
+struct rev_list_info {
+ struct rev_info *revs;
+ int show_timestamp;
+ int hdr_termination;
+ const char *header_prefix;
+};
+
+extern int show_bisect_vars(struct rev_list_info *info, int reaches, int all,
int flags);
extern int bisect_next_vars(const char *prefix);
diff --git a/builtin-rev-list.c b/builtin-rev-list.c
index cd6f6b8fbbf3c246b53ee2308baad37a97987002..244b73eaeb7a985ea8f73acbb99ffe930df9f785 100644 (file)
--- a/builtin-rev-list.c
+++ b/builtin-rev-list.c
" --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 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);
- if (show_timestamp)
+ if (info->show_timestamp)
printf("%lu ", commit->date);
- if (header_prefix)
- fputs(header_prefix, stdout);
+ if (info->header_prefix)
+ fputs(info->header_prefix, stdout);
if (!revs->graph) {
if (commit->object.flags & BOUNDARY)
}
} else {
if (buf.len)
- printf("%s%c", buf.buf, hdr_termination);
+ printf("%s%c", buf.buf, info->hdr_termination);
}
strbuf_release(&buf);
} else {
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;
char hex[41] = "", *format;
struct commit_list *tried;
+ struct rev_info *revs = info->revs;
if (!revs->commits && !(flags & BISECT_SHOW_TRIED))
return 1;
strcpy(hex, sha1_to_hex(revs->commits->item->object.sha1));
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");
}
int cmd_rev_list(int argc, const char **argv, const char *prefix)
{
struct rev_info revs;
- struct commit_list *list;
+ struct rev_list_info info;
int i;
int read_from_stdin = 0;
int bisect_list = 0;
revs.commit_format = CMIT_FMT_UNSPECIFIED;
argc = setup_revisions(argc, argv, &revs, NULL);
+ memset(&info, 0, sizeof(info));
+ info.revs = &revs;
+
quiet = DIFF_OPT_TST(&revs.diffopt, QUIET);
for (i = 1 ; i < argc; i++) {
const char *arg = argv[i];
continue;
}
if (!strcmp(arg, "--timestamp")) {
- show_timestamp = 1;
+ info.show_timestamp = 1;
continue;
}
if (!strcmp(arg, "--bisect")) {
}
if (revs.commit_format != CMIT_FMT_UNSPECIFIED) {
/* The command line has a --pretty */
- hdr_termination = '\n';
+ info.hdr_termination = '\n';
if (revs.commit_format == CMIT_FMT_ONELINE)
- header_prefix = "";
+ info.header_prefix = "";
else
- header_prefix = "commit ";
+ info.header_prefix = "commit ";
}
else if (revs.verbose_header)
/* Only --header was specified */
revs.commit_format = CMIT_FMT_RAW;
- list = revs.commits;
-
- if ((!list &&
+ if ((!revs.commits &&
(!(revs.tag_objects||revs.tree_objects||revs.blob_objects) &&
!revs.pending.nr)) ||
revs.diff)
bisect_find_all);
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);
}
traverse_commit_list(&revs,
quiet ? finish_commit : show_commit,
quiet ? finish_object : show_object,
- &revs);
+ &info);
return 0;
}