git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Fix renaming branch without config file

From
GBGeert Bosch <bosch@gnat.com>
Date
Apr 5, 2007, 14:20 UTC
Message-ID
<20070405144359.4B8832A7C67@potomac.gnat.com>

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 <bosch@gnat.com>
---
 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
Next: Johannes Schindelin
Message 1 of 5 in “Fix renaming branch without config file”
  1. Fix renaming branch without config fileGeert Bosch, Apr 5, 2007
  2. Johannes SchindelinApr 5, 2007
  3. Geert BoschApr 5, 2007
  4. Johannes SchindelinApr 5, 2007
  5. Geert BoschApr 6, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.