Patch workflow with mutt and git

Patch workflow with mutt and git

1st

It's easy to grab a patch from a mailing list with mutt and get it merged on your local git tree.
The steps are quite simple:

1. Save a copy of the e-mail
mutt: shift+c (to copy), it will ask:
Copy to mailbox ('?' for list): =mailboxname
then you just need to provide the path, for example: /tmp/testing.mbox

2. Go to your git tree and merge the patch:
cd /path/to/your/git
git am /tmp/testing.mbox

3. If there is no conflict, you are good! Now you can build everything.

2nd

However, if you deal with more patches, then these steps above become annoying. Also, usually people have the e-mail on one system and the git tree one another build system. So, I tried to make life easier using a mutt's macro and a pair of scripts. 

The work flow is: You just need to tag every patch you like to apply using 't'. Then you run the new macro which in my case is 'ctrl+h' and all patches show up in the build system.

The first script is called 'procmail' which just call the real procmail passing a custom configuration:
$ cat mailtogit/procmail
/usr/bin/procmail -m ~/mailtogit/procmailrc -
----8<-----

and the custom configuration saves the e-mail in the ~/incoming directory which can be an autofs dir from your build system. Also, it saves the e-mail on a mbox with the name based on the email's subject.
$ cat mailtogit/procmailrc
SHELL=/bin/bash
VERBOSE=off
MAILDIR=$HOME/incoming/
LOGFILE=$HOME/incoming/.procmaillog

:0
`formail -xSubject: | sed -e '{ s/Subject: //; s@\[@@g; s@\]@@g; s@[()]@_@g; s@[/:]@-@g; s@"@_@g; s@^ \+@@; s@\.\.@.@g; s@ \+@_@g; s@-_@_@g; s@__@_@g; s@\.$@@; }'`.mbox

----8<-----
But mutt delivers all tagged messages at once, so instead of changing default's mutt behaviour, I wrote another script to deliver one e-mail at a time to procmail.

$ cat mailtogit/frommutt
formail -cds ~/mailtogit/procmail -
----8<-----
Now that the two scripts are ready, let's create the mutt's macro to use them. It's very simple, just copy the line below to your ~/.muttrc changing the path to the frommutt script:
macro index \Ch '<pipe-entry>/path/to/frommutt^M' "output git patches"


Testing:
Here is one example of grabbing patches from netdev mailing:
[...]
Mar 01 Ben Hutchings [ ] ├─>[PATCH net-next-2.6 2/8] sfc: Reduce size of efx_rx_buffer further by removin
Mar 01 Ben Hutchings [ ] ├─>[PATCH net-next-2.6 3/8] sfc: Read MC firmware version when requested through
Mar 01 Ben Hutchings [ ] ├─>[PATCH net-next-2.6 4/8] sfc: Do not read STAT1.FAULT in efx_mdio_check_mmd()
Mar 01 Ben Hutchings [ ] ├─>[PATCH net-next-2.6 5/8] sfc: Update copyright dates
Mar 01 Ben Hutchings [ ] ├─>[PATCH net-next-2.6 6/8] sfc: Expose TX push and TSO counters through ethtool
Mar 01 Ben Hutchings [ ] ├─>[PATCH net-next-2.6 7/8] sfc: Remove configurable FIFO thresholds for pause f
Mar 01 Ben Hutchings [ ] └─>[PATCH net-next-2.6 8/8] sfc: Bump version to 3.1
[...]

Tagging using 't', notice the '*' mark below:
[...]
* Mar 01 Ben Hutchings [ ] ├─>[PATCH net-next-2.6 2/8] sfc: Reduce size of efx_rx_buffer further by removin
* Mar 01 Ben Hutchings [ ] ├─>[PATCH net-next-2.6 3/8] sfc: Read MC firmware version when requested through
* Mar 01 Ben Hutchings [ ] ├─>[PATCH net-next-2.6 4/8] sfc: Do not read STAT1.FAULT in efx_mdio_check_mmd()
* Mar 01 Ben Hutchings [ ] ├─>[PATCH net-next-2.6 5/8] sfc: Update copyright dates
* Mar 01 Ben Hutchings [ ] ├─>[PATCH net-next-2.6 6/8] sfc: Expose TX push and TSO counters through ethtool
* Mar 01 Ben Hutchings [ ] ├─>[PATCH net-next-2.6 7/8] sfc: Remove configurable FIFO thresholds for pause f
* Mar 01 Ben Hutchings [ ] └─>[PATCH net-next-2.6 8/8] sfc: Bump version to 3.1
[...]

then after ctrl+h, this shows up in the ~/incoming directory:
$ ls ~/incoming/
PATCH_net-next-2.6_sfc_Reduce_size_of_efx_rx_buffer_by_unionising_skb_and_page.mbox
PATCH_net-next-2.6_2-8_sfc_Reduce_size_of_efx_rx_buffer_further_by_removing_data_member.mbox
PATCH_net-next-2.6_3-8_sfc_Read_MC_firmware_version_when_requested_through_ethtool.mbox
PATCH_net-next-2.6_4-8_sfc_Do_not_read_STAT1.FAULT_in_efx_mdio_check_mmd_.mbox
PATCH_net-next-2.6_5-8_sfc_Update_copyright_dates.mbox
PATCH_net-next-2.6_6-8_sfc_Expose_TX_push_and_TSO_counters_through_ethtool_statistics.mbox
PATCH_net-next-2.6_7-8_sfc_Remove_configurable_FIFO_thresholds_for_pause_frame_generation.mbox
PATCH_net-next-2.6_8-8_sfc_Bump_version_to_3.1.mbox

Now applying the patches:
$ ssh buildsystem
$ cd /storage/net-next-2.6/
$ git am /storage/incoming/*.mbox
Applying: sfc: Reduce size of efx_rx_buffer further by removing data member
Applying: sfc: Read MC firmware version when requested through ethtool
Applying: sfc: Do not read STAT1.FAULT in efx_mdio_check_mmd()
Applying: sfc: Update copyright dates
Applying: sfc: Expose TX push and TSO counters through ethtool statistics
Applying: sfc: Remove configurable FIFO thresholds for pause frame generation
Applying: sfc: Bump version to 3.1
$

That's it! Notice that usually the patch ordering is fine. But sometimes, you will need to pass the patches in the right order. In my example, the first patch didn't have the 1/8, so I had to apply it first and the rest.

You can also tag all patches and then copy using 'shift+c' to a mailbox and try to apply on git as well. But then you won't be able to change the patch order if you need to.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
提供的源码资源涵盖了安卓应用、小程序、Python应用和Java应用等多个领域,每个领域都包含了丰富的实例和项目。这些源码都是基于各自平台的最新技术和标准编写,确保了在对应环境下能够无缝运行。同时,源码中配备了详细的注释和文档,帮助用户快速理解代码结构和实现逻辑。 适用人群: 这些源码资源特别适合大学生群体。无论你是计算机相关专业的学生,还是对其他领域编程感兴趣的学生,这些资源都能为你提供宝贵的学习和实践机会。通过学习和运行这些源码,你可以掌握各平台开发的基础知识,提升编程能力和项目实战经验。 使用场景及目标: 在学习阶段,你可以利用这些源码资源进行课程实践、课外项目或毕业设计。通过分析和运行源码,你将深入了解各平台开发的技术细节和最佳实践,逐步培养起自己的项目开发和问题解决能力。此外,在求职或创业过程中,具备跨平台开发能力的大学生将更具竞争力。 其他说明: 为了确保源码资源的可运行性和易用性,特别注意了以下几点:首先,每份源码都提供了详细的运行环境和依赖说明,确保用户能够轻松搭建起开发环境;其次,源码中的注释和文档都非常完善,方便用户快速上手和理解代码;最后,我会定期更新这些源码资源,以适应各平台技术的最新发展和市场需求。
Git workflow 是指在使用 Git 版本控制时,团队协作开发时所采用的工作流程。常见的 Git workflow 包括集中式工作流、功能分支工作流、Gitflow 工作流、Forking 工作流等。 1. 集中式工作流(Centralized Workflow):团队成员直接在主分支(通常是 master 或 main)上进行开发,每个开发者都有自己的本地分支,完成开发后将本地分支合并到主分支中。 2. 功能分支工作流(Feature Branch Workflow):每个功能或任务都在独立的分支上进行开发,开发完成后合并到主分支。这种工作流程使得团队成员可以并行开发多个功能,减少代码冲突。 3. Gitflow 工作流:Gitflow 是一种在功能分支工作流基础上扩展出的工作流程,主要区别是引入了额外的分支来管理特性开发、发布和维护等不同阶段。它包括主分支(master 或 main)、开发分支(develop)、特性分支(feature)、发布分支(release)、修复分支(hotfix)等。 4. Forking 工作流:适用于开源项目,每个贡献者通过 Fork 项目得到自己的独立仓库,在自己的仓库中进行开发,然后通过 Pull Request 将修改提交给原项目。原项目的维护者可以审查和合并这些提交。 这些只是一些常见的 Git workflow,实际上还有很多其他的变种和组合。选择适合团队的工作流程取决于项目的规模、团队的协作方式和开发流程等因素。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值