git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH v3] Documentation: specify base point when generating MyFirstContribution patchset
@ 2021-10-18 12:41 Bagas Sanjaya
  2021-10-18 17:09 ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Bagas Sanjaya @ 2021-10-18 12:41 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Glen Choo, Bagas Sanjaya

Specifying base point (commit hash) can help reviewers and testers
interested on the patchset. Mention how to record it with `--base`
option to `format-patch`.

Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
---
 Changes since v3 [1]:
     - rewording (suggested by Glen)

 I don't apply Junio's suggestion that use `--base=auto`, because in
 most cases invocations of the option requires full hash of base object
 and AFAIK people just do `git checkout -b` without specifying the
 tracking option (`-t`).

 [1]: https://lore.kernel.org/git/xmqqo87q6whk.fsf@gitster.g/T/#t

 Documentation/MyFirstContribution.txt | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/Documentation/MyFirstContribution.txt b/Documentation/MyFirstContribution.txt
index b20bc8e914..1c4cd092ee 100644
--- a/Documentation/MyFirstContribution.txt
+++ b/Documentation/MyFirstContribution.txt
@@ -902,10 +902,19 @@ is out of scope for the context of this tutorial.
 === Preparing Initial Patchset
 
 Sending emails with Git is a two-part process; before you can prepare the emails
-themselves, you'll need to prepare the patches. Luckily, this is pretty simple:
+themselves, you'll need to prepare the patches. Luckily, this is pretty simple.
+First, we need to get hash of the commit the patchset is based on. We call
+this commit the `<base>`:
 
 ----
-$ git format-patch --cover-letter -o psuh/ master..psuh
+$ git show -s --format="%H" master
+----
+
+Now generate the patchset, passing the hash of `<base>` to the `--base`
+parameter:
+
+----
+$ git format-patch --cover-letter --base=<base> -o psuh/ master..psuh
 ----
 
 The `--cover-letter` parameter tells `format-patch` to create a cover letter
@@ -916,6 +925,10 @@ The `-o psuh/` parameter tells `format-patch` to place the patch files into a
 directory. This is useful because `git send-email` can take a directory and
 send out all the patches from there.
 
+The `--base=<base>` parameter tells `format-patch` to embed base commit
+hash to the cover letter. Reviewers and testers interested in the patchset
+can create branch based on the specifed base commit in order to apply it.
+
 `master..psuh` tells `format-patch` to generate patches for the difference
 between `master` and `psuh`. It will make one patch file per commit. After you
 run, you can go have a look at each of the patches with your favorite text
@@ -1046,7 +1059,7 @@ reviewer comments. Once the patch series is ready for submission, generate your
 patches again, but with some new flags:
 
 ----
-$ git format-patch -v2 --cover-letter -o psuh/ --range-diff master..psuh-v1 master..
+$ git format-patch -v2 --cover-letter -o psuh/ --base=<base> --range-diff master..psuh-v1 master..
 ----
 
 The `--range-diff master..psuh-v1` parameter tells `format-patch` to include a

base-commit: f443b226ca681d87a3a31e245a70e6bc2769123c
-- 
An old man doll... just what I always wanted! - Clara


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v3] Documentation: specify base point when generating MyFirstContribution patchset
  2021-10-18 12:41 [PATCH v3] Documentation: specify base point when generating MyFirstContribution patchset Bagas Sanjaya
@ 2021-10-18 17:09 ` Junio C Hamano
  2021-10-18 17:32   ` Glen Choo
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2021-10-18 17:09 UTC (permalink / raw)
  To: Bagas Sanjaya; +Cc: git, Glen Choo, Johannes Schindelin

Bagas Sanjaya <bagasdotme@gmail.com> writes:

> Specifying base point (commit hash) can help reviewers and testers
> interested on the patchset. Mention how to record it with `--base`
> option to `format-patch`.
>
> Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
> ---
>  Changes since v3 [1]:
>      - rewording (suggested by Glen)
>
>  I don't apply Junio's suggestion that use `--base=auto`, because in
>  most cases invocations of the option requires full hash of base object
>  and AFAIK people just do `git checkout -b` without specifying the
>  tracking option (`-t`).

That's actually quite sad, if it were true.

Our home, when we added "end-user/newbie friendly features" to
"checkout" (credit goes to Dscho, IIRC), was actually most new
people would not even have to say "-b" in the simplest tasks
(instead they rely on "git checkout foo" gets turned into "git
checkout -t -b foo origin/foo" by DWIMmery) and the fact that
branch.autoSetupMerge defaulting to 'true' so that they get the @{u}
and --base=auto support without even saying "-t" (as long as they do
not explicitly decline with "--no-track" from the command line, that
is).

> -$ git format-patch --cover-letter -o psuh/ master..psuh
> +$ git show -s --format="%H" master

I said this is not good in my previous response already and told you
to teach merge-base, if we were not to use the --base=auto, didn't I?

The range given to format-patch, i.e. master..psuh, would be the
correct range of commits to format, as long as you didn't rewind the
local master branch.

But that does not mean master would always be the right base, does
it?  What if you had a work totally unrelated to the contents of
this tutorial on the 'master' front?  The person on the receiving
end may not even know what object it refers to until you pushed your
'master' branch out.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v3] Documentation: specify base point when generating MyFirstContribution patchset
  2021-10-18 17:09 ` Junio C Hamano
@ 2021-10-18 17:32   ` Glen Choo
  2021-10-18 20:08     ` Re* " Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Glen Choo @ 2021-10-18 17:32 UTC (permalink / raw)
  To: Junio C Hamano, Bagas Sanjaya; +Cc: git, Johannes Schindelin


The fact that we are having this right/wrong base discussion makes me
think that including the base is out of scope for first time
contributors. 

> But that does not mean master would always be the right base, does
> it?  What if you had a work totally unrelated to the contents of
> this tutorial on the 'master' front?  The person on the receiving
> end may not even know what object it refers to until you pushed your
> 'master' branch out.

This is the crux of the problem, which is that the contributor's base is
actually their private 'master' branch, but their patches go to the
upstream 'master' branch. Does it even matter that the patches were
originally authored on a private 'master'?

If it matters, the 'master' should be part of the patchset or it can
be described using the conventions of the list ("this series is based
off a merge of ab/foo-bar and cd/baz").

If it does not matter, then providing the base is not helpful.

I suspect that we are documenting --base is that we do not have *any*
documentation of this in our mailing list workflow docs, and
MyFirstContribution is becoming a catch-all for all of our workflow
regardless of whether it is truly for first-timers or not. My own docs
changes [1] are arguably guilty of doing the same thing.

As you mentioned in the v2 thread:

  Actually it is up to contributors whether they want to include `--base` 
  or not.

This is a level of discretion that we shouldn't be leaving to first
timers (as a very recent first timer, I would not appreciate this
ambiguity). This document should be recommending good, easy-to-follow
defaults for first timers, thus I think that discretionary things belong
elsewhere.

We might consider adding _yet another_ document designed for
levelling up contributors past their first contribution, something along
the lines of "Patch submission tips and tricks". This could hold
information that we want contributors to know about, but are not
necessary for a first-timer e.g. --range-diff and --base.

[1] https://lore.kernel.org/git/20210922202218.7986-1-chooglen@google.com/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re* [PATCH v3] Documentation: specify base point when generating MyFirstContribution patchset
  2021-10-18 17:32   ` Glen Choo
@ 2021-10-18 20:08     ` Junio C Hamano
  2021-10-19  4:36       ` Eric Sunshine
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2021-10-18 20:08 UTC (permalink / raw)
  To: Glen Choo; +Cc: Bagas Sanjaya, git

Glen Choo <chooglen@google.com> writes:

>> But that does not mean master would always be the right base, does
>> it?  What if you had a work totally unrelated to the contents of
>> this tutorial on the 'master' front?  The person on the receiving
>> end may not even know what object it refers to until you pushed your
>> 'master' branch out.
>
> This is the crux of the problem, which is that the contributor's base is
> actually their private 'master' branch, but their patches go to the
> upstream 'master' branch. Does it even matter that the patches were
> originally authored on a private 'master'?

No, and that is why I suggested to update the example to take
advantage of the fact that we forked out of origin/master, not
private master, in my review of the second round.

And telling what the value of origin/master is, or letting
--base=auto to compute the merge base between origin/master and the
branch you are sending out (as origin/master may have advanced since
you forked), which is even better, helps the recipient quite a lot.

Being on the receiving end all the time, I should know ;-).

> As you mentioned in the v2 thread:
>
>   Actually it is up to contributors whether they want to include `--base` 
>   or not.
>
> This is a level of discretion that we shouldn't be leaving to first
> timers (as a very recent first timer, I would not appreciate this
> ambiguity).

Exactly.  The document is about contributing to _this_ project, and
we can and should be more explicit to say what we prefer to see.

Going back and forth is often a good way to figure out what kinks to
iron out and make progress, and in this particular case, it seems it
have already consumed enough bandwidth to make as much progress as we
can make in this approach, so let's start concluding by suggesting a
much simpler rewrite.

How about doing the following and call it done?

----- >8 --------- >8 --------- >8 --------- >8 ----
Subject: [PATCH] MyFirstContribution: teach to use "format-patch --base=auto"

Let's encourage first-time contributors to tell us what commit they
based their work with the format-patch invocation.  As the example
already forks from origin/master and by branch.autosetupmerge by
default records the upstream when the psuh branch was created, we
can use --base=auto for this.  Also, mention the readers that the
range of commits can simply be given with `@{u}` if they are on the
`psuh` branch already.

As we are getting one more option on the command line, and spending
one paragraph each to explain them, let's reformat that part of the
description as a bulletted list.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---

 * Fell out as an alternative approach during a review by Bagas
   Sanjaya https://lore.kernel.org/git/xmqqo87q6whk.fsf@gitster.g/

 Documentation/MyFirstContribution.txt | 30 +++++++++++++++++++++---------
 1 file changed, 21 insertions(+), 9 deletions(-)

diff --git c/Documentation/MyFirstContribution.txt w/Documentation/MyFirstContribution.txt
index b20bc8e914..e505a7ec87 100644
--- c/Documentation/MyFirstContribution.txt
+++ w/Documentation/MyFirstContribution.txt
@@ -905,19 +905,31 @@ Sending emails with Git is a two-part process; before you can prepare the emails
 themselves, you'll need to prepare the patches. Luckily, this is pretty simple:
 
 ----
-$ git format-patch --cover-letter -o psuh/ master..psuh
+$ git format-patch --cover-letter -o psuh/ --base=auto psuh@{u}..psuh
 ----
 
-The `--cover-letter` parameter tells `format-patch` to create a cover letter
-template for you. You will need to fill in the template before you're ready
-to send - but for now, the template will be next to your other patches.
+ . The `--cover-letter` option tells `format-patch` to create a
+   cover letter template for you. You will need to fill in the
+   template before you're ready to send - but for now, the template
+   will be next to your other patches.
 
-The `-o psuh/` parameter tells `format-patch` to place the patch files into a
-directory. This is useful because `git send-email` can take a directory and
-send out all the patches from there.
+ . The `-o psuh/` option tells `format-patch` to place the patch
+   files into a directory. This is useful because `git send-email`
+   can take a directory and send out all the patches from there.
 
-`master..psuh` tells `format-patch` to generate patches for the difference
-between `master` and `psuh`. It will make one patch file per commit. After you
+ . The `--base=auto` option tells the command to record the "base
+   commit", on which the recipient is expected to apply the patch
+   series.
+
+ . The `psuh@{u}..psuh` option tells `format-patch` to generate
+   patches for the commits you created on the `psuh` branch since it
+   forked from its upstream (which is `origin/master` if you
+   followed the example in the "Set up your workspace" section).  If
+   you are already on the `psuh` branch, you can just say `@{u}`,
+   which means "commits on the current branch since it forked from
+   its upstream", which is the same thing.
+
+The command will make one patch file per commit. After you
 run, you can go have a look at each of the patches with your favorite text
 editor and make sure everything looks alright; however, it's not recommended to
 make code fixups via the patch file. It's a better idea to make the change the

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: Re* [PATCH v3] Documentation: specify base point when generating MyFirstContribution patchset
  2021-10-18 20:08     ` Re* " Junio C Hamano
@ 2021-10-19  4:36       ` Eric Sunshine
  0 siblings, 0 replies; 5+ messages in thread
From: Eric Sunshine @ 2021-10-19  4:36 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Glen Choo, Bagas Sanjaya, Git List

On Mon, Oct 18, 2021 at 4:09 PM Junio C Hamano <gitster@pobox.com> wrote:
> Subject: [PATCH] MyFirstContribution: teach to use "format-patch --base=auto"
>
> Let's encourage first-time contributors to tell us what commit they
> based their work with the format-patch invocation.  As the example
> already forks from origin/master and by branch.autosetupmerge by

I think you meant: s/and by/and/

> default records the upstream when the psuh branch was created, we
> can use --base=auto for this.  Also, mention the readers that the

s/the readers/to readers/

> range of commits can simply be given with `@{u}` if they are on the
> `psuh` branch already.
>
> As we are getting one more option on the command line, and spending
> one paragraph each to explain them, let's reformat that part of the
> description as a bulletted list.
>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-10-19  4:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-18 12:41 [PATCH v3] Documentation: specify base point when generating MyFirstContribution patchset Bagas Sanjaya
2021-10-18 17:09 ` Junio C Hamano
2021-10-18 17:32   ` Glen Choo
2021-10-18 20:08     ` Re* " Junio C Hamano
2021-10-19  4:36       ` Eric Sunshine

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).