git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Andy Zhang <zhgdrx@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: why "git rebase" searching the duplicate patches in <upstream branch> rather than in <new base branch>?
Date: Sun, 1 Aug 2021 16:59:27 +0800	[thread overview]
Message-ID: <CAJcwCMPaX4qTBfxG6UwswFXCAkGE1meX8GOFNQueKXmfHPMJ2Q@mail.gmail.com> (raw)
In-Reply-To: <xmqqmtqij63t.fsf@gitster.g>

On Tue, Jul 20, 2021 at 6:23 AM Junio C Hamano <gitster@pobox.com> wrote:
>
> Andy Zhang <zhgdrx@gmail.com> writes:
>
> > why "git rebase" searching the duplicate patches in <upstream
> > branch> rather than in <new base branch>?
> >
> > hi, all:
> >
> >  I am reading the help of "git rebase", it says:
> >     "If the upstream branch already contains a change you have made
> > (e.g., because you mailed a patch which was applied upstream), then
> > that commit will be skipped. "
> >
> >  But, because we are applying commits to <new base branch> rather than
> > to <upstream branch>, I really don't understand why we are searching
> > the duplicate patches in <upstream branch> rather than in <new base
> > branch>?
>
> It is either a design bug or a documentation bug, or both ;-)
>
It should NOT be a documentation bug, because, in my experiment, I
observe that, "git"'s behavior is exactly the same as documentation.
So, it should be "work as design".

> I do think it makes sense to skip commits from the branch we are
> rebasing that have equivalent commits in the upstream, as it is
> expected that upstream might have already applied/cherry-picked some
> of the changes you are rebasing, and you do not want to use the same
> change twice.
>
> When we are transplanting a series of commits from an old base to
> totally unrelated base using the --onto option, e.g. when replaying
> the contents of 'topic' relative to 'next' down to 'master' in your
> topology, however,
>
> > Old tree is:
> >
> > o---o---o---o---o  master
> >     \
> >      o---o---o---o---o  next
> >                       \
> >                        o---o---o  topic
>
> it is not necessarily obvious where to stop digging back at.  In the
> above picture where 'master' and 'next' have ancestry relationship,
> we could try to see if the three commits on 'topic' branch being
> replayed match any of the commits in next..master range, but when
> using the --onto option, there does not have to be any relationship
> between the <upstream> and <new base> (they do not have to share a
> root commit).  So from that point of view, it probably makes sense
> to default to --no-reapply-cherry-picks when --onto is used, while
> defaulting --reapply-cherry-picks when --onto is not used.
>
>

      parent reply	other threads:[~2021-08-01  8:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAJcwCMPU9EhRkqeei_LnYyTJRZUQgHCvomrBbW0Qn+Jp1yhQfQ@mail.gmail.com>
2021-07-19 17:45 ` why "git rebase" searching the duplicate patches in <upstream branch> rather than in <new base branch>? Andy Zhang
2021-07-19 18:17   ` Felipe Contreras
2021-07-19 22:23   ` Junio C Hamano
2021-07-20  9:04     ` Sergey Organov
2021-07-20 15:36       ` Junio C Hamano
2021-07-20 16:44         ` Sergey Organov
2021-08-01  8:59     ` Andy Zhang [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

  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=CAJcwCMPaX4qTBfxG6UwswFXCAkGE1meX8GOFNQueKXmfHPMJ2Q@mail.gmail.com \
    --to=zhgdrx@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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).