MCPcopy Create free account
hub / github.com/git/git / bisect_write

Function bisect_write

builtin/bisect.c:291–337  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

289}
290
291static int bisect_write(const char *state, const char *rev,
292 const struct bisect_terms *terms, int nolog)
293{
294 struct strbuf tag = STRBUF_INIT;
295 struct object_id oid;
296 struct commit *commit;
297 FILE *fp = NULL;
298 int res = 0;
299
300 if (!strcmp(state, terms->term_bad)) {
301 strbuf_addf(&tag, "refs/bisect/%s", state);
302 } else if (one_of(state, terms->term_good, "skip", NULL)) {
303 strbuf_addf(&tag, "refs/bisect/%s-%s", state, rev);
304 } else {
305 res = error(_("Bad bisect_write argument: %s"), state);
306 goto finish;
307 }
308
309 if (repo_get_oid(the_repository, rev, &oid)) {
310 res = error(_("couldn't get the oid of the rev '%s'"), rev);
311 goto finish;
312 }
313
314 if (refs_update_ref(get_main_ref_store(the_repository), NULL, tag.buf, &oid, NULL, 0,
315 UPDATE_REFS_MSG_ON_ERR)) {
316 res = -1;
317 goto finish;
318 }
319
320 fp = fopen(git_path_bisect_log(), "a");
321 if (!fp) {
322 res = error_errno(_("couldn't open the file '%s'"), git_path_bisect_log());
323 goto finish;
324 }
325
326 commit = lookup_commit_reference(the_repository, &oid);
327 log_commit(fp, "%s", state, commit);
328
329 if (!nolog)
330 fprintf(fp, "git bisect %s %s\n", state, rev);
331
332finish:
333 if (fp)
334 fclose(fp);
335 strbuf_release(&tag);
336 return res;
337}
338
339static int check_and_set_terms(struct bisect_terms *terms, const char *cmd)
340{

Callers 3

bisect_startFunction · 0.85
bisect_stateFunction · 0.85
process_replay_lineFunction · 0.85

Calls 10

strbuf_addfFunction · 0.85
one_ofFunction · 0.85
errorFunction · 0.85
repo_get_oidFunction · 0.85
refs_update_refFunction · 0.85
get_main_ref_storeFunction · 0.85
error_errnoFunction · 0.85
lookup_commit_referenceFunction · 0.85
log_commitFunction · 0.85
strbuf_releaseFunction · 0.85

Tested by

no test coverage detected