git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Sergey Organov <sorganov@gmail.com>
Cc: Chris Torek <chris.torek@gmail.com>,
	Hongyi Zhao <hongyi.zhao@gmail.com>,
	Phillip Susi <phill@thesusis.net>, Git List <git@vger.kernel.org>
Subject: Re: git revert with partial commit.
Date: Tue, 04 Apr 2023 11:20:28 -0700	[thread overview]
Message-ID: <xmqq4jpv1pcj.fsf@gitster.g> (raw)
In-Reply-To: <87lej7zhpt.fsf@osv.gnss.ru> (Sergey Organov's message of "Tue, 04 Apr 2023 20:21:18 +0300")

Sergey Organov <sorganov@gmail.com> writes:

>> This kind of operation produces a new commit, so there's no such
>> thing as a partial revert or partial cherry-pick, at least in
>> terms of "things Git can do by itself".  But we, as humans writing
>> programs, wish to *achieve* such things.
>
> So, why Git can't help us achieving it by supporting paths limiting in
> (all) merge operations? There seems to be no absolute obstacles, just a
> luck of support.

I think there is no fundamental reason to forbid an optional
pathspec to "cherry-pick" and "revert", given that a commit that
results from either "git cherry-pick" or "git revert" is called a
"cherry-pick" or a "revert" merely by convention and there is no
tool-level support to treat them any specially at merge or rebase
time [*1*].  It would make it harder to design tool-level support
for full cherry-picks or reverts, but that is a problem for future
generation, not ours ;-)  Allowing pathspec to "merge" and recording
the result as a merge of two (or more) parents is an absolute no-no
but that is not what we are discussing.

But in practice, the part that takes the most brain work in a revert
or cherry-pick that is not an outright "the effect of that commit as
its entirety is now gone" is not the mechanical (partial)
reapplication, but coming up with a good split of the original (or
the reverse of the original) and a good explanation.  Especially
given that it would be just the matter of running these commands
with "--no-commit", selectively resetting the paths that the user
does not want to touch, before spending some quality time describing
what the user did in the resulting commit, it is very understandable
if teaching pathspec to these commands has been outside anybody's
priority list so far.

But I do not think Chris meant to say "you should not expect such a
feature"; what we heard was a reasonable explanation of how the
current world works, and I do not see a reason to react strongly to
such a statement as if you were unreasonably forbidden from doing
something sensible.


[Footnote]

*1* If there were, it would totally be a different story.  For
example, merging a branch that has a revert of a commit X to a
branch that has the original commit X _may_ want to avoid replaying
the revert from the side branch in the result depending on the
circumstances, but it will be even less clear what to do if such a
"special cased" revert were a partial one).

  reply	other threads:[~2023-04-04 18:20 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-02  9:17 git revert with partial commit Hongyi Zhao
2023-04-02 14:16 ` Torsten Bögershausen
2023-04-03 17:07   ` Junio C Hamano
2023-04-04  0:28   ` Hongyi Zhao
2023-04-03 18:29 ` Phillip Susi
2023-04-04  0:20   ` Hongyi Zhao
2023-04-04  0:37     ` Hongyi Zhao
2023-04-04 15:50       ` Hongyi Zhao
2023-04-04 16:19         ` Chris Torek
2023-04-04 17:21           ` Sergey Organov
2023-04-04 18:20             ` Junio C Hamano [this message]
2023-04-04 19:40               ` Sergey Organov
2023-04-04 19:48                 ` Junio C Hamano
2023-04-04 21:14                 ` Felipe Contreras
2023-04-05  6:39                   ` Sergey Organov
2023-04-07  0:24                     ` Felipe Contreras
2023-04-07 17:20                       ` Sergey Organov
2023-04-06 15:48     ` Phillip Susi

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=xmqq4jpv1pcj.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=chris.torek@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=hongyi.zhao@gmail.com \
    --cc=phill@thesusis.net \
    --cc=sorganov@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).