谁获得手工编辑的补丁文件的功劳? [英] Who gets credit for a hand-edited patch file?

查看:94
本文介绍了谁获得手工编辑的补丁文件的功劳?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关编辑GitHub拉取请求的我的回答的后续问题问到是否在应用之前直接编辑修补文件这将导致对原作者作品的评价。由于它不是原来问题的一部分,因此我在此将其作为一个新问题提出。

DR

Git会将作者身份赋予补丁的创建者,而不是当前的提交者。但是,您可以覆盖此行为,



Git如何处理邮箱文件中的修补程序



git am 命令处理一系列存储在邮箱中的修补程序。在GitHub拉取请求的情况下,每个补丁文件只是一系列以 mbox格式。 Git解析邮箱中的来自行 ,以确定每次提交的GIT_AUTHOR_NAME和GIT_AUTHOR_EMAIL的值。

这意味着什么



即使您手动编辑个别差异群组,Git通常会将Bob视为作者,将您视为提交者。这通常是正确的交易;然而,尽管这当然是不好的业力,但从技术角度来看,你可以想象地将鲍勃从完全承诺。毕竟,这只是一个文本文件,您可以根据自己的需要进行调整,如果您更改邮箱中的From行,则Git将在应用每个修补程序时使用新值填充其作者字段。



这样做确实有道义和法律影响,但问题是关于归因。 Git在默认情况下可以正确地赋予作者身份,但控制最终是你的。


A follow-up question to my answer about editing GitHub pull-requests asked whether editing the patch file directly before applying it would result in taking credit for the original author's work. Since it wasn't really part of the original question, I'm asking it here as a new question.

解决方案

TL;DR

Git will attribute authorship to the creator of the patch and not the current committer. However, you can override this behavior,

How Git Handles Patches in Mailbox Files

The git am command processes a series of patches stored in a mailbox. In the case of GitHub pull-requests, each patch file is just a series of diffs stored in mbox format. Git parses the From lines in the mailbox to determine the values for GIT_AUTHOR_NAME and GIT_AUTHOR_EMAIL for each commit.

What This Means

Even if you hand-edit the individual diff hunks, Git will normally treat Bob as the author and you as the committer. This is generally The Right Thing™.

However, while it's certainly bad karma, from a technical perspective you could conceivably edit Bob out of the commit altogether. After all, it's just a text file that you can munge to suit yourself, and if you change the From lines in the mailbox then Git will use the new values to populate its author fields when it applies each patch.

There are certainly moral and legal implications to doing this, but the question was about attribution. Git attributes authorship properly by default, but control is ultimately yours.

这篇关于谁获得手工编辑的补丁文件的功劳?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆