diff options
author | Junio C Hamano <junkio@cox.net> | 2007-02-13 16:50:32 -0800 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2007-02-13 16:54:35 -0800 |
commit | 4a164d48df6bb1b4a771741c63d4437fd2dca0bb (patch) | |
tree | 73e3b0ca16e8ea83e9f761af476736c29b24caf9 | |
parent | f8f2aaa17297d6b21c84641edc2f6135575a003c (diff) | |
parent | 03840fc32d783be6750bf7e41a89687b8c3053eb (diff) | |
download | git-4a164d48df6bb1b4a771741c63d4437fd2dca0bb.tar.gz |
Merge branch 'jc/merge-base' (early part)
This contains an evil merge to fast-import, in order to
resolve in_merge_bases() update.
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | builtin-branch.c | 2 | ||||
-rw-r--r-- | builtin-merge-base.c (renamed from merge-base.c) | 12 | ||||
-rw-r--r-- | builtin-reflog.c | 4 | ||||
-rw-r--r-- | builtin.h | 1 | ||||
-rw-r--r-- | commit.c | 9 | ||||
-rw-r--r-- | commit.h | 2 | ||||
-rw-r--r-- | fast-import.c | 2 | ||||
-rw-r--r-- | git.c | 1 |
9 files changed, 19 insertions, 15 deletions
@@ -291,6 +291,7 @@ BUILTIN_OBJS = \ builtin-ls-tree.o \ builtin-mailinfo.o \ builtin-mailsplit.o \ + builtin-merge-base.o \ builtin-merge-file.o \ builtin-mv.o \ builtin-name-rev.o \ diff --git a/builtin-branch.c b/builtin-branch.c index 2d8d61b453..d0e7209368 100644 --- a/builtin-branch.c +++ b/builtin-branch.c @@ -134,7 +134,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds) */ if (!force && - !in_merge_bases(rev, head_rev)) { + !in_merge_bases(rev, &head_rev, 1)) { error("The branch '%s' is not a strict subset of " "your current HEAD.\n" "If you are sure you want to delete it, " diff --git a/merge-base.c b/builtin-merge-base.c index 385f4ba386..e35d362f26 100644 --- a/merge-base.c +++ b/builtin-merge-base.c @@ -1,9 +1,7 @@ #include "cache.h" #include "commit.h" -static int show_all; - -static int merge_base(struct commit *rev1, struct commit *rev2) +static int show_merge_base(struct commit *rev1, struct commit *rev2, int show_all) { struct commit_list *result = get_merge_bases(rev1, rev2, 0); @@ -23,16 +21,16 @@ static int merge_base(struct commit *rev1, struct commit *rev2) static const char merge_base_usage[] = "git-merge-base [--all] <commit-id> <commit-id>"; -int main(int argc, char **argv) +int cmd_merge_base(int argc, const char **argv, const char *prefix) { struct commit *rev1, *rev2; unsigned char rev1key[20], rev2key[20]; + int show_all = 0; - setup_git_directory(); git_config(git_default_config); while (1 < argc && argv[1][0] == '-') { - char *arg = argv[1]; + const char *arg = argv[1]; if (!strcmp(arg, "-a") || !strcmp(arg, "--all")) show_all = 1; else @@ -49,5 +47,5 @@ int main(int argc, char **argv) rev2 = lookup_commit_reference(rev2key); if (!rev1 || !rev2) return 1; - return merge_base(rev1, rev2); + return show_merge_base(rev1, rev2, show_all); } diff --git a/builtin-reflog.c b/builtin-reflog.c index 65b845b447..341555139e 100644 --- a/builtin-reflog.c +++ b/builtin-reflog.c @@ -215,8 +215,8 @@ static int expire_reflog_ent(unsigned char *osha1, unsigned char *nsha1, old = lookup_commit_reference_gently(osha1, 1); if (!new && !is_null_sha1(nsha1)) new = lookup_commit_reference_gently(nsha1, 1); - if ((old && !in_merge_bases(old, cb->ref_commit)) || - (new && !in_merge_bases(new, cb->ref_commit))) + if ((old && !in_merge_bases(old, &cb->ref_commit, 1)) || + (new && !in_merge_bases(new, &cb->ref_commit, 1))) goto prune; } @@ -44,6 +44,7 @@ extern int cmd_ls_files(int argc, const char **argv, const char *prefix); extern int cmd_ls_tree(int argc, const char **argv, const char *prefix); extern int cmd_mailinfo(int argc, const char **argv, const char *prefix); extern int cmd_mailsplit(int argc, const char **argv, const char *prefix); +extern int cmd_merge_base(int argc, const char **argv, const char *prefix); extern int cmd_merge_file(int argc, const char **argv, const char *prefix); extern int cmd_mv(int argc, const char **argv, const char *prefix); extern int cmd_name_rev(int argc, const char **argv, const char *prefix); @@ -1187,14 +1187,17 @@ struct commit_list *get_merge_bases(struct commit *one, return result; } -int in_merge_bases(struct commit *rev1, struct commit *rev2) +int in_merge_bases(struct commit *commit, struct commit **reference, int num) { struct commit_list *bases, *b; int ret = 0; - bases = get_merge_bases(rev1, rev2, 1); + if (num == 1) + bases = get_merge_bases(commit, *reference, 1); + else + die("not yet"); for (b = bases; b; b = b->next) { - if (!hashcmp(rev1->object.sha1, b->item->object.sha1)) { + if (!hashcmp(commit->object.sha1, b->item->object.sha1)) { ret = 1; break; } @@ -114,5 +114,5 @@ extern int is_repository_shallow(void); extern struct commit_list *get_shallow_commits(struct object_array *heads, int depth, int shallow_flag, int not_shallow_flag); -int in_merge_bases(struct commit *rev1, struct commit *rev2); +int in_merge_bases(struct commit *, struct commit **, int); #endif /* COMMIT_H */ diff --git a/fast-import.c b/fast-import.c index fd3b117574..404d911390 100644 --- a/fast-import.c +++ b/fast-import.c @@ -1308,7 +1308,7 @@ static int update_branch(struct branch *b) return error("Branch %s is missing commits.", b->name); } - if (!in_merge_bases(old_cmit, new_cmit)) { + if (!in_merge_bases(old_cmit, &new_cmit, 1)) { unlock_ref(lock); warn("Not updating %s" " (new tip %s does not contain %s)", @@ -256,6 +256,7 @@ static void handle_internal_command(int argc, const char **argv, char **envp) { "ls-tree", cmd_ls_tree, RUN_SETUP }, { "mailinfo", cmd_mailinfo }, { "mailsplit", cmd_mailsplit }, + { "merge-base", cmd_merge_base, RUN_SETUP }, { "merge-file", cmd_merge_file }, { "mv", cmd_mv, RUN_SETUP | NOT_BARE }, { "name-rev", cmd_name_rev, RUN_SETUP }, |