git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Bagas Sanjaya <bagasdotme@gmail.com>
Cc: git@vger.kernel.org, Glen Choo <chooglen@google.com>,
	Carlo Arenas <carenas@gmail.com>
Subject: Re: [PATCH v2] Documentation: specify base point when generating MyFirstContribution patchset
Date: Fri, 15 Oct 2021 10:14:47 -0700	[thread overview]
Message-ID: <xmqqo87q6whk.fsf@gitster.g> (raw)
In-Reply-To: <20211015122515.47535-1-bagasdotme@gmail.com> (Bagas Sanjaya's message of "Fri, 15 Oct 2021 19:25:16 +0700")

Bagas Sanjaya <bagasdotme@gmail.com> writes:

> +It would help those who review and test your patches to specify on what
> +commit the patches should be applied to. To do so, use the `--base` option
> +when running `format-patch`. The option expects hash of the commit the
> +patchset is based on. Since we base `psuh` on top of `master`, the base
> +commit hash can be determined by: 
> +
> +----
> +$ git show -s --format="%H" master
> +----

That's a littie bit wasteful.

If we need to teach more stuff (like --format="%H"), one thing that
more directly help this exact use case is to teach

    git merge-base master psuh

here.  But read on.

> +The output of command above can be passed to `--base` option. Replace `<base>`
> +with your own hash:
> +
> +----
> +$ git format-patch --cover-letter --base=<base> -o psuh/ master..psuh
> +----
> +

If we set up the psuh branch correctly, we can use the `--base=auto`
option, which would reduce the number of things readers need to
learn by one.  Then the whole example in this patch can be reduced
to (after dropping "Since we base `psuh` on top of `master`..." at
the end of the previous paragraph):

    patchset is based on.  As we forked `psuh` to build on
    `origin/master`, we can use the `--base=auto` option when
    running the `format-patch` command, like so:

    ----
    $ git format-patch --cover-letter --base=auto -o psuh/ origin/master..psuh
    ----

That is one fewer step the user needs to execute.

This needs one line change in the earlier part of the document (not
touched by the patch under discussion here). 

In the [[setup-workspace]] section, we create the psuh by branching
out of the origin/master (not 'master', so the references to
`master` in the patch under discussion need to be updated, which I
did in the above paragraph already), like so:

    ----
    $ git checkout -b psuh origin/master
    ----

All we need to do is to pass the `-t` option there, i.e.

    ----
    $ git checkout -t -b psuh origin/master
    ----
    
to make the --base=auto work, I think.

Thanks.


[Addendum]

Also, if the tutorial text naturally guides the user to be "on" the
`psuh` branch when the patches are taken from it, we could even
shorten the command to

    ----
    $ git format-patch --cover-letter --base=auto -o psuh/ @{u}..
    ----

That extra shortening would need a bit more work in the earlier part
of [[format-patch]] section around the part that says "Luckily, this
is pretty simple".  Basically, we need to invent a plausible story
for the user to have done "git checkout psuh" earlier, so that it is
clear to the readers that the `psuh` branch is the current branch.

So it probably is a good idea to leave it outside the scope of this
topic.

      parent reply	other threads:[~2021-10-15 17:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-15 12:25 [PATCH v2] Documentation: specify base point when generating MyFirstContribution patchset Bagas Sanjaya
2021-10-15 17:06 ` Glen Choo
2021-10-16  5:16   ` Bagas Sanjaya
2021-10-15 17:14 ` 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

  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=xmqqo87q6whk.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=bagasdotme@gmail.com \
    --cc=carenas@gmail.com \
    --cc=chooglen@google.com \
    --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.
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).