[PATCH 1/2] Move in_merge_bases() to commit.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This reasonably useful function was hidden inside builtin-branch.c
---

 * This is used by the next one, which is why this is part of
   the 'reflog entry and pruning' series.

 builtin-branch.c |   21 +--------------------
 commit.c         |   17 +++++++++++++++++
 commit.h         |    1 +
 3 files changed, 19 insertions(+), 20 deletions(-)

diff --git a/builtin-branch.c b/builtin-branch.c
index 560309c..12eebc0 100644
--- a/builtin-branch.c
+++ b/builtin-branch.c
@@ -70,25 +70,6 @@ const char *branch_get_color(enum color_branch ix)
 	return "";
 }
 
-static int in_merge_bases(const unsigned char *sha1,
-			  struct commit *rev1,
-			  struct commit *rev2)
-{
-	struct commit_list *bases, *b;
-	int ret = 0;
-
-	bases = get_merge_bases(rev1, rev2, 1);
-	for (b = bases; b; b = b->next) {
-		if (!hashcmp(sha1, b->item->object.sha1)) {
-			ret = 1;
-			break;
-		}
-	}
-
-	free_commit_list(bases);
-	return ret;
-}
-
 static void delete_branches(int argc, const char **argv, int force)
 {
 	struct commit *rev, *head_rev = head_rev;
@@ -119,7 +100,7 @@ static void delete_branches(int argc, const char **argv, int force)
 		 */
 
 		if (!force &&
-		    !in_merge_bases(sha1, rev, head_rev)) {
+		    !in_merge_bases(rev, head_rev)) {
 			fprintf(stderr,
 				"The branch '%s' is not a strict subset of your current HEAD.\n"
 				"If you are sure you want to delete it, run 'git branch -D %s'.\n",
diff --git a/commit.c b/commit.c
index a6d543e..4bddcbe 100644
--- a/commit.c
+++ b/commit.c
@@ -1009,3 +1009,20 @@ struct commit_list *get_merge_bases(struct commit *one,
 	free(rslt);
 	return result;
 }
+
+int in_merge_bases(struct commit *rev1, struct commit *rev2)
+{
+	struct commit_list *bases, *b;
+	int ret = 0;
+
+	bases = get_merge_bases(rev1, rev2, 1);
+	for (b = bases; b; b = b->next) {
+		if (!hashcmp(rev1->object.sha1, b->item->object.sha1)) {
+			ret = 1;
+			break;
+		}
+	}
+
+	free_commit_list(bases);
+	return ret;
+}
diff --git a/commit.h b/commit.h
index fc13de9..10eea9f 100644
--- a/commit.h
+++ b/commit.h
@@ -107,4 +107,5 @@ int read_graft_file(const char *graft_file);
 
 extern struct commit_list *get_merge_bases(struct commit *rev1, struct commit *rev2, int cleanup);
 
+int in_merge_bases(struct commit *rev1, struct commit *rev2);
 #endif /* COMMIT_H */
-- 
1.4.4.2.g688739


-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]