Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use vimdiff instead of svn diff's Code View tool

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article is about how to use vimdiff instead of svn diff's code viewing tool. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Under linux, it is very difficult to directly use the svn diff command to view code changes, so we found a better solution on the Internet, that is, let vimdiff as a tool for viewing code in svn diff, especially for people who are used to using vim.

When you use the svn diff command to compare a file before and after modification, for example, execute the following command:

$svn diff-r4420 ngx_http_limit_req_module.c

Then the following command is actually sent to the default diff program:

-u-L ngx_http_limit_req_module.c (revision 4420)-L ngx_http_limit_req_module.c (working copy) .SVN / tmp/tempfile.tmp ngx_http_limit_req_module.c

The interpretation of svn diff in the official SVN FAQ (in Chinese and English):

When using an external diff command, Subversion generates a very complex command line. The first argument is specific-- diff-cmd, and then specific-- extensions (although extensions are ignored when using blank-- symbols), or add the'- u 'parameter if you don't specify-- extensions or-- extensions is empty. For the third and fourth parameters, Subversion passes a "- L" and the label of the first file (for example, "project_issues.html (revision 11209)"). The fifth and sixth are the labels of another "- L" and the second file. The seventh and eighth parameters are the names of the first and second files (for example, ".svn / text-base/project_issues.html.svn-base" and ".svn / tmp / project_issues.html.tmp").

Knowing the internal invocation commands of diff, it is relatively easy to implement using vimdiff as a diff program.

When vimdiff compares two files, all you need to know is the path and file name of the two files, that is, the 7th and 8th parameters of the above diff internal command.

It also shows that it is not feasible to call vimdiff directly with-diff-cmd because there are too many parameters in the diff internal command (the command is as follows).

$svn diff--diff-cmd vimdiff-r4420 ngx_http_limit_req_module.c

So, we need to write another script, let this script as a diff program, get the internal command of diff, and then take only the seventh and eighth parameters, and then pass it to vimdiff, so that we can solve the problem of too many parameters.

The diffwrap.sh is as follows:

#! / bin/sh# remove the first five parameters shift compare vimdiff "$@" using vimdiff

In addition, svn provides the ability to modify the diff default program in the configuration file so that you don't have to specify-- diff-cmd every time you use svn diff.

Modify ~ / .subversion / config to find the following configuration line:

# diff-cmd = diff_program (diff, gdiff, etc.)

Just add the path to the above script, for example, change it to

Diff-cmd = / usr/local/bin/diffwrap.sh

In the future, using the svn diff command will open vimdiff to compare 2 files by default.

Effect picture:

Thank you for reading! This is the end of this article on "how to use vimdiff instead of svn diff's code viewing tool". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report