gpt4 book ai didi

comments - 如何在补丁/差异文件中写入注释?

转载 作者:行者123 更新时间:2023-12-02 13:20:29 25 4
gpt4 key购买 nike

我想查看一位同事的补丁。我们无法使用审核工具。所以我想评论一下他制作的补丁文件。是否可以将内联注释写入(svn)补丁文件?

我在svn红书中找不到任何关于它的信息。我什至无法找到补丁文件语法来自己弄清楚。

最佳答案

diff 格式就是 unified diff format 。如果您愿意,可以在范围信息后添加一些文本。考虑使用命令 svn diff -c 1544711 https://svn.apache.org/repos/asf/subversion/trunk 生成的差异:

Index: subversion/mod_dav_svn/mod_dav_svn.c
===================================================================
--- subversion/mod_dav_svn/mod_dav_svn.c (revision 1544710)
+++ subversion/mod_dav_svn/mod_dav_svn.c (revision 1544711)
@@ -1097,7 +1097,8 @@

/* Fill the filename on the request with a bogus path since we aren't serving
* a file off the disk. This means that <Directory> blocks will not match and
- * that %f in logging formats will show as "svn:/path/to/repo/path/in/repo". */
+ * %f in logging formats will show as "dav_svn:/path/to/repo/path/in/repo".
+ */
static int dav_svn__translate_name(request_rec *r)
{
const char *fs_path, *repos_basename, *repos_path;
@@ -1146,7 +1147,7 @@
if (repos_path && '/' == repos_path[0] && '\0' == repos_path[1])
repos_path = NULL;

- /* Combine 'svn:', fs_path and repos_path to produce the bogus path we're
+ /* Combine 'dav_svn:', fs_path and repos_path to produce the bogus path we're
* placing in r->filename. We can't use our standard join helpers such
* as svn_dirent_join. fs_path is a dirent and repos_path is a fspath
* (that can be trivially converted to a relpath by skipping the leading
@@ -1154,7 +1155,7 @@
* repository is 'trunk/c:hi' this results in a non canonical dirent on
* Windows. Instead we just cat them together. */
r->filename = apr_pstrcat(r->pool,
- "svn:", fs_path, repos_path, SVN_VA_NULL);
+ "dav_svn:", fs_path, repos_path, SVN_VA_NULL);

/* Leave a note to ourselves so that we know not to decline in the
* map_to_storage hook. */

如果将选项 -x-p 添加到该命令,您将得到:

Index: subversion/mod_dav_svn/mod_dav_svn.c
===================================================================
--- subversion/mod_dav_svn/mod_dav_svn.c (revision 1544710)
+++ subversion/mod_dav_svn/mod_dav_svn.c (revision 1544711)
@@ -1097,7 +1097,8 @@ static int dav_svn__handler(request_rec *r)

/* Fill the filename on the request with a bogus path since we aren't serving
* a file off the disk. This means that <Directory> blocks will not match and
- * that %f in logging formats will show as "svn:/path/to/repo/path/in/repo". */
+ * %f in logging formats will show as "dav_svn:/path/to/repo/path/in/repo".
+ */
static int dav_svn__translate_name(request_rec *r)
{
const char *fs_path, *repos_basename, *repos_path;
@@ -1146,7 +1147,7 @@ static int dav_svn__translate_name(request_rec *r)
if (repos_path && '/' == repos_path[0] && '\0' == repos_path[1])
repos_path = NULL;

- /* Combine 'svn:', fs_path and repos_path to produce the bogus path we're
+ /* Combine 'dav_svn:', fs_path and repos_path to produce the bogus path we're
* placing in r->filename. We can't use our standard join helpers such
* as svn_dirent_join. fs_path is a dirent and repos_path is a fspath
* (that can be trivially converted to a relpath by skipping the leading
@@ -1154,7 +1155,7 @@ static int dav_svn__translate_name(request_rec *r)
* repository is 'trunk/c:hi' this results in a non canonical dirent on
* Windows. Instead we just cat them together. */
r->filename = apr_pstrcat(r->pool,
- "svn:", fs_path, repos_path, SVN_VA_NULL);
+ "dav_svn:", fs_path, repos_path, SVN_VA_NULL);

/* Leave a note to ourselves so that we know not to decline in the
* map_to_storage hook. */

请注意如何将函数添加到范围行上的 @@ 之后。处理差异的任何软件都会忽略这部分行。所以你可以自由地把你想要的任何东西放在那里。您可以在那里发表您的评论。

Unidiff 帅哥以 ' '(空格)开始每一行,表示上下文(如未更改的行),'+' 表示添加的行,或 '-' 表示删除的行。许多解析器(包括 Subversion 的 svn patch 命令)将丢弃以其他字符开头的行。因此,您也许可以简单地插入以其他字符开头的行。但这并不能保证与上述方法一样可移植。

关于comments - 如何在补丁/差异文件中写入注释?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20140657/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com