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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Bagas Sanjaya <bagasdotme@xxxxxxxxx> 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.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux