Re: [PATCH 2/3] rebase -i --keep-empty: don't prune empty commits

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

 



Hi Phillip,

On Tue, 20 Mar 2018, Phillip Wood wrote:

> diff --git a/sequencer.c b/sequencer.c
> index 4d3f60594c..96ff812c8d 100644
> --- a/sequencer.c
> +++ b/sequencer.c
> @@ -2470,7 +2470,7 @@ int sequencer_make_script(FILE *out, int argc, const char **argv,
>  	init_revisions(&revs, NULL);
>  	revs.verbose_header = 1;
>  	revs.max_parents = 1;
> -	revs.cherry_pick = 1;
> +	revs.cherry_mark = 1;

This will conflict with my --recreate-merges patch series, but in a good
way.

> @@ -2495,14 +2495,18 @@ int sequencer_make_script(FILE *out, int argc, const char **argv,
>  		return error(_("make_script: error preparing revisions"));
>  
>  	while ((commit = get_revision(&revs))) {
> +		int is_empty  = is_original_commit_empty(commit);
> +
>  		strbuf_reset(&buf);
> -		if (!keep_empty && is_original_commit_empty(commit))
> +		if (!keep_empty && is_empty)
>  			strbuf_addf(&buf, "%c ", comment_line_char);
> -		strbuf_addf(&buf, "%s %s ", insn,
> -			    oid_to_hex(&commit->object.oid));
> -		pretty_print_commit(&pp, commit, &buf);
> -		strbuf_addch(&buf, '\n');
> -		fputs(buf.buf, out);
> +		if (is_empty || !(commit->object.flags & PATCHSAME)) {

May I suggest inverting the logic here, to make the code more obvious and
also to avoid indenting the block even further?

		if (!is_empty && (commit->object.flags & PATCHSAME))
			continue;

> +			strbuf_addf(&buf, "%s %s ", insn,
> +				    oid_to_hex(&commit->object.oid));
> +			pretty_print_commit(&pp, commit, &buf);
> +			strbuf_addch(&buf, '\n');
> +			fputs(buf.buf, out);
> +		}
>  	}
>  	strbuf_release(&buf);
>  	return 0;

Thanks,
Dscho



[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