git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Resurrect diff-tree-helper -R
@ 2005-05-01  0:34 Junio C Hamano
  2005-05-01  1:09 ` Linus Torvalds
  0 siblings, 1 reply; 25+ messages in thread
From: Junio C Hamano @ 2005-05-01  0:34 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: git

Diff-tree-helper take two patch inadvertently dropped the
support of -R option, which is necessary to produce reverse diff
based on diff-cache and diff-files output (diff-tree does not
matter since you can feed two trees in reverse order).  This
patch restores it.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
diff-tree-helper.c |   17 +++++++++++------
1 files changed, 11 insertions(+), 6 deletions(-)

jit-diff 0 diff-tree-helper.c
# - Fix up d_type handling - we need to include <dirent.h> before
# + working-tree
--- k/diff-tree-helper.c  (mode:100644)
+++ l/diff-tree-helper.c  (mode:100644)
@@ -44,7 +44,8 @@ static int parse_oneside_change(const ch
 	return 0;
 }
 
-static int parse_diff_tree_output(const char *buf, const char **spec, int cnt)
+static int parse_diff_tree_output(const char *buf,
+				  const char **spec, int cnt, int reverse)
 {
 	struct diff_spec old, new;
 	char path[PATH_MAX];
@@ -98,8 +99,12 @@ static int parse_diff_tree_output(const 
 	default:
 		return -1;
 	}
-	if (!cnt || matches_pathspec(path, spec, cnt))
-		run_external_diff(path, &old, &new);
+	if (!cnt || matches_pathspec(path, spec, cnt)) {
+		if (reverse)
+			run_external_diff(path, &new, &old);
+		else
+			run_external_diff(path, &old, &new);
+	}
 	return 0;
 }
 
@@ -108,14 +113,14 @@ static const char *diff_tree_helper_usag
 
 int main(int ac, const char **av) {
 	struct strbuf sb;
-	int reverse_diff = 0;
+	int reverse = 0;
 	int line_termination = '\n';
 
 	strbuf_init(&sb);
 
 	while (1 < ac && av[1][0] == '-') {
 		if (av[1][1] == 'R')
-			reverse_diff = 1;
+			reverse = 1;
 		else if (av[1][1] == 'z')
 			line_termination = 0;
 		else
@@ -129,7 +134,7 @@ int main(int ac, const char **av) {
 		read_line(&sb, stdin, line_termination);
 		if (sb.eof)
 			break;
-		status = parse_diff_tree_output(sb.buf, av+1, ac-1);
+		status = parse_diff_tree_output(sb.buf, av+1, ac-1, reverse);
 		if (status)
 			fprintf(stderr, "cannot parse %s\n", sb.buf);
 	}




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

end of thread, other threads:[~2005-05-15 18:10 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-01  0:34 [PATCH] Resurrect diff-tree-helper -R Junio C Hamano
2005-05-01  1:09 ` Linus Torvalds
2005-05-01  1:47   ` Daniel Jacobowitz
2005-05-01  5:33     ` Linus Torvalds
2005-05-01  2:22   ` Junio C Hamano
2005-05-01  5:27     ` Linus Torvalds
2005-05-01  6:22       ` Junio C Hamano
2005-05-01  7:21         ` [PATCH] Add git-apply-patch-script Junio C Hamano
2005-05-01  7:19       ` [PATCH] Rework built-in diff to make its output more dense Junio C Hamano
2005-05-13 22:45   ` [PATCH] Resurrect diff-tree-helper -R Petr Baudis
2005-05-13 22:50     ` Junio C Hamano
2005-05-13 22:59     ` Junio C Hamano
2005-05-13 23:33       ` Petr Baudis
2005-05-13 23:59         ` Junio C Hamano
2005-05-14  0:33           ` Junio C Hamano
2005-05-14 15:03             ` Petr Baudis
2005-05-14 16:27               ` Junio C Hamano
2005-05-14 23:35                 ` Petr Baudis
2005-05-15  6:25                   ` Junio C Hamano
2005-05-15  9:30                     ` Petr Baudis
2005-05-15 18:07                       ` Junio C Hamano
2005-05-15 18:10                     ` [PATCH] Tweak diff output further to make it a bit less distracting Junio C Hamano
2005-05-14 15:02           ` [PATCH] Resurrect diff-tree-helper -R Petr Baudis
2005-05-14  0:03         ` Junio C Hamano
2005-05-13 23:05     ` 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).