Skip to contentSkip to conversation

Display change history as a diff between two dirs

PATCH Superseded Roland Kaufmann 1 participant 1 message Jun 15, 2016

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 Display change history as a diff between two dirs

Watching patches serially it can be difficult to get an overview of how a pervasive change is distributed through-out different modules. Thus;

Extract snapshots of the files that have changed between two revisions into temporary directories and launch a graphical tool to show the diff between them.

Use existing functionality in git-diff to get the files themselves, and git-difftool to launch the diff viewer.

Based on a script called 'git-diffc' by Nitin Gupta.

---
Issues addressed in this revision are:

* Diff-viewer is searched for in order: env. var. GIT_EXTERNAL_TREEDIFF, env. var. GIT_EXTERNAL_DIFF, conf. of git-difftool.

If dir. comp. is found useful, there should probably be some config var. to control it too, but I think that will require some refactoring of git-mergetool--lib.

* Only platforms where mktemp is known to exist (and have sane options) are explicitly tested for; the default is to fallback to a Perl module implementation which is heavier, but has a greater chance of working I reckon (git-send-email uses this module).

* Less convoluted testing of empty directory.

 contrib/dirdiff/README                 |   10 ++++
 contrib/dirdiff/git-dirdiff--helper.sh |   37 ++++++++++++++++
 contrib/dirdiff/git-dirdiff.sh         |   72 ++++++++++++++++++++++++++++++++
 contrib/dirdiff/git-dirdiff.txt        |   71 +++++++++++++++++++++++++++++++
 4 files changed, 190 insertions(+), 0 deletions(-)
 create mode 100644 contrib/dirdiff/README
 create mode 100755 contrib/dirdiff/git-dirdiff--helper.sh
 create mode 100755 contrib/dirdiff/git-dirdiff.sh
 create mode 100644 contrib/dirdiff/git-dirdiff.txt
contrib/dirdiff/README new file +10 -0
new file mode 100644
index 0000000..d06461a
@@ -0,0 +1,10 @@
+# install on GNU, BSD:
+for f in "" "--helper"; do
+  b=git-dirdiff$f
+  sudo install -m 0755 contrib/dirdiff/$b.sh $(git --exec-path)/$b
+done
+
+# install on Windows
+for /f %a in ('git --exec-path') do set GIT_PATH=%a
+set GIT_PATH=%GIT_PATH:/=\%
+for %a in ("" "--helper") do copy contrib\dirdiff\git-dirdiff%~a.sh "%GIT_PATH%\%~a" /y
contrib/dirdiff/git-dirdiff--helper.sh new file +37 -0
new file mode 100755
index 0000000..8ff0124
@@ -0,0 +1,37 @@
+#!/bin/sh
+#
+# Accumulate files in a changeset into a pre-defined directory.
+#
+# Copyright (C) 2011 Roland Kaufmann
+#
+# Based on a script called git-diffc by Nitin Gupta and valuable
+# suggestions by Junio C. Hamano.
+#
+# This file is licensed under the GPL v2, or a later version
+# at the discretion of the official Git maintainer.
+
+. git-sh-setup
+
+# check that we are called by git-dirdiff
+test -z "$__GIT_DIFF_DIR" &&
+  die Error: Do not call $(basename "$0") directly
+
+# what is the directory name of the file that has changed
+RELDIR=$(dirname "$1") ||
+  exit $?
+
+# don't attempt to copy new or removed files
+if test "$2" != "/dev/null"
+then
+  mkdir -p "$__GIT_DIFF_DIR/old/$RELDIR" ||
+    exit $?
+  cp "$2" "$__GIT_DIFF_DIR/old/$1" ||
+    exit $?
+fi
+if test "$5" != "/dev/null"
+then
+  mkdir -p "$__GIT_DIFF_DIR/new/$RELDIR" ||
+    exit $?
+  cp "$5" "$__GIT_DIFF_DIR/new/$1" ||
+    exit $?
+fi
contrib/dirdiff/git-dirdiff.sh new file +72 -0

72 lines not on this page · raw message

contrib/dirdiff/git-dirdiff.txt new file +71 -0

71 lines not on this page · raw message

Signature · 1 line
1.7.1