Skip to contentSkip to conversation

Display change history as a diff between two dirs

PATCH In review Roland Kaufmann 2 participants 3 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH v4 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.

---
Issue addressed in this revision:
* If changes were made in subdirectories the script though the diff set between the two trees was empty, because it only checked for regular files.

 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..a23efee
@@ -0,0 +1,37 @@
+#!/bin/sh
+#
+# Accumulate files in a changeset into a pre-defined directory.
+#
+# Copyright (C) 2011-2012 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
#1 lore raw
Quoted 7 lines · Roland Kaufmann

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.

Quoted 7 lines

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.

---

Sorry, but I completely forgot about this three-month old topic (the last discussion was early November last year).

How does this compare with Tim Henigan's "diffall"? I think the problem these two topics try to address is the same, and their approach may be similar enough that having one consolidated effort might be worth it.

I seem to have suggested during the previous review round of this series the same thing I suggested to Tim, that we _might_ want to instead have the logic to populate the two temporary trees on the core side with a new external diff interface.

http://thread.gmane.org/gmane.comp.version-control.git/184458/focus=184462

#2 lore raw
Quoted 3 lines · Junio C Hamano

How does this compare with Tim Henigan's "diffall"?  I think the problem these two topics try to address is the same, and their approach may be similar enough that having one consolidated effort might be worth it.

Yes, I certainly agree. From a quick glance it seems to do exactly the same thing (and both take inspirations from scripts already floating around on the net); I guess that is a sign that it is an idea whose time has come! :-)

The major difference is that Tim's version generate the list of files and then extract them, whereas my current version piggybacks on the external diff interface (as you suggested in one of the previous reviews). Which of these approaches -- if any -- has the most merit I think depends on the plans for that interface.

But until that's decided upon, it would have been nice if a version could hang out in contrib/ to gather some experience.

Signature · 1 line
   Roland.