{"thread":{"id":"3526","subject":"[PATCH] Prevent --index-info from ignoring -z.","startedAt":"2006-03-02T17:21:33Z","lastAt":"2006-03-02T17:21:33Z","messageCount":1,"participants":["Shawn Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"17061","messageId":"20060302172133.GA19111@spearce.org","threadId":"3526","inReplyTo":null,"subject":"[PATCH] Prevent --index-info from ignoring -z.","fromName":"Shawn Pearce","fromEmail":"spearce@spearce.org","sentAt":"2006-03-02T17:21:33Z","receivedAt":"2006-03-02T17:21:33Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"If git-update-index --index-info -z is used only the first\nrecord given to the process will actually be updated as\nthe -z option is ignored until after all index records\nhave been read and processed.  This meant that multiple\nnull terminated records were seen as a single record which\nwas lacking a trailing LF, however since the first record\nended in a null the C string handling functions ignored the\ntrailing garbage.  So --index-info should be required to be\nthe last command line option, much as --stdin is required\nto be the last command line option.  Because --index-info\nimplies --stdin this isn't an issue as the user shouldn't\nbe passing --stdin when also passing --index-info.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n\n---\n\n update-index.c |    4 +++-\n 1 files changed, 3 insertions(+), 1 deletions(-)\n\nbase eab8a06b5f0937ead199cbd35950a213486f34eb\nlast 77565623e6c7a02ead3d080816c761da85421781\ndiff --git a/update-index.c b/update-index.c\nindex ce1db38..797245a 100644\n--- a/update-index.c\n+++ b/update-index.c\n@@ -577,9 +577,11 @@ int main(int argc, const char **argv)\n \t\t\t\tbreak;\n \t\t\t}\n \t\t\tif (!strcmp(path, \"--index-info\")) {\n+\t\t\t\tif (i != argc - 1)\n+\t\t\t\t\tdie(\"--index-info must be at the end\");\n \t\t\t\tallow_add = allow_replace = allow_remove = 1;\n \t\t\t\tread_index_info(line_termination);\n-\t\t\t\tcontinue;\n+\t\t\t\tbreak;\n \t\t\t}\n \t\t\tif (!strcmp(path, \"--ignore-missing\")) {\n \t\t\t\tnot_new = 1;\n-- \n1.2.3.g5f0e\n"}]}