Re: [PATCHv6 3/6] commit: --fixup option for use with rebase --autosquash

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

 



"Pat Notz" <patnotz@xxxxxxxxx> writes:

> diff --git a/builtin/commit.c b/builtin/commit.c
> index 5fa24f5..c82108c 100644
> --- a/builtin/commit.c
> +++ b/builtin/commit.c
> @@ -586,6 +588,15 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
>  		strbuf_add(&sb, buffer + 2, strlen(buffer + 2));
>  		hook_arg1 = "commit";
>  		hook_arg2 = use_message;
> +	} else if (fixup_message) {
> +		struct pretty_print_context ctx = {0};
> +		struct commit *commit;
> +		const char *out_enc;
> +		commit = lookup_commit_reference_by_name(fixup_message);
> +		out_enc = get_commit_output_encoding();
> +		format_commit_message(commit, "fixup! %s\n\n",
> +				      &sb, &ctx, out_enc);

As your lookup_commit_reference_by_name() expects the caller to check for
errors, you should do something similar to what you do in your
"use_message" codepath in your [PATCH 1/6].

	if (use_message) {
		const char *out_enc;
		struct commit *commit;
 
		commit = lookup_commit_reference_by_name(use_message);
		if (!commit)
			die("could not lookup commit %s", use_message);
		out_enc = get_commit_output_encoding();
		use_message_buffer = logmsg_reencode(commit, out_enc);
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[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]