@matheusbsbs / matheus-bagliano / commits / c0fa8255c6
Fork 0

Fold get_merge_bases_clean() into get_merge_bases()

Change get_merge_bases() to be able to clean up after itself if needed by adding a cleanup parameter. We don't need to save the flags and restore them afterwards anymore; that was a leftover from before the flags were moved out of the range used in revision.c. clear_commit_marks() sets them to zero, which is enough. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>

Rene Scharfe committed Jul 2, 2006 at 11:49 UTC c0fa8255c652e148f0910425d2cc2b8029065008
4 files changed +9 -19
commit.c
+6 -15
@@ -1012,7 +1012,8 @@ static void mark_reachable_commits(struct commit_list *result,
1012 }
1013 }
1014
1015 -struct commit_list *get_merge_bases(struct commit *rev1, struct commit *rev2)
1015 +struct commit_list *get_merge_bases(struct commit *rev1, struct commit *rev2,
1016 + int cleanup)
1017 {
1018 struct commit_list *list = NULL;
1019 struct commit_list *result = NULL;
@@ -1080,20 +1081,10 @@ struct commit_list *get_merge_bases(struct commit *rev1, struct commit *rev2)
1081 tmp = next;
1082 }
1083
1083 - return result;
1084 -}
1085 -
1086 -struct commit_list *get_merge_bases_clean(struct commit *rev1,
1087 - struct commit *rev2)
1088 -{
1089 - unsigned int flags1 = rev1->object.flags;
1090 - unsigned int flags2 = rev2->object.flags;
1091 - struct commit_list *result = get_merge_bases(rev1, rev2);
1092 -
1093 - clear_commit_marks(rev1, PARENT1 | PARENT2 | UNINTERESTING);
1094 - clear_commit_marks(rev2, PARENT1 | PARENT2 | UNINTERESTING);
1095 - rev1->object.flags = flags1;
1096 - rev2->object.flags = flags2;
1084 + if (cleanup) {
1085 + clear_commit_marks(rev1, PARENT1 | PARENT2 | UNINTERESTING);
1086 + clear_commit_marks(rev2, PARENT1 | PARENT2 | UNINTERESTING);
1087 + }
1088
1089 return result;
1090 }
commit.h
+1 -2
@@ -105,7 +105,6 @@ struct commit_graft *read_graft_line(char *buf, int len);
105 int register_commit_graft(struct commit_graft *, int);
106 int read_graft_file(const char *graft_file);
107
108 -extern struct commit_list *get_merge_bases(struct commit *rev1, struct commit *rev2);
109 -extern struct commit_list *get_merge_bases_clean(struct commit *rev1, struct commit *rev2);
108 +extern struct commit_list *get_merge_bases(struct commit *rev1, struct commit *rev2, int cleanup);
109
110 #endif /* COMMIT_H */
merge-base.c
+1 -1
@@ -6,7 +6,7 @@ static int show_all = 0;
6
7 static int merge_base(struct commit *rev1, struct commit *rev2)
8 {
9 - struct commit_list *result = get_merge_bases(rev1, rev2);
9 + struct commit_list *result = get_merge_bases(rev1, rev2, 0);
10
11 if (!result)
12 return 1;
revision.c
+1 -1
@@ -813,7 +813,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
813 }
814
815 if (symmetric) {
816 - exclude = get_merge_bases_clean(a, b);
816 + exclude = get_merge_bases(a, b, 1);
817 add_pending_commit_list(revs, exclude,
818 flags_exclude);
819 a->object.flags |= flags;