Re: [PATCH v2 4/6] bisect--helper: `bisect_reset` shell function in C
- From
Pranit Bauva <pranit.bauva@gmail.com>
- Date
- Jun 16, 2016, 19:06 UTC
- Message-ID
- <CAFZEwPPuoP6s2BZgKfvT5fZ_TGyqO16fCmJkGpbxDt8YR2gxVQ@mail.gmail.com>
- In-Reply-To
- <CAPig+cTf72M2iaZr3bZj+0V_0VHXJahpusY6zwT_B5uJx0BP1g@mail.gmail.com>
Hey Eric,
On Thu, Jun 16, 2016 at 2:35 AM, Eric Sunshine <sunshine@sunshineco.com> wrote:
Show 21 quoted lines
> On Wed, Jun 15, 2016 at 10:00 AM, Pranit Bauva <pranit.bauva@gmail.com> wrote:
>> 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 <pranit.bauva@gmail.com>
>> ---
>> 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 lineWill fix.
Show 7 quoted lines
>> + } 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);Seems better. :)
Show 18 quoted lines
>> + }
>> +
>> + 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();
>> +}Regards, Pranit Bauva