Subject: Re: base-commit when prerequisite-patch-id is specified

From: Junio C Hamano <[email-masked]>
Date: Thu, 28 Mar 2024 17:06:09 -0700

Konstantin Ryabitsev <[email-masked]> writes:

> Hello:
>
> I'm working on automatically supporting dependencies with b4, and I'm curious
> if "base-commit" should be used to indicate where to start applying
> dependencies, or if that's purely for the patch series itself.
>
> E.g.:
>
>     base-commit: [commit-ish]
>     prerequisite-patch-id: abcd...1234
>     prerequisite-patch-id: cdef...3456
>
> In this situation, does base-commit mean:
> 1. where to apply abcd...1234
> 2. the sha we should find when we apply both prerequisite patches

"git format-patch --help" has this to say:

  Imagine that on top of the public commit P, you applied well-known patches X, Y
  and Z from somebody else, and then built your three-patch series A, B, C, the
  history would be like:

      ---P---X---Y---Z---A---B---C

  With git format-patch --base=P -3 C (or variants thereof, e.g. with --cover-letter
  or using Z..C instead of -3 C to specify the range), the base tree information
  block is shown at the end of the first message the command outputs (either the
  first patch, or the cover letter), like this:

      base-commit: P
      prerequisite-patch-id: X
      prerequisite-patch-id: Y
      prerequisite-patch-id: Z

So, it appears to me that the only way to read your example is that
there is P, on top of which abcd...1234 and cdef...3456 should be
applied, before our series is ready to be applied on top?

There is no way to express the desired topology on top of P that X,
Y and Z are built, and I think it is acceptable to assume the author
of such a patch series, who took it out of a history other than the
above depicted single strand of pearls, e.g. a mergy one in the
example given in the "git format-patch --help" output:

  For non-linear topology, such as

      ---P---X---A---M---C
          \         /
           Y---Z---B

  You can also use git format-patch --base=P -3 C to generate patches for A, B and
  C, and the identifiers for P, X, Y, Z are appended at the end of the first
  message.

is responsible to ensure that linear application of X Y Z A B C on
top of P should give the same result as C the author had taken the
patches out of.  The recipient, or b4 tool, cannot do anything with
the existing information.