Skip to content

Commit c7eb614

Browse files
committed
Merge branch 'jk/cat-file-batch-optim'
* jk/cat-file-batch-optim: Revert "cat-file: split --batch input lines on whitespace"
2 parents 304852f + 062aeee commit c7eb614

File tree

3 files changed

+3
-34
lines changed

3 files changed

+3
-34
lines changed

Documentation/git-cat-file.txt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,8 @@ BATCH OUTPUT
8888
If `--batch` or `--batch-check` is given, `cat-file` will read objects
8989
from stdin, one per line, and print information about them.
9090

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].
9593

9694
You can specify the information shown for each object by using a custom
9795
`<format>`. The `<format>` is copied literally to stdout for each
@@ -112,10 +110,6 @@ newline. The available atoms are:
112110
The size, in bytes, that the object takes up on disk. See the
113111
note about on-disk sizes in the `CAVEATS` section below.
114112

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-
119113
If no format is specified, the default format is `%(objectname)
120114
%(objecttype) %(objectsize)`.
121115

builtin/cat-file.c

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ struct expand_data {
119119
enum object_type type;
120120
unsigned long size;
121121
unsigned long disk_size;
122-
const char *rest;
123122

124123
/*
125124
* 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,
164163
data->info.disk_sizep = &data->disk_size;
165164
else
166165
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);
170166
} else
171167
die("unknown format element: %.*s", len, atom);
172168
}
@@ -277,21 +273,7 @@ static int batch_objects(struct batch_options *opt)
277273
warn_on_object_refname_ambiguity = 0;
278274

279275
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);
295277
if (error)
296278
return error;
297279
}

t/t1006-cat-file.sh

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,6 @@ $content"
7878
echo $sha1 | git cat-file --batch-check="%(objecttype) %(objectname)" >actual &&
7979
test_cmp expect actual
8080
'
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-
'
8881
}
8982

9083
hello_content="Hello World"

0 commit comments

Comments
 (0)