git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] Documentation: specify base point when generating MyFirstContribution patchset

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 15, 2021, 17:14 UTC
Message-ID
<xmqqo87q6whk.fsf@gitster.g>
In-Reply-To
<20211015122515.47535-1-bagasdotme@gmail.com>
Bagas Sanjaya <bagasdotme@gmail.com> writes:
Show 9 quoted lines
> +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.
Show 7 quoted lines
> +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.

Previous: Bagas Sanjaya
Message 4 of 4 in “Documentation: specify base point when generating MyFirstContribution patchset”
  1. Documentation: specify base point when generating MyFirstContribution patchsetBagas Sanjaya, Oct 15, 2021
  2. Glen ChooOct 15, 2021
  3. Bagas SanjayaOct 16, 2021
  4. Junio C HamanoOct 15, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.