Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Emacs Directory Comparison and Sync Mode

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 doc
Octocat-spinner-32 .gitignore
Octocat-spinner-32 README.md
Octocat-spinner-32 dircmp.el
Octocat-spinner-32 emacs-git-difftool.sh
README.md

dircmp-mode: Emacs directory comparison and sync mode

Installation and usage

Add to your Emacs startup file:

(load "/path/to/dircmp.el")

Then:

M-x compare-directories RET dir1 RET dir2 RET

Use dircmp-mode as your Git difftool

There's a change cooking in git difftool that will make diff tools with editing capabilities much more powerful. The change will make git difftool use symbolic links to working tree files whenever one side of the comparison is the working tree.

Current versions of git difftool can use working tree symlinks, but only for files with uncommitted changes. Otherwise, it creates temporary copies of the files, making it cumbersome to save edits made during the comparison.

Emacs [dircmp-mode follows symbolic links] and compares the destination file content, allowing Emacs, together with the git difftool change, to edit working tree files during comparison.

For example, review changes that your topic branch would merge to your master branch:

$ git difftool -d $(git merge-base master HEAD)

dircmp-mode

Make changes, and save them from Ediff:

ediff

Emacs writes the changes directly to your working tree:

$ git diff
diff --git a/git-difftool.perl b/git-difftool.perl
index 5f093ae..7cf61cf 100755
--- a/git-difftool.perl
+++ b/git-difftool.perl
@@ -174,7 +174,8 @@ EOF
        }

        if ($rmode ne $null_mode) {
-           if (use_wt_file($repo, $workdir, $dst_path, $rsha1, $symlinks)) {
+           if (use_wt_file($repo, $workdir, $dst_path, $rsha1,
+                   $symlinks)) {
                push(@working_tree, $dst_path);
            } else {
                $rindex .= "$rmode $rsha1\t$dst_path\0";

To configure dircmp-mode as your Git diff tool:

~/.gitconfig:

...
[difftool "emacs"]
  cmd = /path/to/dircmp/emacs-git-difftool.sh \"$LOCAL\" \"$REMOTE\"
  prompt = false

[diff]
    tool = emacs
...

Thanks to John Keeping, Junio C. Hamano, and David Aguilar for implementing and reviewing the git difftool changes to make this possible.

Something went wrong with that request. Please try again.