LoginSignup
3
2

More than 3 years have passed since last update.

ソースコードのパッチを送るためのGmail (G Suite)・Thunderbirdの設定

Last updated at Posted at 2020-03-14

English

GitHubでホストしていない古いプロジェクト(GNUとかGNUとか)を触っていると、コミットする手段がメールなことがしばしばあります。オープンソース活動にGmailをお使いの方は多いと思いますが、Gmailのwebメーラーでパッチを送ると、勝手にタブをスペースに変換するわ削除するわでまともに使えません。

patch collapsed via web Gmail

$ git apply < patch.txt
error: patch failed: gdb/ChangeLog:1
error: gdb/ChangeLog: patch does not apply
error: patch failed: gdb/darwin-nat.c:1985
error: gdb/darwin-nat.c: patch does not apply

そこでwebメーラーではなくメールクライアント (MUA; Mail User Agent) からGmailを使ってやる必要があります。

メーラーの選定

TL;DR: Muttに慣れている人はMuttで、それ以外の人にはThunderbirdをオススメします。

gitのパッチを送る場合に限ってはgit-send-email(1)を使うという手もあります。ググればやり方が沢山出てきます。Linux kernelにパッチを送る際の推奨手段でもあります。

この記事では cvs diffsvn diff、その他 unified diff (diff -u) 形式のパッチを送ることを想定します。

まずLinux kernelドキュメントgit-format-patch(1)に載っている全メーラーを調べてみることにしました。選定基準は:

  • オープンソース
  • 継続して開発されている。Gmailの仕様は頻繁に変更される(例えばパスワード認証はデフォルトで無効になったり)のですぐに対応できるソフトウェアが望ましいです。
  • パッチを送っている人が多い。エラーをググればすぐ出ると期待されるので。

ググった結果:

Search keywords GUI or TUI # results as of 2020/03/13
"git am" Mutt TUI 11,800
"git am" Thunderbird GUI 11,600
"git am" Alpine TUI 5,300
"git am" KMail GUI 1,650
"git am" Claws Mail GUI 2,270
"git am" TkRat GUI 252
"git am" Sylpheed GUI 262
"git am" Evolution (run only on Linux) GUI 11,900
"git am" outlook (non open source) GUI 6,690
"git am" apple mail (non open source) GUI 7,850
"git am" "apple mail" (non open source) GUI 101

まずMuttを試してみましたが、authentication failed みたいなエラーが出て、ググって解決しなかったのでやめました。Muttのスペシャリストになるのに時間を費やしたくない。

次にThunderbirdを試した結果サイコーでした。多くの人がパッチを送っているようだし、ググれば全部出る。

GmailのIMAPを有効にする

設定で Enable IMAP します。

enable IMAP in Gmail's Setting

Thunderbirdでアカウント追加

FileNewExisting Mail Account...

add Gmail's account on Thunderbird (1)

任意の名前とGmail (foo@gmail.com) か G Suite (foo@foo-organization.com) のメールアドレスを入力して Continue。今は Password は入力しなくてOKです。

add Gmail's account on Thunderbird (2)

Manual config をクリック。

add Gmail's account on Thunderbird (3)

AuthenticationOAuth2 になっていることを確認して Done

add Gmail's account on Thunderbird (4 Google OAuth)
add Gmail's account on Thunderbird (5 Google OAuth)

Google (G Suite) のパスワードを入力。

add Gmail's account on Thunderbird (6)

残念ながらエラーになりました(そのうち直ると思います)。

  • User name or password invalid
  • Configuration could not be verified ― is the user name or password wrong?

とりあえずパスワード認証することにします。

パスワード認証

Thunderbird の設定画面は開いたままにしておいて下さい

パスワード認証を行うためには less secure app access を有効にする必要があります。

G Suiteをお使いの場合(you@gmail.com でなく you@your-company.com でGmailをお使いの場合)G Suiteの管理者がこちらの設定を行う必要があります。

(G Suite) Allow users to manage their access to less secure apps

Less secure app access
settings
Allow less secure apps をONにします。アカウントは右上のアイコンで切り替えられます。

turn on: Allow less secure apps

Thunderbirdに戻り Normal password を選んで Done

add Gmail's account on Thunderbird (7)

これでメールが受信できるはずです 🎉

format=flowed を無効にする

しかしまだThunderbirdがパッチを壊しちゃいます。git-format-patch(1)に従い、

  • EditAccount SettingsComposition & AddressingCompose messages in HTML format のチェックを外す
  • EditPreferencesAdvancedConfig Editor...
    • mail.wrap_long_lines: false
    • mailnews.wraplength: 0
    • mailnews.send_plaintext_flowed: false

これでメールのヘッダーに format=flowed が付加されなくなります。

To: bar@gmail.com
From: Wataru Ashihara <foo@gmail.com>
Subject: test
Message-ID: <***@gmail.com>
Date: Mon, 9 Mar 2020 19:48:53 +0900
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101
 Thunderbird/60.9.0
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
                                       ^^^^^^^^^^^^^^^ this removed!
Content-Language: en-US
Content-Transfer-Encoding: 7bit

body

パッチを壊さずに送信できるようになりました。

クリエイティブ・コモンズ・ライセンス
この 作品 は クリエイティブ・コモンズ 表示 4.0 国際 ライセンスの下に提供されています。

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2