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

[PATCH] git log [diff-tree options]...

From
Junio C Hamano <junkio@cox.net>
Date
Apr 9, 2006, 09:04 UTC
Message-ID
<7v7j5zce7x.fsf@assigned-by-dhcp.cox.net>

And this makes "git log" to take common diff-tree options, so that it can be used as "git whatchanged".

The recent revision walker updates by Linus to make path limiting low-latency helps this quite a bit.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 git.c |   32 +++++++++++++++++++++++++++++++-
 1 files changed, 31 insertions(+), 1 deletions(-)
52b70d56bd23811003a72866cc23a0a44b9da1b7
diff --git a/git.c b/git.c
index fa58232..8776088 100644
--- a/git.c
+++ b/git.c
@@ -16,6 +16,8 @@ #include "common-cmds.h"
 #include "cache.h"
 #include "commit.h"
 #include "revision.h"
+#include "diff.h"
+#include "log-tree.h"
 
 #ifndef PATH_MAX
 # define PATH_MAX 4096
@@ -285,7 +287,10 @@ static int cmd_log(int argc, const char 
 	int abbrev = DEFAULT_ABBREV;
 	int abbrev_commit = 0;
 	const char *commit_prefix = "commit ";
+	struct log_tree_opt opt;
+	int do_diff = 0;
 
+	init_log_tree_opt(&opt);
 	argc = setup_revisions(argc, argv, &rev, "HEAD");
 	while (1 < argc) {
 		const char *arg = argv[1];
@@ -310,9 +315,31 @@ static int cmd_log(int argc, const char 
 			else if (40 < abbrev)
 				abbrev = 40;
 		}
-		else
+		else {
+			int cnt = log_tree_opt_parse(&opt, argv+1, argc-1);
+			if (0 < cnt) {
+				do_diff = 1;
+				argv += cnt;
+				argc -= cnt;
+				continue;
+			}
 			die("unrecognized argument: %s", arg);
+		}
+
 		argc--; argv++;
+	}
+	if (do_diff) {
+		opt.diffopt.abbrev = abbrev;
+		opt.verbose_header = 0;
+		opt.always_show_header = 0;
+		opt.no_commit_id = 1;
+		if (opt.combine_merges)
+			opt.ignore_merges = 0;
+		if (opt.dense_combined_merges)
+			opt.diffopt.output_format = DIFF_FORMAT_PATCH;
+		if (opt.diffopt.output_format == DIFF_FORMAT_PATCH)
+			opt.diffopt.recursive = 1;
+		diff_setup_done(&opt.diffopt);
 	}
 
 	prepare_revision_walk(&rev);
@@ -350,6 +377,9 @@ static int cmd_log(int argc, const char 
 		pretty_print_commit(commit_format, commit, ~0, buf,
 				    LOGSIZE, abbrev);
 		printf("%s\n", buf);
+
+		if (do_diff)
+			log_tree_commit(&opt, commit);
 	}
 	free(buf);
 	return 0;
-- 
1.2.6.gad0b
Next: Junio C Hamano
Message 1 of 22 in “git log [diff-tree options]...”
  1. git log [diff-tree options]...Junio C Hamano, Apr 9, 2006
  2. Junio C HamanoApr 9, 2006
  3. Linus TorvaldsApr 9, 2006
  4. Junio C HamanoApr 9, 2006
  5. Linus TorvaldsApr 9, 2006
  6. Junio C HamanoApr 9, 2006
  7. Linus TorvaldsApr 9, 2006
  8. Johannes SchindelinApr 9, 2006
  9. Johannes SchindelinApr 9, 2006
  10. Timo HirvonenApr 9, 2006
  11. Johannes SchindelinApr 10, 2006
  12. Junio C HamanoApr 9, 2006
  13. Linus TorvaldsApr 10, 2006
  14. Johannes SchindelinApr 10, 2006
  15. Randal L. SchwartzApr 11, 2006
  16. Junio C HamanoApr 11, 2006
  17. Petr BaudisApr 11, 2006
  18. Randal L. SchwartzApr 11, 2006
  19. Junio C HamanoApr 10, 2006
  20. tree-diff: do not assume we use only one pathspecJunio C Hamano, Apr 10, 2006
  21. git log --full-diffJunio C Hamano, Apr 10, 2006
  22. Linus TorvaldsApr 10, 2006

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.