Re: [RFC/PATCH v3] merge-base: teach "git merge-base" to accept more than 2 arguments
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jul 28, 2008, 05:37 UTC
- Message-ID
- <7vabg2wovf.fsf@gitster.siamese.dyndns.org>
- In-Reply-To
- <20080728065023.743930d6.chriscool@tuxfamily.org>
Christian Couder <chriscool@tuxfamily.org> writes:
Show 6 quoted lines
> Before this patch "git merge-base" accepted only 2 arguments, so > only merge bases between 2 references could be computed. > > The purpose of this patch is to make "git merge-base" accept more > than 2 arguments, so that the merge bases between the first given > reference and all the other references can be computed.
I have trouble with this wording, but I'll comment on the documentation part in a separate message.
Show 7 quoted lines
> +static struct commit *get_commit_reference(const char *arg)
> +{
> + unsigned char revkey[20];
> + if (get_sha1(arg, revkey))
> + die("Not a valid object name %s", arg);
> + return lookup_commit_reference(revkey);
> +}This returns a NULL when you feed a tree to the command, and...
Show 21 quoted lines
> int cmd_merge_base(int argc, const char **argv, const char *prefix)
> {
> + struct commit **rev;
> int show_all = 0;
> + int rev_nr = 0;
>
> git_config(git_default_config, NULL);
>
> @@ -38,15 +48,18 @@ int cmd_merge_base(int argc, const char **argv, const char *prefix)
> usage(merge_base_usage);
> argc--; argv++;
> }
> + if (argc < 3)
> usage(merge_base_usage);
> +
> + rev = xmalloc((argc - 1) * sizeof(*rev));
> +
> + do {
> + struct commit *r = get_commit_reference(argv[1]);
> + if (!r)
> + return 1;... the command silently exits with 1.