Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Simon Richter <Simon.Richter@hogyros.de>
Cc: git@vger.kernel.org
Subject: Re: "discard!" commit message for commits that should be removed while cleaning up the history
Date: Sun, 12 Jul 2026 06:28:39 -0700	[thread overview]
Message-ID: <xmqqbjcc72wo.fsf@gitster.g> (raw)
In-Reply-To: <07c9811e-41db-473e-ba0a-cdcbf8187be7@hogyros.de> (Simon Richter's message of "Sun, 12 Jul 2026 14:54:48 +0900")

Simon Richter <Simon.Richter@hogyros.de> writes:

> I often add printf statements during debugging, which obviously should 
> not end up in the final submission. My usual approach is to commit these 
> immediately, into commits with a message of "DISCARD", so that when I do 
> a final rebase pass, I can remove the debug code easily.
>
> Would it make sense to add a mechanism that autosquash understands 
> directly, and that could be checked for by a push hook or CI rule?

The sequencer machinery used by "git rebase [-i]" already knows how
to react to commits with certain subjects.  For example, a commit
with the subject "fixup! <title>" causes that commit to be moved
next to the target commit, and its "pick" insn is turned into a
"fixup" insn.  The "git commit" command itself helps you prepare
such a specially formatted commit title with options like "--fixup".

So, it is not totally out of the question to add support for
noticing a subject that begins with "drop!" (rather than your proposed
"DISCARD", purely so that it matches the existing "fixup!" convention
that instructs the sequencer to use the "fixup" insn).  This would
automatically turn the "pick" insn into a "drop" insn when "git
rebase -i" works on a history segment that includes such a commit.

On the "git commit" side, we likely do not want to add any support
similar to the "--fixup" option (for example, "--fixup=drop"), as
you can run "git commit -m 'drop!'" just as easily.

Having said all that, you can use a custom GIT_SEQUENCE_EDITOR that
notices commits you titled "DISCARD" and rewrites the "pick" insn for
these commits into a "drop" insn in the todo list, without making
any changes to Git.

      reply	other threads:[~2026-07-12 13:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-12  5:54 "discard!" commit message for commits that should be removed while cleaning up the history Simon Richter
2026-07-12 13:28 ` Junio C Hamano [this message]

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

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

  git send-email \
    --in-reply-to=xmqqbjcc72wo.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=Simon.Richter@hogyros.de \
    --cc=git@vger.kernel.org \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox