Re: [PATCH 5/8] revert: allow cherry-picking more than one commit
- From
Jonathan Nieder <jrnieder@gmail.com>
- Date
- Jun 1, 2010, 09:03 UTC
- Message-ID
- <20100601090317.GB32320@progeny.tock>
- In-Reply-To
- <20100531194240.28729.9164.chriscool@tuxfamily.org>
Christian Couder wrote:
Show 28 quoted lines
> --- a/builtin/revert.c
> +++ b/builtin/revert.c
> @@ -520,8 +516,33 @@ static int do_pick_commit()
> return 0;
> }
>
> +static void prepare_revs(struct rev_info *revs)
> +{
> + int argc = 0;
> + int i;
> + const char **argv = xmalloc((commit_argc + 4) * sizeof(*argv));
> +
> + argv[argc++] = NULL;
> + argv[argc++] = "--no-walk";
> + if (action != REVERT)
> + argv[argc++] = "--reverse";
> + for (i = 0; i < commit_argc; i++)
> + argv[argc++] = commit_argv[i];
> + argv[argc++] = NULL;
> +
> + init_revisions(revs, NULL);
> + setup_revisions(argc - 1, argv, revs, NULL);
> + if (prepare_revision_walk(revs))
> + die("revision walk setup failed");
> +
> + if (!revs->commits)
> + die("empty commit set passed");
> +}Tiny one-time leak. Maybe avoiding it will make debugging tools happier.
The rest of the patch of course looks good. Thanks.
diff --git a/builtin/revert.c b/builtin/revert.c index b90955f..a73f66b 100644 --- a/builtin/revert.c +++ b/builtin/revert.c @@ -532,6 +532,7 @@ static void prepare_revs(struct rev_info *revs) init_revisions(revs, NULL); setup_revisions(argc - 1, argv, revs, NULL); + free(argv); if (prepare_revision_walk(revs)) die("revision walk setup failed");