Revert "cat-file: split --batch input lines on whitespace"

This reverts commit c334b87b30c1464a1ab563fe1fb8de5eaf0e5bac; the update assumed that people only used the command to read from "rev-list --objects" output, whose lines begin with a 40-hex object name followed by a whitespace, but it turns out that scripts feed random extended SHA-1 expressions (e.g. "HEAD:$pathname") in which a whitespace has to be kept.

Junio C Hamano committed Aug 2, 2013 at 09:29 UTC 062aeee8aa426468817c5bea96d781289b272ced
3 files changed +3 -34
Documentation/git-cat-file.txt
+2 -8
@@ -88,10 +88,8 @@ BATCH OUTPUT
88 If `--batch` or `--batch-check` is given, `cat-file` will read objects
89 from stdin, one per line, and print information about them.
90
91 -Each line is split at the first whitespace boundary. All characters
92 -before that whitespace are considered as a whole object name, and are
93 -parsed as if given to linkgit:git-rev-parse[1]. Characters after that
94 -whitespace can be accessed using the `%(rest)` atom (see below).
91 +Each line is considered as a whole object name, and is parsed as if
92 +given to linkgit:git-rev-parse[1].
93
94 You can specify the information shown for each object by using a custom
95 `<format>`. The `<format>` is copied literally to stdout for each
@@ -112,10 +110,6 @@ newline. The available atoms are:
110 The size, in bytes, that the object takes up on disk. See the
111 note about on-disk sizes in the `CAVEATS` section below.
112
115 -`rest`::
116 - The text (if any) found after the first run of whitespace on the
117 - input line (i.e., the "rest" of the line).
118 -
113 If no format is specified, the default format is `%(objectname)
114 %(objecttype) %(objectsize)`.
115
builtin/cat-file.c
+1 -19
@@ -119,7 +119,6 @@ struct expand_data {
119 enum object_type type;
120 unsigned long size;
121 unsigned long disk_size;
122 - const char *rest;
122
123 /*
124 * If mark_query is true, we do not expand anything, but rather
@@ -164,9 +163,6 @@ static void expand_atom(struct strbuf *sb, const char *atom, int len,
163 data->info.disk_sizep = &data->disk_size;
164 else
165 strbuf_addf(sb, "%lu", data->disk_size);
167 - } else if (is_atom("rest", atom, len)) {
168 - if (!data->mark_query && data->rest)
169 - strbuf_addstr(sb, data->rest);
166 } else
167 die("unknown format element: %.*s", len, atom);
168 }
@@ -277,21 +273,7 @@ static int batch_objects(struct batch_options *opt)
273 warn_on_object_refname_ambiguity = 0;
274
275 while (strbuf_getline(&buf, stdin, '\n') != EOF) {
280 - char *p;
281 - int error;
282 -
283 - /*
284 - * Split at first whitespace, tying off the beginning of the
285 - * string and saving the remainder (or NULL) in data.rest.
286 - */
287 - p = strpbrk(buf.buf, " \t");
288 - if (p) {
289 - while (*p && strchr(" \t", *p))
290 - *p++ = '\0';
291 - }
292 - data.rest = p;
293 -
294 - error = batch_one_object(buf.buf, opt, &data);
276 + int error = batch_one_object(buf.buf, opt, &data);
277 if (error)
278 return error;
279 }
t/t1006-cat-file.sh
-7
@@ -78,13 +78,6 @@ $content"
78 echo $sha1 | git cat-file --batch-check="%(objecttype) %(objectname)" >actual &&
79 test_cmp expect actual
80 '
81 -
82 - test_expect_success '--batch-check with %(rest)' '
83 - echo "$type this is some extra content" >expect &&
84 - echo "$sha1 this is some extra content" |
85 - git cat-file --batch-check="%(objecttype) %(rest)" >actual &&
86 - test_cmp expect actual
87 - '
81 }
82
83 hello_content="Hello World"