How to use git send mail to send patches to linux upstream - liuyq/android-issues GitHub Wiki

  1. some links to read first

  2. setup git send-email refer to the link here:

    • install send-email

      $ sudo apt update
      $ sudo apt install git-email
      $ git send-email --help
    • set up ~/.gitconfig

      [sendemail]
          smtpServer = smtp.gmail.com
          smtpServerPort = 587
          smtpEncryption = tls
          smtpUser = [email protected]
          # (Optional: we'll leave this commented out and use a different way)
          # smtpPass = PASSWORD
      [credential]
          helper = store
      
    • generate the application specific password

      https://security.google.com/settings/security/apppasswords

    • run git send-email for check

      # run checkpatch.pl to check the commit message to avoid any errors/warnings
      $ ./scripts/checkpatch.pl 0001-thermal-drivers-hisi-Drop-second-sensor-hi3660.patch 
      total: 0 errors, 0 warnings, 10 lines checked
      
      0001-thermal-drivers-hisi-Drop-second-sensor-hi3660.patch has no obvious style problems and is ready for submission.
      $
      
      # run get_maintainer.pl to get the maintainer list
      $ ./scripts/get_maintainer.pl 0001-thermal-drivers-hisi-Drop-second-sensor-hi3660.patch 
      "Rafael J. Wysocki" <[email protected]> (supporter:THERMAL)
      Daniel Lezcano <[email protected]> (supporter:THERMAL,blamed_fixes:1/1=100%)
      Amit Kucheria <[email protected]> (reviewer:THERMAL)
      Zhang Rui <[email protected]> (reviewer:THERMAL)
      Eduardo Valentin <[email protected]> (blamed_fixes:1/1=100%)
      [email protected] (open list:THERMAL)
      [email protected] (open list)
      $
      
      # send out the patches to the mailing list for review
      $ git send-email \
                 --suppress-cc=all \   # suppress all auto cc values, which found from the patch automatically
                 [email protected] \ # in format of <address>,…​  check [MAINTAINERS](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/MAINTAINERS) to see whom should be sent to
                 [email protected] \ # related person
                 tested-by/ \ # patches directory or a patchset file
                 --in-reply-to=CAMSo37WW9veYH6=tHqUR2pa_7YX1UuzHqLBHit60P2QyzQmCEw@mail.gmail.com \ # not sure if it's correct
                 --thread \ 
                 --no-chain-reply-to   

      description about the --in-reply-to option, not sure how to find the message-id yet

      --in-reply-to=<identifier>
         Make the first mail (or all the mails with --no-thread) appear as a reply to the given Message-Id,
         which avoids breaking threads to provide a new patch series. The second and subsequent
         emails will be sent as replies according to the --[no-]chain-reply-to setting.
      
         So for example when --thread and --no-chain-reply-to are specified, the second and subsequent patches
         will be replies to the first one like in the illustration below where [PATCH v2 0/3]
         is in reply to [PATCH 0/2]:
      
             [PATCH 0/2] Here is what I did...
               [PATCH 1/2] Clean up and tests
               [PATCH 2/2] Implementation
               [PATCH v2 0/3] Here is a reroll
                 [PATCH v2 1/3] Clean up
                 [PATCH v2 2/3] New tests
                 [PATCH v2 3/3] Implementation
      
         Only necessary if --compose is also set. If --compose is not set, this will be prompted for.
      
  3. use git format-patch to generate the patches

    $ git format-patch --cover-letter -o outgoing/
    $ edit outgoing/0000-*
    $ git send-email outgoing/*

    more examples on git send-email

  4. tip & tricks

    • make sure to do the cherry-picks on the upstream stable kernel

      instead of the vendor kernel, as the vendor kernel might have some changes not been upstreamed yet

    • how to send the patches in one thread & how to send the patches as reply to one existing thread?

      "--thread" and "--no-chain-reply-to" are supposed to do that, but need to check

⚠️ **GitHub.com Fallback** ⚠️