{"thread":{"id":"417","subject":"[PATCH] Allow removing files in a subdirectory.","startedAt":"2005-05-01T11:16:17Z","lastAt":"2005-05-01T11:16:17Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"2290","messageId":"7vu0lnxkla.fsf@assigned-by-dhcp.cox.net","threadId":"417","inReplyTo":null,"subject":"[PATCH] Allow removing files in a subdirectory.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-05-01T11:16:17Z","receivedAt":"2005-05-01T11:16:17Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"I found this during a conflict merge testing.  The original did\nnot have either DF (a file) or DF/DF (a file DF/DF under a\ndirectory DF).  One side created DF, the other created DF/DF.  I\nfirst resolved DF as a new file by taking what the first side\ndid.  After that, the entry DF/DF cannot be resolved by running\ngit-update-cache --remove although it does not exist on the\nfilesystem.\n\n    $ /bin/ls -F\n    AN  DF  MN  NM  NN  SS  Z/\n    $ git-ls-files --stage | grep DF\n    100644 71420ab81e254145d26d6fc0cddee64c1acd4787 0 DF\n    100644 68a6d8b91da11045cf4aa3a5ab9f2a781c701249 2 DF/DF\n    $ git-update-cache --remove DF/DF\n    fatal: Unable to add DF/DF to database\n\nIt turns out that the errno from open() in this case was not\nENOENT but ENOTDIR, which the code did not check.  Here is a\nfix.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\n\nBTW, Linus do you want the updates to my merge-test-script-from-hell? \n\n\nupdate-cache.c |    2 +-\n1 files changed, 1 insertion(+), 1 deletion(-)\n\n# - [PATCH] Resurrect diff-tree-helper -R\n# + [PATCH] Allow removing files in a subdirectory.\n--- k/update-cache.c\n+++ l/update-cache.c\n@@ -111,7 +111,7 @@ static int add_file_to_cache(char *path)\n \n \tfd = open(path, O_RDONLY);\n \tif (fd < 0) {\n-\t\tif (errno == ENOENT) {\n+\t\tif (errno == ENOENT || errno == ENOTDIR) {\n \t\t\tif (allow_remove)\n \t\t\t\treturn remove_file_from_cache(path);\n \t\t}\n\n"}]}