Thread (5 messages) flat view 5 messages, 2 authors, 2016-06-15
DORMANTno replies

[PATCH] Fix renaming branch without config file

From: Geert Bosch <hidden>
Date: 2016-06-15 22:43:03
Subsystem: the rest · Maintainer: Linus Torvalds

Make git_config_rename_section return success if no config file
exists.  Otherwise, renaming a branch would abort, leaving the
repository in an inconsistent state.

Signed-off-by: Geert Bosch <redacted>
---
 config.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/config.c b/config.c
index 6479855..70d1055 100644
--- a/config.c
+++ b/config.c
@@ -916,8 +916,8 @@ int git_config_rename_section(const char *old_name, const char *new_name)
 	}
 
 	if (!(config_file = fopen(config_filename, "rb"))) {
-		ret = error("Could not open config file!");
-		goto out;
+		/* no config file means nothing to rename, no error */
+		goto unlock_and_out;
 	}
 
 	while (fgets(buf, sizeof(buf), config_file)) {
@@ -951,6 +951,7 @@ int git_config_rename_section(const char *old_name, const char *new_name)
 		}
 	}
 	fclose(config_file);
+ unlock_and_out:
 	if (close(out_fd) || commit_lock_file(lock) < 0)
 			ret = error("Cannot commit config file!");
  out:
-- 
1.4.5-rc0.GIT
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help