git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] log: support --full-diff=<pathspec>
@ 2011-11-03 10:01 Nguyễn Thái Ngọc Duy
  2011-11-03 12:15 ` [PATCH] log: allow to specify diff pathspec in addition to prune pathspec Nguyễn Thái Ngọc Duy
  0 siblings, 1 reply; 5+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2011-11-03 10:01 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

I wanted to check if any patches that update builtin/fsck.c also
update 't' directory and git seemed not support this case
(true?). With this I can do

  git log --patch --full-diff="'builtin/fsck.c' 't'" -- builtin/fsck.c

I guess this may be something people find useful.

This patch is a bit inconvenient though because <pathspec> is parsed
with sq_dequote_to_argv() and all arguments must be wrapped by ''.
Also "full-diff" name does not make much sense when it comes with
pathspec.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 revision.c |   19 +++++++++++++++++++
 revision.h |    1 +
 2 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/revision.c b/revision.c
index 8764dde..f508953 100644
--- a/revision.c
+++ b/revision.c
@@ -13,6 +13,7 @@
 #include "decorate.h"
 #include "log-tree.h"
 #include "string-list.h"
+#include "quote.h"
 
 volatile show_early_output_fn_t show_early_output;
 
@@ -1531,6 +1532,10 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
 	} else if (!strcmp(arg, "--full-diff")) {
 		revs->diff = 1;
 		revs->full_diff = 1;
+	} else if (!prefixcmp(arg, "--full-diff=")) {
+		revs->diff = 1;
+		revs->full_diff = 1;
+		revs->full_diff_opt = arg + strlen("--full-diff=");
 	} else if (!strcmp(arg, "--full-history")) {
 		revs->simplify_history = 0;
 	} else if (!strcmp(arg, "--relative-date")) {
@@ -1819,6 +1824,20 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
 			revs->prune = 1;
 		if (!revs->full_diff)
 			diff_tree_setup_paths(revs->prune_data.raw, &revs->diffopt);
+		else if (revs->full_diff_opt) {
+			const char **argv = NULL;
+			int alloc = 0, nr = 0;
+			char *arg;
+
+			arg = xstrdup(revs->full_diff_opt);
+			sq_dequote_to_argv(arg, &argv, &nr, &alloc);
+
+			ALLOC_GROW(argv, nr + 1, alloc);
+			argv[nr] = NULL;
+			argv = get_pathspec(revs->prefix, argv);
+
+			diff_tree_setup_paths(argv, &revs->diffopt);
+		}
 	}
 	if (revs->combine_merges)
 		revs->ignore_merges = 0;
diff --git a/revision.h b/revision.h
index 6aa53d1..baa709c 100644
--- a/revision.h
+++ b/revision.h
@@ -137,6 +137,7 @@ struct rev_info {
 	const char	*subject_prefix;
 	int		no_inline;
 	int		show_log_size;
+	const char      *full_diff_opt;
 
 	/* Filter by commit log message */
 	struct grep_opt	grep_filter;
-- 
1.7.3.1.256.g2539c.dirty

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-11-05  3:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-03 10:01 [PATCH] log: support --full-diff=<pathspec> Nguyễn Thái Ngọc Duy
2011-11-03 12:15 ` [PATCH] log: allow to specify diff pathspec in addition to prune pathspec Nguyễn Thái Ngọc Duy
2011-11-04 22:04   ` Junio C Hamano
2011-11-05  3:25     ` Nguyen Thai Ngoc Duy
2011-11-04 22:07   ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).