{"thread":{"id":"65935","subject":"[PATCH v2] builtin/rm.c: use die_errno() when system call fails","startedAt":"2026-07-06T19:11:29Z","lastAt":"2026-07-06T19:44:20Z","messageCount":2,"participants":["Gatla Vishweshwar Reddy","Junio C Hamano"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"547258","messageId":"20260706191024.93788-1-gatlavishweshwarreddy26@gmail.com","threadId":"65935","inReplyTo":null,"subject":"[PATCH v2] builtin/rm.c: use die_errno() when system call fails","fromName":"Gatla Vishweshwar Reddy","fromEmail":"gatlavishweshwarreddy26@gmail.com","sentAt":"2026-07-06T19:10:24Z","receivedAt":"2026-07-06T19:11:29Z","isPatch":true,"body":"When remove_file_from_index() fails, the errno value contains the\nreason for the failure. Using die() instead of die_errno() loses\nthis information, making it harder to diagnose failures. Switch to\ndie_errno() to include the system error message in the output.\n\nSigned-off-by: Gatla Vishweshwar Reddy <gatlavishweshwarreddy26@gmail.com>\n---\n builtin/rm.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/rm.c b/builtin/rm.c\nindex 081d0bc375..3f5e6e232d 100644\n--- a/builtin/rm.c\n+++ b/builtin/rm.c\n@@ -396,7 +396,7 @@ int cmd_rm(int argc,\n \t\t\tprintf(\"rm '%s'\\n\", path);\n \n \t\tif (remove_file_from_index(the_repository->index, path))\n-\t\t\tdie(_(\"git rm: unable to remove %s\"), path);\n+\t\t\tdie_errno(_(\"git rm: unable to remove %s\"), path);\n \t}\n \n \tif (show_only)\n-- \n2.54.0\n\n"},{"id":"547262","messageId":"xmqqy0fnaooe.fsf@gitster.g","threadId":"65935","inReplyTo":"20260706191024.93788-1-gatlavishweshwarreddy26@gmail.com","subject":"Re: [PATCH v2] builtin/rm.c: use die_errno() when system call fails","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-07-06T19:44:17Z","receivedAt":"2026-07-06T19:44:20Z","isPatch":true,"body":"Gatla Vishweshwar Reddy <gatlavishweshwarreddy26@gmail.com> writes:\n\n> When remove_file_from_index() fails, the errno value contains the\n> reason for the failure.\n\nIs that true?\n\nTogether with the subject that mentions \"system call\", I think the\nabove is not quite right.  Offhand I do not think of any system call\nor library call we make, whose failure that sets errnor would cause\nthe callchain to return an error back to this caller.\n\nPlease show us a call graph that originates at this location that\ncalls remove_file_from_index(), and identify which system/library\ncall sets errno to cause this function return non-zero.\n\nOtherwise, we would end up feeding an irrelevant garbage value in\nerror and have die_errno() pick it up.\n\n> Using die() instead of die_errno() loses\n> this information, making it harder to diagnose failures. Switch to\n> die_errno() to include the system error message in the output.\n>\n> Signed-off-by: Gatla Vishweshwar Reddy <gatlavishweshwarreddy26@gmail.com>\n> ---\n>  builtin/rm.c | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/builtin/rm.c b/builtin/rm.c\n> index 081d0bc375..3f5e6e232d 100644\n> --- a/builtin/rm.c\n> +++ b/builtin/rm.c\n> @@ -396,7 +396,7 @@ int cmd_rm(int argc,\n>  \t\t\tprintf(\"rm '%s'\\n\", path);\n>  \n>  \t\tif (remove_file_from_index(the_repository->index, path))\n> -\t\t\tdie(_(\"git rm: unable to remove %s\"), path);\n> +\t\t\tdie_errno(_(\"git rm: unable to remove %s\"), path);\n>  \t}\n>  \n>  \tif (show_only)\n"}]}