{"thread":{"id":"62409","subject":"[BUG] spurious failure when adding tracked file in ignored directory","startedAt":"2024-10-25T23:30:59Z","lastAt":"2024-10-27T14:08:04Z","messageCount":3,"participants":["Christian Sattler","Johannes Sixt"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"506135","messageId":"CALCpNBqfGRh3U6HpJDfUQyLOckz-hRJw2_2GRZfSFqXAyRY12g@mail.gmail.com","threadId":"62409","inReplyTo":null,"subject":"[BUG] spurious failure when adding tracked file in ignored directory","fromName":"Christian Sattler","fromEmail":"sattler.christian@gmail.com","sentAt":"2024-10-25T23:30:47Z","receivedAt":"2024-10-25T23:30:59Z","isPatch":false,"sender":{"key":"sattler.christian@gmail.com","avatar":null},"body":"Adding a tracked file in an ignored directory causes a spurious warning and\nexit code 1 failure (despite actually adding the file). Example on 2.47.0:\n\ngit init\nmkdir dir\ntouch dir/file\ngit add dir/file\necho dir >.gitignore\ngit add dir/file\n\nThe last command fails with exit code 1 and prints:\n\n> The following paths are ignored by one of your .gitignore files:\n> dir\n> hint: Use -f if you really want to add them.\n> hint: Disable this message with \"git config advice.addIgnoredFile false\"\n\nSuppose we change dir/file before the last command.  Then after the last\ncommand, the change is in the index, despite what the warning indicates.\n\n- Christian\n"},{"id":"506150","messageId":"3701837d-d9d3-422e-82f2-567a6f832dca@kdbg.org","threadId":"62409","inReplyTo":"CALCpNBqfGRh3U6HpJDfUQyLOckz-hRJw2_2GRZfSFqXAyRY12g@mail.gmail.com","subject":"Re: [BUG] spurious failure when adding tracked file in ignored directory","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2024-10-27T13:44:57Z","receivedAt":"2024-10-27T13:45:01Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 26.10.24 um 01:30 schrieb Christian Sattler:\n> Adding a tracked file in an ignored directory causes a spurious warning and\n> exit code 1 failure (despite actually adding the file). Example on 2.47.0:\n> \n> git init\n> mkdir dir\n> touch dir/file\n> git add dir/file\n> echo dir >.gitignore\n> git add dir/file\n> \n> The last command fails with exit code 1 and prints:\n> \n>> The following paths are ignored by one of your .gitignore files:\n>> dir\n>> hint: Use -f if you really want to add them.\n>> hint: Disable this message with \"git config advice.addIgnoredFile false\"\n> \n> Suppose we change dir/file before the last command.  Then after the last\n> command, the change is in the index, despite what the warning indicates.\n\nI cannot reproduce your claim \"despite actually adding the file\": the\nfile is not added. So, everything works as intended. What does `git\nstatus` tell after `git add`?\n\n-- Hannes\n\n"},{"id":"506152","messageId":"CALCpNBoZfugMQuuDoAELxkipZjYdhznJw3XzuxDC6XGYbJ9=AA@mail.gmail.com","threadId":"62409","inReplyTo":"3701837d-d9d3-422e-82f2-567a6f832dca@kdbg.org","subject":"Re: [BUG] spurious failure when adding tracked file in ignored directory","fromName":"Christian Sattler","fromEmail":"sattler.christian@gmail.com","sentAt":"2024-10-27T14:07:51Z","receivedAt":"2024-10-27T14:08:04Z","isPatch":false,"sender":{"key":"sattler.christian@gmail.com","avatar":null},"body":"On Sun, 27 Oct 2024 at 14:45, Johannes Sixt <j6t@kdbg.org> wrote:\n> I cannot reproduce your claim \"despite actually adding the file\": the\n> file is not added. So, everything works as intended. What does `git\n> status` tell after `git add`?\n\nHere is the example with modifications before the add.\n\ngit init\nmkdir dir\ntouch dir/file\ngit add dir/file\necho dir >.gitignore\necho content >dir/file\n\nOutput of git status:\n> On branch main\n>\n> No commits yet\n>\n> Changes to be committed:\n>   (use \"git rm --cached <file>...\" to unstage)\n> new file:   dir/file\n\n> Changes not staged for commit:\n>   (use \"git add <file>...\" to update what will be committed)\n>   (use \"git restore <file>...\" to discard changes in working directory)\n> modified:   dir/file\n\n> Untracked files:\n>   (use \"git add <file>...\" to include in what will be committed)\n> .gitignore\n\ngit add dir/file  # fails with warning and exit code 1\n\nOutput of git status:\n> On branch main\n>\n> No commits yet\n>\n> Changes to be committed:\n>   (use \"git rm --cached <file>...\" to unstage)\n> new file:   dir/file\n\n> Untracked files:\n>   (use \"git add <file>...\" to include in what will be committed)\n> .gitignore\n"}]}