Thread (71 messages) 71 messages, 4 authors, 2016-07-06

Re: [PATCH v2 4/6] bisect--helper: `bisect_reset` shell function in C

From: Eric Sunshine <hidden>
Date: 2016-06-16 06:55:53

On Wed, Jun 15, 2016 at 10:00 AM, Pranit Bauva [off-list ref] wrote:
quoted hunk ↗ jump to hunk
Reimplement `bisect_reset` shell function in C and add a `--bisect-reset`
subcommand to `git bisect--helper` to call it from git-bisect.sh .
[...]
Signed-off-by: Pranit Bauva <redacted>
---
diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c
@@ -123,12 +127,48 @@ static int bisect_clean_state(void)
+static int bisect_reset(const char *commit)
+{
+       struct strbuf branch = STRBUF_INIT;
+
+       if (!commit) {
+               if (strbuf_read_file(&branch, git_path_bisect_start(), 0) < 1) {
+                       printf("We are not bisecting.\n");
+                       return 0;
+               }
+               strbuf_rtrim(&branch);
+
Style: unnecessary blank line
quoted hunk ↗ jump to hunk
+       } else {
+               struct object_id oid;
+               if (get_oid(commit, &oid))
+                       return error(_("'%s' is not a valid commit"), commit);
+               strbuf_addf(&branch, "%s", commit);
strbuf_addstr(&branch, commit);
quoted hunk ↗ jump to hunk
+       }
+
+       if (!file_exists(git_path_bisect_head())) {
+               struct argv_array argv = ARGV_ARRAY_INIT;
+               argv_array_pushl(&argv, "checkout", branch.buf, "--", NULL);
+               if (run_command_v_opt(argv.argv, RUN_GIT_CMD)) {
+                       error(_("Could not check out original HEAD '%s'. Try"
+                                       "'git bisect reset <commit>'."), branch.buf);
+                       strbuf_release(&branch);
+                       argv_array_clear(&argv);
+                       return -1;
+               }
+               argv_array_clear(&argv);
+       }
+
+       strbuf_release(&branch);
+       return bisect_clean_state();
+}
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help