Skip to contentSkip to conversation

contrib: added git-diffall

PATCH In review Tim Henigan 2 participants 2 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 contrib: added git-diffall

The 'git difftool' command allows the user to view diffs using an external tool. It runs a separate instance of the tool for each file in the diff. This makes it tedious to review changes spanning multiple files.

The 'git-diffall' script instead prepares temporary directories with the files to be compared and launches a single instance of the external diff tool to view them (i.e. a directory diff).

The 'diff.tool' or 'merge.tool' configuration variable is used to specify which external tool is used.

---

This script has been hosted on GitHub [1] since April 2010. Enough people have found it useful that I hope it will be considered for inclusion in the standard git install, either in contrib or as a new core command.

Changes in v4:
- Corrected location of hard-coded tmp dir
- Renamed 'path_sep' to 'dashdash_seen'
- Documented '--extcmd' in the README
- Changed test for '--extcmd=<command>' to use $#
- Documented that '--' is mandatory if a pathspec is given

v4 matches commit 251177b8e4 on GitHub [1].

Changes in v3:
- Fixed a bug that caused failures if file names included spaces
- Added unique suffix to tmp dir name (tmp/git-diffall-tmp.$$)
- Renamed "common_ancestor" to "merge_base"
- Cleaned up README to be more accurate
- Added useful error message if --extcmd is final option, but no command was specified
- Removed spaces after redirection operators

v3 matches commit f36e4881e5 on GitHub [1].

Changes in v2:
- Changed to #!/bin/sh
- Eliminated use of 'which' statements
- Fixed trap function to actually run on abnormal exit
- Simplified path concatenation logic ($IFS)
- Corrected indentation errors
- Improved readability of while loop
- Cleaned up quoting of variables

v2 matches commit 5d4b90de3 on GitHub [1].

[1]: https://github.com/thenigan/git-diffall

 contrib/diffall/README      |   31 +++++
 contrib/diffall/git-diffall |  261 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 292 insertions(+), 0 deletions(-)
 create mode 100644 contrib/diffall/README
 create mode 100755 contrib/diffall/git-diffall
contrib/diffall/README new file +31 -0
new file mode 100644
index 0000000..507f17d
@@ -0,0 +1,31 @@
+The git-diffall script provides a directory based diff mechanism
+for git.
+
+To determine what diff viewer is used, the script requires either
+the 'diff.tool' or 'merge.tool' configuration option to be set.
+
+This script is compatible with most common forms used to specify a
+range of revisions to diff:
+
+  1. git diffall: shows diff between working tree and staged changes
+  2. git diffall --cached [<commit>]: shows diff between staged
+     changes and HEAD (or other named commit)
+  3. git diffall <commit>: shows diff between working tree and named
+     commit
+  4. git diffall <commit> <commit>: show diff between two named commits
+  5. git diffall <commit>..<commit>: same as above
+  6. git diffall <commit>...<commit>: show the changes on the branch
+     containing and up to the second, starting at a common ancestor
+     of both <commit>
+
+Note: all forms take an optional path limiter [-- <path>*]
+
+The '--extcmd=<command>' option allows the user to specify a custom
+command for viewing diffs.  When given, configured defaults are
+ignored and the script runs $command $LOCAL $REMOTE.  Additionally,
+$BASE is set in the environment.
+
+This script is based on an example provided by Thomas Rast on the
+Git list [1]:
+
+[1] http://thread.gmane.org/gmane.comp.version-control.git/124807
contrib/diffall/git-diffall new file +261 -0

261 lines not on this page · raw message

Signature · 1 line
1.7.9.1
#1 lore raw

contrib/diffall/git-diffall line 79

Quoted 2 lines · Tim Henigan
contrib/diffall/git-diffall new file +2 -0
+	-x|--e|--ex|--ext|--extc|--extcm|--extcmd)
+		if test $# == 1

That is not POSIX.

	if test $# = 1

No need to resend; I'll fix it up locally.