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

[PATCH] rename_ref(): only print a warning when config-file update fails

From
LHLars Hjemli <hjemli@gmail.com>
Date
Apr 6, 2007, 08:33 UTC
Message-ID
<11758483861506-git-send-email-hjemli@gmail.com>

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 <hjemli@gmail.com>
---
On 4/5/07, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
Show 15 quoted lines
> Hi,
> 
> On Thu, 5 Apr 2007, Geert Bosch wrote:
> 
> > Make git_config_rename_section return success if no config file
> > exists.
> 
> I don't think this is correct. git_config_rename_section() _should_ return
> an error.
> 
> > 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(-)
diff --git a/refs.c b/refs.c
index f471152..2ac6384 100644
--- a/refs.c
+++ b/refs.c
@@ -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;
-- 
1.5.1.53.g77e6f
Next: Geert Bosch
Message 1 of 5 in “rename_ref(): only print a warning when config-file update fails”
  1. rename_ref(): only print a warning when config-file update failsLars Hjemli, Apr 6, 2007
  2. Geert BoschApr 6, 2007
  3. Junio C HamanoApr 6, 2007
  4. Lars HjemliApr 6, 2007
  5. Junio C HamanoApr 7, 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.