diff options
Diffstat (limited to 'bisect.c')
-rw-r--r-- | bisect.c | 31 |
1 files changed, 15 insertions, 16 deletions
@@ -1,4 +1,5 @@ #include "cache.h" +#include "config.h" #include "commit.h" #include "diff.h" #include "revision.h" @@ -438,10 +439,7 @@ static void read_bisect_paths(struct argv_array *array) { struct strbuf str = STRBUF_INIT; const char *filename = git_path_bisect_names(); - FILE *fp = fopen(filename, "r"); - - if (!fp) - die_errno(_("Could not open file '%s'"), filename); + FILE *fp = xfopen(filename, "r"); while (strbuf_getline_lf(&str, fp) != EOF) { strbuf_trim(&str); @@ -669,7 +667,7 @@ static int is_expected_rev(const struct object_id *oid) if (stat(filename, &st) || !S_ISREG(st.st_mode)) return 0; - fp = fopen(filename, "r"); + fp = fopen_or_warn(filename, "r"); if (!fp) return 0; @@ -682,16 +680,16 @@ static int is_expected_rev(const struct object_id *oid) return res; } -static int bisect_checkout(const unsigned char *bisect_rev, int no_checkout) +static int bisect_checkout(const struct object_id *bisect_rev, int no_checkout) { char bisect_rev_hex[GIT_MAX_HEXSZ + 1]; - memcpy(bisect_rev_hex, sha1_to_hex(bisect_rev), GIT_SHA1_HEXSZ + 1); - update_ref(NULL, "BISECT_EXPECTED_REV", bisect_rev, NULL, 0, UPDATE_REFS_DIE_ON_ERR); + memcpy(bisect_rev_hex, oid_to_hex(bisect_rev), GIT_SHA1_HEXSZ + 1); + update_ref(NULL, "BISECT_EXPECTED_REV", bisect_rev->hash, NULL, 0, UPDATE_REFS_DIE_ON_ERR); argv_checkout[2] = bisect_rev_hex; if (no_checkout) { - update_ref(NULL, "BISECT_HEAD", bisect_rev, NULL, 0, UPDATE_REFS_DIE_ON_ERR); + update_ref(NULL, "BISECT_HEAD", bisect_rev->hash, NULL, 0, UPDATE_REFS_DIE_ON_ERR); } else { int res; res = run_command_v_opt(argv_checkout, RUN_GIT_CMD); @@ -705,7 +703,7 @@ static int bisect_checkout(const unsigned char *bisect_rev, int no_checkout) static struct commit *get_commit_reference(const struct object_id *oid) { - struct commit *r = lookup_commit_reference(oid->hash); + struct commit *r = lookup_commit_reference(oid); if (!r) die(_("Not a valid commit name %s"), oid_to_hex(oid)); return r; @@ -798,7 +796,7 @@ static void check_merge_bases(int no_checkout) handle_skipped_merge_base(mb); } else { printf(_("Bisecting: a merge base must be tested\n")); - exit(bisect_checkout(mb->hash, no_checkout)); + exit(bisect_checkout(mb, no_checkout)); } } @@ -828,7 +826,8 @@ static int check_ancestors(const char *prefix) /* Clean up objects used, as they will be reused. */ clear_commit_marks_for_object_array(&pending_copy, ALL_REV_FLAGS); - free(pending_copy.objects); + + object_array_clear(&pending_copy); return res; } @@ -941,7 +940,7 @@ int bisect_next_all(const char *prefix, int no_checkout) struct rev_info revs; struct commit_list *tried; int reaches = 0, all = 0, nr, steps; - const unsigned char *bisect_rev; + struct object_id *bisect_rev; char *steps_msg; read_bisect_terms(&term_bad, &term_good); @@ -979,11 +978,11 @@ int bisect_next_all(const char *prefix, int no_checkout) exit(4); } - bisect_rev = revs.commits->item->object.oid.hash; + bisect_rev = &revs.commits->item->object.oid; - if (!hashcmp(bisect_rev, current_bad_oid->hash)) { + if (!oidcmp(bisect_rev, current_bad_oid)) { exit_if_skipped_commits(tried, current_bad_oid); - printf("%s is the first %s commit\n", sha1_to_hex(bisect_rev), + printf("%s is the first %s commit\n", oid_to_hex(bisect_rev), term_bad); show_diff_tree(prefix, revs.commits->item); /* This means the bisection process succeeded. */ |