Skip to content

Commit a94d994

Browse files
author
Junio C Hamano
committed
update-index: work with c-quoted name
update-index --stdin did not work with c-style quoted names even though update-index --index-info did. This fixes the inconsistency. Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent d5a6aaf commit a94d994

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

update-index.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,10 +534,17 @@ int main(int argc, const char **argv)
534534
struct strbuf buf;
535535
strbuf_init(&buf);
536536
while (1) {
537+
char *path_name;
537538
read_line(&buf, stdin, line_termination);
538539
if (buf.eof)
539540
break;
540-
update_one(buf.buf, prefix, prefix_length);
541+
if (line_termination && buf.buf[0] == '"')
542+
path_name = unquote_c_style(buf.buf, NULL);
543+
else
544+
path_name = buf.buf;
545+
update_one(path_name, prefix, prefix_length);
546+
if (path_name != buf.buf)
547+
free(path_name);
541548
}
542549
}
543550
if (active_cache_changed) {

0 commit comments

Comments
 (0)