Re: [PATCH 2/4] stash: convert branch to builtin

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Mar 24, 2018 at 1:37 PM, Joel Teichroeb <joel@xxxxxxxxxxxxx> wrote:
> diff --git a/builtin/stash--helper.c b/builtin/stash--helper.c
> @@ -307,6 +313,42 @@ static int apply_stash(int argc, const char **argv, const char *prefix)
> +static int branch_stash(int argc, const char **argv, const char *prefix)
> +{
> +       const char *commit = NULL, *branch = NULL;
> +
> +       argc = parse_options(argc, argv, prefix, options,
> +                       git_stash_helper_branch_usage, 0);
> +
> +       if (argc != 0) {
> +               branch = argv[0];
> +               if (argc == 2)
> +                       commit = argv[1];
> +       }

This seems fragile. What happens if there are three args?

> +       if (get_stash_info(&info, commit))
> +               return -1;
> +
> +       argv_array_pushl(&args, "checkout", "-b", NULL);
> +       argv_array_push(&args, branch);
> +       argv_array_push(&args, sha1_to_hex(info.b_commit.hash));
> +       ret = cmd_checkout(args.argc, args.argv, prefix);
> +       if (ret)
> +               return -1;
> +
> +       ret = do_apply_stash(prefix, &info, 1);
> +       if (!ret && info.is_stash_ref)
> +               ret = do_drop_stash(prefix, &info);
> +
> +       return ret;
> +}



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux