@matheusbsbs / matheus-bagliano / commits / 7b0c996679
Fork 0

Move "--parent" parsing into generic revision.c library code

Not only do we do it in both rev-list.c and git.c, the revision walking code will soon want to know whether we should rewrite parenthood information or not. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>

Linus Torvalds committed Mar 30, 2006 at 16:52 UTC 7b0c996679e975b666fd27c922e1e0837b611c98
4 files changed +8 -12
git.c
+1 -5
@@ -283,7 +283,6 @@ static int cmd_log(int argc, const char **argv, char **envp)
283 char *buf = xmalloc(LOGSIZE);
284 static enum cmit_fmt commit_format = CMIT_FMT_DEFAULT;
285 int abbrev = DEFAULT_ABBREV;
286 - int show_parents = 0;
286 const char *commit_prefix = "commit ";
287
288 argc = setup_revisions(argc, argv, &rev, "HEAD");
@@ -294,9 +293,6 @@ static int cmd_log(int argc, const char **argv, char **envp)
293 if (commit_format == CMIT_FMT_ONELINE)
294 commit_prefix = "";
295 }
297 - else if (!strcmp(arg, "--parents")) {
298 - show_parents = 1;
299 - }
296 else if (!strcmp(arg, "--no-abbrev")) {
297 abbrev = 0;
298 }
@@ -317,7 +313,7 @@ static int cmd_log(int argc, const char **argv, char **envp)
313 while ((commit = get_revision(&rev)) != NULL) {
314 printf("%s%s", commit_prefix,
315 sha1_to_hex(commit->object.sha1));
320 - if (show_parents) {
316 + if (rev.parents) {
317 struct commit_list *parents = commit->parents;
318 while (parents) {
319 struct object *o = &(parents->item->object);
rev-list.c
+1 -6
@@ -39,7 +39,6 @@ struct rev_info revs;
39 static int bisect_list = 0;
40 static int verbose_header = 0;
41 static int abbrev = DEFAULT_ABBREV;
42 -static int show_parents = 0;
42 static int show_timestamp = 0;
43 static int hdr_termination = 0;
44 static const char *commit_prefix = "";
@@ -54,7 +53,7 @@ static void show_commit(struct commit *commit)
53 if (commit->object.flags & BOUNDARY)
54 putchar('-');
55 fputs(sha1_to_hex(commit->object.sha1), stdout);
57 - if (show_parents) {
56 + if (revs.parents) {
57 struct commit_list *parents = commit->parents;
58 while (parents) {
59 struct object *o = &(parents->item->object);
@@ -338,10 +337,6 @@ int main(int argc, const char **argv)
337 commit_prefix = "commit ";
338 continue;
339 }
341 - if (!strcmp(arg, "--parents")) {
342 - show_parents = 1;
343 - continue;
344 - }
340 if (!strcmp(arg, "--timestamp")) {
341 show_timestamp = 1;
342 continue;
revision.c
+4
@@ -605,6 +605,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
605 revs->limited = 1;
606 continue;
607 }
608 + if (!strcmp(arg, "--parents")) {
609 + revs->parents = 1;
610 + continue;
611 + }
612 if (!strcmp(arg, "--dense")) {
613 revs->dense = 1;
614 continue;
revision.h
+2 -1
@@ -34,7 +34,8 @@ struct rev_info {
34 edge_hint:1,
35 limited:1,
36 unpacked:1,
37 - boundary:1;
37 + boundary:1,
38 + parents:1;
39
40 /* special limits */
41 int max_count;