@matheusbsbs / matheus-bagliano / commits / 5cfcd07c93
Fork 0

Retire diff-helper.

The textual diff generation with built-in '-p' in diff-* brothers has proven to be useful enough that git-diff-helper outlived its usefulness. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Sep 20, 2005 at 23:24 UTC 5cfcd07c931e6029a77f9393309f7d0ec7cdc118
11 files changed +2 -415
.gitignore
-1
@@ -20,7 +20,6 @@ git-cvsimport
20 git-daemon
21 git-diff
22 git-diff-files
23 -git-diff-helper
23 git-diff-index
24 git-diff-stages
25 git-diff-tree
Documentation/diff-format.txt
+1 -2
@@ -62,8 +62,7 @@ When "git-diff-index", "git-diff-tree", or "git-diff-files" are run
62 with a '-p' option, they do not produce the output described above;
63 instead they produce a patch file.
64
65 -The patch generation can be customized at two levels. This
66 -customization also applies to "git-diff-helper".
65 +The patch generation can be customized at two levels.
66
67 1. When the environment variable 'GIT_EXTERNAL_DIFF' is not set,
68 these commands internally invoke "diff" like this:
Documentation/git-diff-helper.txt deleted
-53
@@ -1,53 +0,0 @@
1 -git-diff-helper(1)
2 -==================
3 -v0.1, May 2005
4 -
5 -NAME
6 -----
7 -git-diff-helper - Generates patch format output for git-diff-*
8 -
9 -
10 -SYNOPSIS
11 ---------
12 -'git-diff-helper' [-z] [-S<string>] [-O<orderfile>]
13 -
14 -DESCRIPTION
15 ------------
16 -Reads output from "git-diff-index", "git-diff-tree" and "git-diff-files" and
17 -generates patch format output.
18 -
19 -OPTIONS
20 --------
21 --z::
22 - \0 line termination on input
23 -
24 --S<string>::
25 - Look for differences that contains the change in <string>.
26 -
27 ---pickaxe-all::
28 - When -S finds a change, show all the changes in that
29 - changeset, not just the files that contains the change
30 - in <string>.
31 -
32 --O<orderfile>::
33 - Output the patch in the order specified in the
34 - <orderfile>, which has one shell glob pattern per line.
35 -
36 -See Also
37 ---------
38 -The section on generating patches in gitlink:git-diff-index[1]
39 -
40 -
41 -Author
42 -------
43 -Written by Junio C Hamano <junkio@cox.net>
44 -
45 -
46 -Documentation
47 ---------------
48 -Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
49 -
50 -GIT
51 ----
52 -Part of the gitlink:git[7] suite
53 -
Documentation/git.txt
-3
@@ -363,9 +363,6 @@ gitlink:git-count-objects[1]::
363 gitlink:git-daemon[1]::
364 A really simple server for GIT repositories.
365
366 -gitlink:git-diff-helper[1]::
367 - Generates patch format output for git-diff-*
368 -
366 gitlink:git-get-tar-commit-id[1]::
367 Extract commit ID from an archive created using git-tar-tree.
368
Makefile
+1 -1
@@ -102,7 +102,7 @@ PROGRAMS = \
102 git-apply git-cat-file \
103 git-checkout-index git-clone-pack git-commit-tree \
104 git-convert-objects git-diff-files \
105 - git-diff-helper git-diff-index git-diff-stages \
105 + git-diff-index git-diff-stages \
106 git-diff-tree git-fetch-pack git-fsck-objects \
107 git-hash-object git-init-db \
108 git-local-fetch git-ls-files git-ls-tree git-merge-base \
diff-helper.c deleted
-154
@@ -1,154 +0,0 @@
1 -/*
2 - * Copyright (C) 2005 Junio C Hamano
3 - */
4 -#include "cache.h"
5 -#include "strbuf.h"
6 -#include "diff.h"
7 -
8 -static const char *pickaxe = NULL;
9 -static int pickaxe_opts = 0;
10 -static const char *orderfile = NULL;
11 -static const char *diff_filter = NULL;
12 -static int line_termination = '\n';
13 -static int inter_name_termination = '\t';
14 -
15 -static void flush_them(int ac, const char **av)
16 -{
17 - diffcore_std_no_resolve(av + 1,
18 - pickaxe, pickaxe_opts,
19 - orderfile, diff_filter);
20 - diff_flush(DIFF_FORMAT_PATCH, '\n');
21 -}
22 -
23 -static const char diff_helper_usage[] =
24 -"git-diff-helper [-z] [-O<orderfile>] [-S<string>] [--pickaxe-all] [<path>...]";
25 -
26 -int main(int ac, const char **av) {
27 - struct strbuf sb;
28 - const char *garbage_flush_format;
29 -
30 - strbuf_init(&sb);
31 -
32 - while (1 < ac && av[1][0] == '-') {
33 - if (av[1][1] == 'z')
34 - line_termination = inter_name_termination = 0;
35 - else if (av[1][1] == 'S') {
36 - pickaxe = av[1] + 2;
37 - }
38 - else if (!strcmp(av[1], "--pickaxe-all"))
39 - pickaxe_opts = DIFF_PICKAXE_ALL;
40 - else if (!strncmp(av[1], "--diff-filter=", 14))
41 - diff_filter = av[1] + 14;
42 - else if (!strncmp(av[1], "-O", 2))
43 - orderfile = av[1] + 2;
44 - else
45 - usage(diff_helper_usage);
46 - ac--; av++;
47 - }
48 - garbage_flush_format = (line_termination == 0) ? "%s" : "%s\n";
49 -
50 - /* the remaining parameters are paths patterns */
51 -
52 - diff_setup(0);
53 - while (1) {
54 - unsigned old_mode, new_mode;
55 - unsigned char old_sha1[20], new_sha1[20];
56 - char old_path[PATH_MAX];
57 - int status, score, two_paths;
58 - char new_path[PATH_MAX];
59 -
60 - int ch;
61 - char *cp, *ep;
62 -
63 - read_line(&sb, stdin, line_termination);
64 - if (sb.eof)
65 - break;
66 - switch (sb.buf[0]) {
67 - case ':':
68 - /* parse the first part up to the status */
69 - cp = sb.buf + 1;
70 - old_mode = new_mode = 0;
71 - while ((ch = *cp) && ('0' <= ch && ch <= '7')) {
72 - old_mode = (old_mode << 3) | (ch - '0');
73 - cp++;
74 - }
75 - if (*cp++ != ' ')
76 - break;
77 - while ((ch = *cp) && ('0' <= ch && ch <= '7')) {
78 - new_mode = (new_mode << 3) | (ch - '0');
79 - cp++;
80 - }
81 - if (*cp++ != ' ')
82 - break;
83 - if (get_sha1_hex(cp, old_sha1))
84 - break;
85 - cp += 40;
86 - if (*cp++ != ' ')
87 - break;
88 - if (get_sha1_hex(cp, new_sha1))
89 - break;
90 - cp += 40;
91 - if (*cp++ != ' ')
92 - break;
93 - status = *cp++;
94 - if (!strchr("AMCRDU", status))
95 - break;
96 - two_paths = score = 0;
97 - if (status == DIFF_STATUS_RENAMED ||
98 - status == DIFF_STATUS_COPIED)
99 - two_paths = 1;
100 -
101 - /* pick up score if exists */
102 - if (sscanf(cp, "%d", &score) != 1)
103 - score = 0;
104 - cp = strchr(cp,
105 - inter_name_termination);
106 - if (!cp)
107 - break;
108 - if (*cp++ != inter_name_termination)
109 - break;
110 -
111 - /* first pathname */
112 - if (!line_termination) {
113 - read_line(&sb, stdin, line_termination);
114 - if (sb.eof)
115 - break;
116 - strcpy(old_path, sb.buf);
117 - }
118 - else if (!two_paths)
119 - strcpy(old_path, cp);
120 - else {
121 - ep = strchr(cp, inter_name_termination);
122 - if (!ep)
123 - break;
124 - strncpy(old_path, cp, ep-cp);
125 - old_path[ep-cp] = 0;
126 - cp = ep + 1;
127 - }
128 -
129 - /* second pathname */
130 - if (!two_paths)
131 - strcpy(new_path, old_path);
132 - else {
133 - if (!line_termination) {
134 - read_line(&sb, stdin,
135 - line_termination);
136 - if (sb.eof)
137 - break;
138 - strcpy(new_path, sb.buf);
139 - }
140 - else
141 - strcpy(new_path, cp);
142 - }
143 - diff_helper_input(old_mode, new_mode,
144 - old_sha1, new_sha1,
145 - old_path, status, score,
146 - new_path);
147 - continue;
148 - }
149 - flush_them(ac, av);
150 - printf(garbage_flush_format, sb.buf);
151 - }
152 - flush_them(ac, av);
153 - return 0;
154 -}
diff.c
-23
@@ -1152,29 +1152,6 @@ void diff_addremove(int addremove, unsigned mode,
1152 diff_queue(&diff_queued_diff, one, two);
1153 }
1154
1155 -void diff_helper_input(unsigned old_mode,
1156 - unsigned new_mode,
1157 - const unsigned char *old_sha1,
1158 - const unsigned char *new_sha1,
1159 - const char *old_path,
1160 - int status,
1161 - int score,
1162 - const char *new_path)
1163 -{
1164 - struct diff_filespec *one, *two;
1165 - struct diff_filepair *dp;
1166 -
1167 - one = alloc_filespec(old_path);
1168 - two = alloc_filespec(new_path);
1169 - if (old_mode)
1170 - fill_filespec(one, old_sha1, old_mode);
1171 - if (new_mode)
1172 - fill_filespec(two, new_sha1, new_mode);
1173 - dp = diff_queue(&diff_queued_diff, one, two);
1174 - dp->score = score * MAX_SCORE / 100;
1175 - dp->status = status;
1176 -}
1177 -
1155 void diff_change(unsigned old_mode, unsigned new_mode,
1156 const unsigned char *old_sha1,
1157 const unsigned char *new_sha1,
diff.h
-9
@@ -19,15 +19,6 @@ extern void diff_change(unsigned mode1, unsigned mode2,
19 const unsigned char *sha2,
20 const char *base, const char *path);
21
22 -extern void diff_helper_input(unsigned mode1,
23 - unsigned mode2,
24 - const unsigned char *sha1,
25 - const unsigned char *sha2,
26 - const char *path1,
27 - int status,
28 - int score,
29 - const char *path2);
30 -
22 extern void diff_unmerge(const char *path);
23
24 extern int diff_scoreopt_parse(const char *opt);
t/t4000-diff-format.sh
-9
@@ -50,13 +50,4 @@ test_expect_success \
50 'validate git-diff-files -p output.' \
51 'cmp -s current expected'
52
53 -test_expect_success \
54 - 'build same diff using git-diff-helper.' \
55 - 'git-diff-files -z | git-diff-helper -z >current'
56 -
57 -
58 -test_expect_success \
59 - 'validate git-diff-helper output.' \
60 - 'cmp -s current expected'
61 -
53 test_done
t/t4005-diff-rename-2.sh
-80
@@ -40,38 +40,6 @@ test_expect_success \
40 'validate output from rename/copy detection (#1)' \
41 'compare_diff_raw current expected'
42
43 -# make sure diff-helper can grok it.
44 -mv expected diff-raw
45 -GIT_DIFF_OPTS=--unified=0 git-diff-helper <diff-raw >current
46 -cat >expected <<\EOF
47 -diff --git a/COPYING b/COPYING.1
48 -copy from COPYING
49 -copy to COPYING.1
50 ---- a/COPYING
51 -+++ b/COPYING.1
52 -@@ -6 +6 @@
53 -- HOWEVER, in order to allow a migration to GPLv3 if that seems like
54 -+ However, in order to allow a migration to GPLv3 if that seems like
55 -diff --git a/COPYING b/COPYING.2
56 -rename from COPYING
57 -rename to COPYING.2
58 ---- a/COPYING
59 -+++ b/COPYING.2
60 -@@ -2 +2 @@
61 -- Note that the only valid version of the GPL as far as this project
62 -+ Note that the only valid version of the G.P.L as far as this project
63 -@@ -6 +6 @@
64 -- HOWEVER, in order to allow a migration to GPLv3 if that seems like
65 -+ HOWEVER, in order to allow a migration to G.P.Lv3 if that seems like
66 -@@ -12 +12 @@
67 -- This file is licensed under the GPL v2, or a later version
68 -+ This file is licensed under the G.P.L v2, or a later version
69 -EOF
70 -
71 -test_expect_success \
72 - 'validate output from diff-helper (#1)' \
73 - 'compare_diff_patch current expected'
74 -
43 ################################################################
44
45 test_expect_success \
@@ -94,36 +62,6 @@ test_expect_success \
62 'validate output from rename/copy detection (#2)' \
63 'compare_diff_raw current expected'
64
97 -# make sure diff-helper can grok it.
98 -mv expected diff-raw
99 -GIT_DIFF_OPTS=--unified=0 git-diff-helper <diff-raw >current
100 -cat >expected <<\EOF
101 -diff --git a/COPYING b/COPYING
102 ---- a/COPYING
103 -+++ b/COPYING
104 -@@ -2 +2 @@
105 -- Note that the only valid version of the GPL as far as this project
106 -+ Note that the only valid version of the G.P.L as far as this project
107 -@@ -6 +6 @@
108 -- HOWEVER, in order to allow a migration to GPLv3 if that seems like
109 -+ HOWEVER, in order to allow a migration to G.P.Lv3 if that seems like
110 -@@ -12 +12 @@
111 -- This file is licensed under the GPL v2, or a later version
112 -+ This file is licensed under the G.P.L v2, or a later version
113 -diff --git a/COPYING b/COPYING.1
114 -copy from COPYING
115 -copy to COPYING.1
116 ---- a/COPYING
117 -+++ b/COPYING.1
118 -@@ -6 +6 @@
119 -- HOWEVER, in order to allow a migration to GPLv3 if that seems like
120 -+ However, in order to allow a migration to GPLv3 if that seems like
121 -EOF
122 -
123 -test_expect_success \
124 - 'validate output from diff-helper (#2)' \
125 - 'compare_diff_patch current expected'
126 -
65 ################################################################
66
67 # tree has COPYING and rezrov. work tree has the same COPYING and
@@ -145,22 +83,4 @@ test_expect_success \
83 'validate output from rename/copy detection (#3)' \
84 'compare_diff_raw current expected'
85
148 -# make sure diff-helper can grok it.
149 -mv expected diff-raw
150 -GIT_DIFF_OPTS=--unified=0 git-diff-helper <diff-raw >current
151 -cat >expected <<\EOF
152 -diff --git a/COPYING b/COPYING.1
153 -copy from COPYING
154 -copy to COPYING.1
155 ---- a/COPYING
156 -+++ b/COPYING.1
157 -@@ -6 +6 @@
158 -- HOWEVER, in order to allow a migration to GPLv3 if that seems like
159 -+ However, in order to allow a migration to GPLv3 if that seems like
160 -EOF
161 -
162 -test_expect_success \
163 - 'validate output from diff-helper (#3)' \
164 - 'compare_diff_patch current expected'
165 -
86 test_done
t/t4009-diff-rename-4.sh
-80
@@ -44,38 +44,6 @@ test_expect_success \
44 'validate output from rename/copy detection (#1)' \
45 'compare_diff_raw_z current expected'
46
47 -# make sure diff-helper can grok it.
48 -mv current diff-raw
49 -GIT_DIFF_OPTS=--unified=0 git-diff-helper -z <diff-raw >current
50 -cat >expected <<\EOF
51 -diff --git a/COPYING b/COPYING.1
52 -copy from COPYING
53 -copy to COPYING.1
54 ---- a/COPYING
55 -+++ b/COPYING.1
56 -@@ -6 +6 @@
57 -- HOWEVER, in order to allow a migration to GPLv3 if that seems like
58 -+ However, in order to allow a migration to GPLv3 if that seems like
59 -diff --git a/COPYING b/COPYING.2
60 -rename from COPYING
61 -rename to COPYING.2
62 ---- a/COPYING
63 -+++ b/COPYING.2
64 -@@ -2 +2 @@
65 -- Note that the only valid version of the GPL as far as this project
66 -+ Note that the only valid version of the G.P.L as far as this project
67 -@@ -6 +6 @@
68 -- HOWEVER, in order to allow a migration to GPLv3 if that seems like
69 -+ HOWEVER, in order to allow a migration to G.P.Lv3 if that seems like
70 -@@ -12 +12 @@
71 -- This file is licensed under the GPL v2, or a later version
72 -+ This file is licensed under the G.P.L v2, or a later version
73 -EOF
74 -
75 -test_expect_success \
76 - 'validate output from diff-helper (#1)' \
77 - 'compare_diff_patch current expected'
78 -
47 ################################################################
48
49 test_expect_success \
@@ -101,36 +69,6 @@ test_expect_success \
69 'validate output from rename/copy detection (#2)' \
70 'compare_diff_raw_z current expected'
71
104 -# make sure diff-helper can grok it.
105 -mv current diff-raw
106 -GIT_DIFF_OPTS=--unified=0 git-diff-helper -z <diff-raw >current
107 -cat >expected <<\EOF
108 -diff --git a/COPYING b/COPYING
109 ---- a/COPYING
110 -+++ b/COPYING
111 -@@ -2 +2 @@
112 -- Note that the only valid version of the GPL as far as this project
113 -+ Note that the only valid version of the G.P.L as far as this project
114 -@@ -6 +6 @@
115 -- HOWEVER, in order to allow a migration to GPLv3 if that seems like
116 -+ HOWEVER, in order to allow a migration to G.P.Lv3 if that seems like
117 -@@ -12 +12 @@
118 -- This file is licensed under the GPL v2, or a later version
119 -+ This file is licensed under the G.P.L v2, or a later version
120 -diff --git a/COPYING b/COPYING.1
121 -copy from COPYING
122 -copy to COPYING.1
123 ---- a/COPYING
124 -+++ b/COPYING.1
125 -@@ -6 +6 @@
126 -- HOWEVER, in order to allow a migration to GPLv3 if that seems like
127 -+ However, in order to allow a migration to GPLv3 if that seems like
128 -EOF
129 -
130 -test_expect_success \
131 - 'validate output from diff-helper (#2)' \
132 - 'compare_diff_patch current expected'
133 -
72 ################################################################
73
74 # tree has COPYING and rezrov. work tree has the same COPYING and
@@ -154,22 +92,4 @@ test_expect_success \
92 'validate output from rename/copy detection (#3)' \
93 'compare_diff_raw_z current expected'
94
157 -# make sure diff-helper can grok it.
158 -mv current diff-raw
159 -GIT_DIFF_OPTS=--unified=0 git-diff-helper -z <diff-raw >current
160 -cat >expected <<\EOF
161 -diff --git a/COPYING b/COPYING.1
162 -copy from COPYING
163 -copy to COPYING.1
164 ---- a/COPYING
165 -+++ b/COPYING.1
166 -@@ -6 +6 @@
167 -- HOWEVER, in order to allow a migration to GPLv3 if that seems like
168 -+ However, in order to allow a migration to GPLv3 if that seems like
169 -EOF
170 -
171 -test_expect_success \
172 - 'validate output from diff-helper (#3)' \
173 - 'compare_diff_patch current expected'
174 -
95 test_done