git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [wishlist] graphical diff

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Mar 18, 2007, 23:09 UTC
Message-ID
<Pine.LNX.4.63.0703182342110.22628@wbgn013.biozentrum.uni-wuerzburg.de>
In-Reply-To
<200703181606.20678.robin.rosenberg.lists@dewire.com>
Hi,
On Sun, 18 Mar 2007, Robin Rosenberg wrote:
Show 5 quoted lines
> söndag 18 mars 2007 14:16 skrev Raimund Bauer:
> > I think it would be really helpful (especially for newbies like me) to
> > have an option like
> > 
> > git diff --gui [revisions] <singe path spec>

And how do you set _what_ gui you want? Everybody has her pet diff-viewer (mine is less, BTW).

Show 6 quoted lines
> Fine, except it is not likely to be my favourite gui. But you don't have 
> to wait, you can get a gui easily today.
>
> [...] 
> 
> git diff HEAD^..HEAD | kompare -

BTW here, "kompare -" does not work as expected. It shows an empty diff. At any rate, have you tried something like "GIT_PAGER='kompare -' git diff HEAD^..HEAD"?

This reminds me that I always wanted to be able to set the pager from the command line, so I can set an alias easily:

-- snipsnap -- [PATCH] Allow setting the pager from the command line

The command `git` already allows piping the output into a pager with `-p`. Now also allow to set the pager with `-p=<pager-cmd>`.

With this, it is possible to make an alias of command/pager combos, like this:

	$ git config alias.showmore '-p=more show'
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 Documentation/git.txt |    8 +++++---
 git.c                 |    7 ++++++-
 2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/Documentation/git.txt b/Documentation/git.txt
index 0b1203e..5634b30 100644
--- a/Documentation/git.txt
+++ b/Documentation/git.txt
@@ -9,7 +9,7 @@ git - the stupid content tracker
 SYNOPSIS
 --------
 [verse]
-'git' [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate]
+'git' [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate][=<pager-cmd>]
 	[-n|--name-rev] [-t|--name-rev-by-tags] [--bare]
 	[--git-dir=GIT_DIR] [--help] COMMAND [ARGS]
 
@@ -75,8 +75,10 @@ OPTIONS
 	environment variable. If no path is given 'git' will print
 	the current setting and then exit.
 
--p|--paginate::
-	Pipe all output into 'less' (or if set, $PAGER).
+-p|--paginate[=<pager-cmd>]::
+	Pipe all output into 'less'. You can override this by
+	"=<pager-cmd>", or setting the environment variables $GIT_PAGER
+	or $PAGER (in that order).
 
 -n|--name-rev:
 	Try naming all SHA1s, and page the result (see
diff --git a/git.c b/git.c
index fca1dfb..76b126d 100644
--- a/git.c
+++ b/git.c
@@ -4,7 +4,7 @@
 #include "quote.h"
 
 const char git_usage_string[] =
-	"git [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate] [--bare] [--git-dir=GIT_DIR] [--help] COMMAND [ARGS]";
+	"git [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate][=pager_cmd] [--bare] [--git-dir=GIT_DIR] [--help] COMMAND [ARGS]";
 
 static void prepend_to_path(const char *dir, int len)
 {
@@ -58,6 +58,11 @@ static int handle_options(const char*** argv, int* argc)
 			}
 		} else if (!strcmp(cmd, "-p") || !strcmp(cmd, "--paginate")) {
 			setup_pager();
+		} else if (!prefixcmp(cmd, "-p=") ||
+				!prefixcmp(cmd, "--paginate=")) {
+			const char *equal = strchr(cmd, '=');
+			setenv("GIT_PAGER", equal + 1, 1);
+			setup_pager();
 		} else if (!strcmp(cmd, "-n") || !strcmp(cmd, "--name-rev"))
 			setup_name_rev_pager(0);
 		else if (!strcmp(cmd, "-t") ||
-- 
1.5.0.4.2713.g4ff1
Previous: Robin RosenbergNext: Robin Rosenberg
Message 3 of 11 in “[wishlist] graphical diff”
  1. Raimund BauerMar 18, 2007
  2. Robin RosenbergMar 18, 2007
  3. Johannes SchindelinMar 18, 2007
  4. Robin RosenbergMar 18, 2007
  5. Johannes SchindelinMar 19, 2007
  6. Raimund BauerMar 19, 2007
  7. Johannes SchindelinMar 19, 2007
  8. Raimund BauerMar 19, 2007
  9. Johannes SchindelinMar 19, 2007
  10. Raimund BauerMar 19, 2007
  11. Christian MICHONMar 18, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.