Ванька ( dedm) wrote,

Recursevely compare and merge directories?

Imaging you are a maintainer of multiple environment configurations of some application. For each configuration you have its own directory which is likely to be put under version control. Now consider this use case: you make changes in one environment, and want to propagate this changes into another one (ideally, from a pure Unix console). What to do, if both environments have their own specific options? So, we cannot just copy all the files from one environment to another by the means of rsync. There is a nice side-by-side merge utility: sdiff, but it deals only with two particular files, as well as my favorite choice for this: vimdiff. The closest analogy for this behavior is Gentoo's dispatch-conf, but it's a very specific tool.

Well, I've found an elegant solution for this problem, which doesn't require the installation of additional software: DirDiff.vim plugin, which is using lovely vimdiff feature as an underlying merge. Just put it into your ~/.vim/plugin/ and start with :DirDiff from-dir to-dir.

As an example, I've just compared two random directories on my laptop and made a screenshot:

Image #970036, 59.3 KB

Vim is the power!
Tags: configuration, development, i18n, linux, vim
  • Post a new comment


    default userpic

    Your IP address will be recorded