rename_ref(): only print a warning when config-file update fails
PATCH 1/1 rename_ref(): only print a warning when config-file update fails
If git_config_rename_section() fails, rename_ref() used to return 1, which left HEAD pointing to an absent refs/heads file (since the actual renaming had already occurred).
---
Quoted 7 lines · Johannes Schindelin
Hi,
Quoted 2 lines · Geert Bosch
Make
git_config_rename_sectionreturn success if no config file exists.
Quoted 8 lines
I don't think this is correct.
git_config_rename_section()_should_ return an error.Quoted 2 lines
Otherwise, renaming a branch would abort, leaving the repository in an inconsistent state.
This should take the hint from --rename-section, and print a warning (or not).
I think both arguments makes sense. There really is no reason to abort the rename operation if the config file update fails (for any reason).
refs.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
refs.c +1 -1
@@ -835,7 +835,7 @@ int rename_ref(const char *oldref, const char *newref, const char *logmsg)snprintf (oldsection,1024 ,"branch.%s" , oldref +11 );snprintf (newsection,1024 ,"branch.%s" , newref +11 );if (git_config_rename_section (oldsection, newsection) <0 ) -return 1 ; +error ("unable to update config-file" ); }return 0 ;
Signature · 1 line
1.5.1.53.g77e6f
Quoted 5 lines · Lars Hjemli
If
git_config_rename_section()fails,rename_ref()used to return 1, which left HEAD pointing to an absent refs/heads file (since the actual renaming had already occurred).Signed-off-by Lars Hjemli <[email protected]>
This makes sense in addition to my patch, if the renaming fails for any of the other possible reasons.
-Geert
Quoted 3 lines · Lars Hjemli
If
git_config_rename_section()fails,rename_ref()used to return 1, which left HEAD pointing to an absent refs/heads file (since the actual renaming had already occurred).
I wonder if rolling back the rename that was asked is an option. We would want to keep these low-level things atomic whenever possible.
Quoted 9 lines · Junio C Hamano
Quoted 3 lines · Lars Hjemli
If
git_config_rename_section()fails,rename_ref()used to return 1, which left HEAD pointing to an absent refs/heads file (since the actual renaming had already occurred).I wonder if rolling back the rename that was asked is an option. We would want to keep these low-level things atomic whenever possible.
I was wondering the same thing, i.e. "goto rollback" as an option for "error()". But I ended up thinking that rename_ref() shouldn't bother with the config file at all (thus my other patch).
Signature · 1 line
larsh
Quoted 7 lines · Lars Hjemli
Quoted 3 lines
I wonder if rolling back the rename that was asked is an option. We would want to keep these low-level things atomic whenever possible.
I was wondering the same thing, i.e. "goto rollback" as an option for "
error()". But I ended up thinking thatrename_ref()shouldn't bother with the config file at all (thus my other patch).
I agree that "other patch" is sensible regardless.