git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, phillip.wood123@gmail.com,
	Johannes.Schindelin@gmx.de, Elijah Newren <newren@gmail.com>
Subject: Re: [PATCH] rebase -i: mark commits that begin empty in todo editor
Date: Thu, 09 Apr 2020 17:50:17 -0700	[thread overview]
Message-ID: <xmqqimi8kvue.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <pull.757.git.git.1586474800276.gitgitgadget@gmail.com> (Elijah Newren via GitGitGadget's message of "Thu, 09 Apr 2020 23:26:39 +0000")

"Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Elijah Newren <newren@gmail.com>
>
> While many users who intentionally create empty commits do not want them
> thrown away by a rebase, there are third-party tools that generate empty
> commits that a user might not want.  In the past, users have used rebase
> to get rid of such commits (a side-effect of the fact that the --apply
> backend is not currently capable of keeping them).  While such users
> could fire up an interactive rebase and just remove the lines
> corresponding to empty commits, that might be difficult if the
> third-party tool generates many of them.  Simplify this task for users
> by marking such lines with a suffix of " # empty" in the todo list.
>
> Suggested-by: Sami Boukortt <sami@boukortt.com>
> Signed-off-by: Elijah Newren <newren@gmail.com>
> ---
>     rebase -i: mark commits that begin empty in todo editor
>     
>     If this isn't enough, we could talk about resurrecting --no-keep-empty
>     (and making --keep-empty just exist to countermand an earlier
>     --no-keep-empty), but perhaps this is good enough?

This does look like an unsatisfying substitute for the real thing,
but perhaps looking for " # empty" and turning them a drop is simple
enough?  Emacs types may do something like

    C-x h C-u M-| 
    sed -e '/ # empty$/s/^pick /drop /'
    <RET>

and vi folks have something similar that begins with a ':'.

But it would not beat just being able to say "--no-keep-empty" (or
"--discard-empty"), would it?

On the other hand, even if there were "--discard-empty" available,
there may still be two classes of empty ones (e.g. ones that were
created by third-party tools, the others that were deliberately
empty) that the user may need and want to sift through, and for such 
a use case, the marking this patch does would be very valuable.

So, from that point of view, this may not be enough, but a "throw
away all" option is not enough, either.  We'd want to have both to
serve such users better.

Thanks.

> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-757%2Fnewren%2Frebase-mark-empty-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-757/newren/rebase-mark-empty-v1
> Pull-Request: https://github.com/git/git/pull/757
>
>  Documentation/git-rebase.txt | 3 ++-
>  sequencer.c                  | 5 +++++
>  2 files changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
> index f7a6033607f..8ab0558aca2 100644
> --- a/Documentation/git-rebase.txt
> +++ b/Documentation/git-rebase.txt
> @@ -620,7 +620,8 @@ commits that started empty, though these are rare in practice.  It
>  also drops commits that become empty and has no option for controlling
>  this behavior.
>  
> -The merge backend keeps intentionally empty commits.  Similar to the
> +The merge backend keeps intentionally empty commits (though with -i
> +they are marked as empty in the todo list editor).  Similar to the
>  apply backend, by default the merge backend drops commits that become
>  empty unless -i/--interactive is specified (in which case it stops and
>  asks the user what to do).  The merge backend also has an
> diff --git a/sequencer.c b/sequencer.c
> index e528225e787..ce9fd27a878 100644
> --- a/sequencer.c
> +++ b/sequencer.c
> @@ -4656,6 +4656,9 @@ static int make_script_with_merges(struct pretty_print_context *pp,
>  			strbuf_addf(&buf, "%s %s %s", cmd_pick,
>  				    oid_to_hex(&commit->object.oid),
>  				    oneline.buf);
> +			if (is_empty)
> +				strbuf_addf(&buf, " %c empty",
> +					    comment_line_char);
>  
>  			FLEX_ALLOC_STR(entry, string, buf.buf);
>  			oidcpy(&entry->entry.oid, &commit->object.oid);
> @@ -4861,6 +4864,8 @@ int sequencer_make_script(struct repository *r, struct strbuf *out, int argc,
>  		strbuf_addf(out, "%s %s ", insn,
>  			    oid_to_hex(&commit->object.oid));
>  		pretty_print_commit(&pp, commit, out);
> +		if (is_empty)
> +			strbuf_addf(out, " %c empty", comment_line_char);
>  		strbuf_addch(out, '\n');
>  	}
>  	return 0;
>
> base-commit: 274b9cc25322d9ee79aa8e6d4e86f0ffe5ced925

  reply	other threads:[~2020-04-10  0:50 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-09 23:26 [PATCH] rebase -i: mark commits that begin empty in todo editor Elijah Newren via GitGitGadget
2020-04-10  0:50 ` Junio C Hamano [this message]
2020-04-10  2:06   ` Bryan Turner
2020-04-10  4:57     ` Junio C Hamano
2020-04-10 17:51 ` [PATCH v2 0/3] " Elijah Newren via GitGitGadget
2020-04-10 17:51   ` [PATCH v2 1/3] " Elijah Newren via GitGitGadget
2020-04-10 17:51   ` [PATCH v2 2/3] rebase: reinstate --no-keep-empty Elijah Newren via GitGitGadget
2020-04-10 20:37     ` Junio C Hamano
2020-04-10 21:41       ` Elijah Newren
2020-04-10 17:51   ` [PATCH v2 3/3] rebase: fix an incompatible-options error message Elijah Newren via GitGitGadget
2020-04-10 20:42   ` [PATCH v2 0/3] rebase -i: mark commits that begin empty in todo editor Junio C Hamano
2020-04-10 21:04     ` Junio C Hamano
2020-04-10 21:14       ` Junio C Hamano
2020-04-10 22:11         ` Elijah Newren
2020-04-10 21:29     ` Junio C Hamano
2020-04-10 22:13       ` Elijah Newren
2020-04-10 22:30         ` Junio C Hamano
2020-04-11  0:07           ` Elijah Newren
2020-04-11 21:14             ` Junio C Hamano
2020-04-11  2:44   ` [PATCH v3 0/4] " Elijah Newren via GitGitGadget
2020-04-11  2:44     ` [PATCH v3 1/4] " Elijah Newren via GitGitGadget
2020-04-15 20:52       ` Junio C Hamano
2020-04-11  2:44     ` [PATCH v3 2/4] rebase: reinstate --no-keep-empty Elijah Newren via GitGitGadget
2020-04-11  2:44     ` [PATCH v3 3/4] rebase: fix an incompatible-options error message Elijah Newren via GitGitGadget
2020-04-11  2:44     ` [PATCH v3 4/4] rebase --merge: optionally skip upstreamed commits Jonathan Tan via GitGitGadget
2020-04-11 18:12       ` Jonathan Tan
2020-04-14  9:11     ` [PATCH v3 0/4] rebase -i: mark commits that begin empty in todo editor Phillip Wood
  -- strict thread matches above, loose matches on Subject: below --
2020-04-10 17:25 [PATCH] " Lia Rosas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqimi8kvue.fsf@gitster.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=newren@gmail.com \
    --cc=phillip.wood123@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).