{"thread":{"id":"42529","subject":"Creating empty commits with --intent-to-add","startedAt":"2016-06-04T17:54:33Z","lastAt":"2016-06-05T19:02:07Z","messageCount":3,"participants":["Thomas Braun","Duy Nguyen"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"288369","messageId":"fdf86f73-0885-7191-2932-f10feba0bdfc@virtuell-zuhause.de","threadId":"42529","inReplyTo":null,"subject":"Creating empty commits with --intent-to-add","fromName":"Thomas Braun","fromEmail":"thomas.braun@virtuell-zuhause.de","sentAt":"2016-06-04T17:54:33Z","receivedAt":"2016-06-04T17:54:33Z","isPatch":false,"sender":{"key":"thomas.braun@virtuell-zuhause.de","avatar":"https://avatars.githubusercontent.com/u/1185677?v=4"},"body":"Hi,\n\nthe following procedure\n\nmkdir test\ncd test\ngit init\necho 1 >file\ngit add --intent-to-add file\ngit commit -m \"blurb\"\n\nresults in a commit. I would have expected that git commit complains,\nas I have not pased the --allow-empty option.\n\nIs that intended behaviour?\n\nTested with 2.8.3.windows.1 and 2.1.4 on linux.\n\nThomas\n"},{"id":"288380","messageId":"CACsJy8A8-RgpYxYsJBaLrMia7D3DfQPr4cxASNsaLyCnmgm3ZQ@mail.gmail.com","threadId":"42529","inReplyTo":"fdf86f73-0885-7191-2932-f10feba0bdfc@virtuell-zuhause.de","subject":"Re: Creating empty commits with --intent-to-add","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2016-06-05T03:15:52Z","receivedAt":"2016-06-05T03:15:52Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Sun, Jun 5, 2016 at 12:54 AM, Thomas Braun\n<thomas.braun@virtuell-zuhause.de> wrote:\n> Hi,\n>\n> the following procedure\n>\n> mkdir test\n> cd test\n> git init\n> echo 1 >file\n> git add --intent-to-add file\n> git commit -m \"blurb\"\n>\n> results in a commit. I would have expected that git commit complains,\n> as I have not pased the --allow-empty option.\n>\n> Is that intended behaviour?\n\nIt's a bug. I'll get to it very soon.\n-- \nDuy\n"},{"id":"288399","messageId":"fefa95d8-f1ef-5007-ad99-a26b01471243@virtuell-zuhause.de","threadId":"42529","inReplyTo":"CACsJy8A8-RgpYxYsJBaLrMia7D3DfQPr4cxASNsaLyCnmgm3ZQ@mail.gmail.com","subject":"Re: Creating empty commits with --intent-to-add","fromName":"Thomas Braun","fromEmail":"thomas.braun@virtuell-zuhause.de","sentAt":"2016-06-05T19:02:07Z","receivedAt":"2016-06-05T19:02:07Z","isPatch":false,"sender":{"key":"thomas.braun@virtuell-zuhause.de","avatar":"https://avatars.githubusercontent.com/u/1185677?v=4"},"body":"Am 05.06.2016 um 05:15 schrieb Duy Nguyen:\n> On Sun, Jun 5, 2016 at 12:54 AM, Thomas Braun\n> <thomas.braun@virtuell-zuhause.de> wrote:\n>> Hi,\n>>\n>> the following procedure\n>>\n>> mkdir test\n>> cd test\n>> git init\n>> echo 1 >file\n>> git add --intent-to-add file\n>> git commit -m \"blurb\"\n>>\n>> results in a commit. I would have expected that git commit complains,\n>> as I have not pased the --allow-empty option.\n>>\n>> Is that intended behaviour?\n> \n> It's a bug. I'll get to it very soon.\n\nThanks for looking into that!\n\nEncouraged by your statement I've done some bisecting via\n\n#!/bin/sh\n\ngit=../git/git\n( make -j10 git >/dev/null || exit 125 ) &&\ncd .. &&\nrm -rf test &&\nmkdir test &&\ncd test &&\n$git init &&\necho 1>file &&\n$git add --intent-to-add file  &&\n$git commit -m \"blurb\"  &&\nexit 1\n\nexit 0\n\nand found 3f6d56de (commit: ignore intent-to-add entries instead of refusing, 2012-02-07)\nas first \"bad\" commit.\n\nThis commit states\n\n#################\ncommit: ignore intent-to-add entries instead of refusing\n\nOriginally, \"git add -N\" was introduced to help users from forgetting to\nadd new files to the index before they ran \"git commit -a\".  As an attempt\nto help them further so that they do not forget to say \"-a\", \"git commit\"\nto commit the index as-is was taught to error out, reminding the user that\nthey may have forgotten to add the final contents of the paths before\nrunning the command.\n\nThis turned out to be a false \"safety\" that is useless.  If the user made\nchanges to already tracked paths and paths added with \"git add -N\", and\nthen ran \"git add\" to register the final contents of the paths added with\n\"git add -N\", \"git commit\" will happily create a commit out of the index,\nwithout including the local changes made to the already tracked paths. It\nwas not a useful \"safety\" measure to prevent \"forgetful\" mistakes from\nhappening.\n\nIt turns out that this behaviour is not just a useless false \"safety\", but\nactively hurts use cases of \"git add -N\" that were discovered later and\nhave become popular, namely, to tell Git to be aware of these paths added\nby \"git add -N\", so that commands like \"git status\" and \"git diff\" would\ninclude them in their output, even though the user is not interested in\nincluding them in the next commit they are going to make.\n\nFix this ancient UI mistake, and instead make a commit from the index\nignoring the paths added by \"git add -N\" without adding real contents.\n#################\n"}]}