@matheusbsbs / matheus-bagliano / commits / a41c175d6f
Fork 0

Prevent --index-info from ignoring -z.

If git-update-index --index-info -z is used only the first record given to the process will actually be updated as the -z option is ignored until after all index records have been read and processed. This meant that multiple null terminated records were seen as a single record which was lacking a trailing LF, however since the first record ended in a null the C string handling functions ignored the trailing garbage. So --index-info should be required to be the last command line option, much as --stdin is required to be the last command line option. Because --index-info implies --stdin this isn't an issue as the user shouldn't be passing --stdin when also passing --index-info. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>

Shawn Pearce committed Mar 2, 2006 at 12:21 UTC a41c175d6f3e903844131b6dc39da986248c7585
1 file changed +3 -1
update-index.c
+3 -1
@@ -577,9 +577,11 @@ int main(int argc, const char **argv)
577 break;
578 }
579 if (!strcmp(path, "--index-info")) {
580 + if (i != argc - 1)
581 + die("--index-info must be at the end");
582 allow_add = allow_replace = allow_remove = 1;
583 read_index_info(line_termination);
582 - continue;
584 + break;
585 }
586 if (!strcmp(path, "--ignore-missing")) {
587 not_new = 1;