git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rename_ref(): only print a warning when config-file update fails
@ 2007-04-06  8:33 Lars Hjemli
  2007-04-06 10:35 ` Geert Bosch
  2007-04-06 20:35 ` Junio C Hamano
  0 siblings, 2 replies; 5+ messages in thread
From: Lars Hjemli @ 2007-04-06  8:33 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Geert Bosch, Johannes Schindelin, git

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:
> 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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] rename_ref(): only print a warning when config-file update fails
  2007-04-06  8:33 [PATCH] rename_ref(): only print a warning when config-file update fails Lars Hjemli
@ 2007-04-06 10:35 ` Geert Bosch
  2007-04-06 20:35 ` Junio C Hamano
  1 sibling, 0 replies; 5+ messages in thread
From: Geert Bosch @ 2007-04-06 10:35 UTC (permalink / raw)
  To: Lars Hjemli; +Cc: Junio C Hamano, Johannes Schindelin, git


On Apr 6, 2007, at 04:33, Lars Hjemli wrote:
> 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>

This makes sense in addition to my patch, if the renaming
fails for any of the other possible reasons.

   -Geert

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] rename_ref(): only print a warning when config-file update fails
  2007-04-06  8:33 [PATCH] rename_ref(): only print a warning when config-file update fails Lars Hjemli
  2007-04-06 10:35 ` Geert Bosch
@ 2007-04-06 20:35 ` Junio C Hamano
  2007-04-06 23:53   ` Lars Hjemli
  1 sibling, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2007-04-06 20:35 UTC (permalink / raw)
  To: Lars Hjemli; +Cc: Geert Bosch, Johannes Schindelin, git

Lars Hjemli <hjemli@gmail.com> writes:

> 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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] rename_ref(): only print a warning when config-file update fails
  2007-04-06 20:35 ` Junio C Hamano
@ 2007-04-06 23:53   ` Lars Hjemli
  2007-04-07  0:14     ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Lars Hjemli @ 2007-04-06 23:53 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Geert Bosch, Johannes Schindelin, git

On 4/6/07, Junio C Hamano <junkio@cox.net> wrote:
> Lars Hjemli <hjemli@gmail.com> writes:
>
> > 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).

-- 
larsh

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] rename_ref(): only print a warning when config-file update fails
  2007-04-06 23:53   ` Lars Hjemli
@ 2007-04-07  0:14     ` Junio C Hamano
  0 siblings, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2007-04-07  0:14 UTC (permalink / raw)
  To: Lars Hjemli; +Cc: Junio C Hamano, Geert Bosch, Johannes Schindelin, git

"Lars Hjemli" <hjemli@gmail.com> writes:

>> 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).

I agree that "other patch" is sensible regardless.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-04-07  0:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-06  8:33 [PATCH] rename_ref(): only print a warning when config-file update fails Lars Hjemli
2007-04-06 10:35 ` Geert Bosch
2007-04-06 20:35 ` Junio C Hamano
2007-04-06 23:53   ` Lars Hjemli
2007-04-07  0:14     ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).