{"thread":{"id":"7545","subject":"[PATCH] rename_ref(): only print a warning when config-file update fails","startedAt":"2007-04-06T08:33:06Z","lastAt":"2007-04-07T00:14:57Z","messageCount":5,"participants":["Lars Hjemli","Geert Bosch","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"38784","messageId":"11758483861506-git-send-email-hjemli@gmail.com","threadId":"7545","inReplyTo":null,"subject":"[PATCH] rename_ref(): only print a warning when config-file update fails","fromName":"Lars Hjemli","fromEmail":"hjemli@gmail.com","sentAt":"2007-04-06T08:33:06Z","receivedAt":"2007-04-06T08:33:06Z","isPatch":true,"sender":{"key":"hjemli@gmail.com","avatar":null},"body":"If git_config_rename_section() fails, rename_ref() used to return 1, which\nleft HEAD pointing to an absent refs/heads file (since the actual renaming\nhad already occurred).\n\nSigned-off-by: Lars Hjemli <hjemli@gmail.com>\n---\n\nOn 4/5/07, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> Hi,\n> \n> On Thu, 5 Apr 2007, Geert Bosch wrote:\n> \n> > Make git_config_rename_section return success if no config file\n> > exists.\n> \n> I don't think this is correct. git_config_rename_section() _should_ return\n> an error.\n> \n> > Otherwise, renaming a branch would abort, leaving the repository in an\n> > inconsistent state.\n> \n> This should take the hint from --rename-section, and print a warning (or\n> not).\n\nI think both arguments makes sense. There really is no reason to abort the\nrename operation if the config file update fails (for any reason).\n\n\n refs.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/refs.c b/refs.c\nindex f471152..2ac6384 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -835,7 +835,7 @@ int rename_ref(const char *oldref, const char *newref, const char *logmsg)\n \t\tsnprintf(oldsection, 1024, \"branch.%s\", oldref + 11);\n \t\tsnprintf(newsection, 1024, \"branch.%s\", newref + 11);\n \t\tif (git_config_rename_section(oldsection, newsection) < 0)\n-\t\t\treturn 1;\n+\t\t\terror(\"unable to update config-file\");\n \t}\n \n \treturn 0;\n-- \n1.5.1.53.g77e6f\n"},{"id":"38785","messageId":"2FE08503-8936-4EB9-9DBF-08AFE2923BD9@gnat.com","threadId":"7545","inReplyTo":"11758483861506-git-send-email-hjemli@gmail.com","subject":"Re: [PATCH] rename_ref(): only print a warning when config-file update fails","fromName":"Geert Bosch","fromEmail":"bosch@gnat.com","sentAt":"2007-04-06T10:35:54Z","receivedAt":"2007-04-06T10:35:54Z","isPatch":true,"sender":{"key":"bosch@gnat.com","avatar":null},"body":"\nOn Apr 6, 2007, at 04:33, Lars Hjemli wrote:\n> If git_config_rename_section() fails, rename_ref() used to return  \n> 1, which\n> left HEAD pointing to an absent refs/heads file (since the actual  \n> renaming\n> had already occurred).\n>\n> Signed-off-by: Lars Hjemli <hjemli@gmail.com>\n\nThis makes sense in addition to my patch, if the renaming\nfails for any of the other possible reasons.\n\n   -Geert\n"},{"id":"38798","messageId":"7v1wixkzpz.fsf@assigned-by-dhcp.cox.net","threadId":"7545","inReplyTo":"11758483861506-git-send-email-hjemli@gmail.com","subject":"Re: [PATCH] rename_ref(): only print a warning when config-file update fails","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-04-06T20:35:52Z","receivedAt":"2007-04-06T20:35:52Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Lars Hjemli <hjemli@gmail.com> writes:\n\n> If git_config_rename_section() fails, rename_ref() used to return 1, which\n> left HEAD pointing to an absent refs/heads file (since the actual renaming\n> had already occurred).\n\nI wonder if rolling back the rename that was asked is an\noption.  We would want to keep these low-level things atomic\nwhenever possible.\n"},{"id":"38825","messageId":"8c5c35580704061653x7e5fd149ud31a8289a4508b54@mail.gmail.com","threadId":"7545","inReplyTo":"7v1wixkzpz.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] rename_ref(): only print a warning when config-file update fails","fromName":"Lars Hjemli","fromEmail":"hjemli@gmail.com","sentAt":"2007-04-06T23:53:43Z","receivedAt":"2007-04-06T23:53:43Z","isPatch":true,"sender":{"key":"hjemli@gmail.com","avatar":null},"body":"On 4/6/07, Junio C Hamano <junkio@cox.net> wrote:\n> Lars Hjemli <hjemli@gmail.com> writes:\n>\n> > If git_config_rename_section() fails, rename_ref() used to return 1, which\n> > left HEAD pointing to an absent refs/heads file (since the actual renaming\n> > had already occurred).\n>\n> I wonder if rolling back the rename that was asked is an\n> option.  We would want to keep these low-level things atomic\n> whenever possible.\n\nI was wondering the same thing, i.e. \"goto rollback\" as an option for\n\"error()\". But I ended up thinking that rename_ref() shouldn't bother\nwith the config file at all (thus my other patch).\n\n-- \nlarsh\n"},{"id":"38828","messageId":"7v6489hwfy.fsf@assigned-by-dhcp.cox.net","threadId":"7545","inReplyTo":"8c5c35580704061653x7e5fd149ud31a8289a4508b54@mail.gmail.com","subject":"Re: [PATCH] rename_ref(): only print a warning when config-file update fails","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-04-07T00:14:57Z","receivedAt":"2007-04-07T00:14:57Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Lars Hjemli\" <hjemli@gmail.com> writes:\n\n>> I wonder if rolling back the rename that was asked is an\n>> option.  We would want to keep these low-level things atomic\n>> whenever possible.\n>\n> I was wondering the same thing, i.e. \"goto rollback\" as an option for\n> \"error()\". But I ended up thinking that rename_ref() shouldn't bother\n> with the config file at all (thus my other patch).\n\nI agree that \"other patch\" is sensible regardless.\n"}]}