{"thread":{"id":"10587","subject":"[PATCH] Mention that git-branch -M can cause problems for tracking branches","startedAt":"2007-11-02T09:17:34Z","lastAt":"2007-11-02T22:30:53Z","messageCount":4,"participants":["Jonas Fonseca","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"57944","messageId":"20071102091734.GC10141@diku.dk","threadId":"10587","inReplyTo":null,"subject":"[PATCH] Mention that git-branch -M can cause problems for tracking branches","fromName":"Jonas Fonseca","fromEmail":"fonseca@diku.dk","sentAt":"2007-11-02T09:17:34Z","receivedAt":"2007-11-02T09:17:34Z","isPatch":true,"sender":{"key":"fonseca@diku.dk","avatar":"https://gravatar.com/avatar/f82f3ad698717c51873b020c750a92438c820a24056dc39fe4d07baa10a92264?d=mp&s=160"},"body":"Signed-off-by: Jonas Fonseca <fonseca@diku.dk>\n---\n Documentation/git-branch.txt |    5 +++++\n 1 files changed, 5 insertions(+), 0 deletions(-)\n\n I made a patch to discard the overwritten branch's configuration\n section, which Spearce felt was too lossy a behaviour. However, since\n it confused me, I think it should at least be mentioned in the manpage.\n Maybe the warning message from git should also be added to improve its\n \"googlability\".\n\ndiff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt\nindex 5e81aa4..def4e85 100644\n--- a/Documentation/git-branch.txt\n+++ b/Documentation/git-branch.txt\n@@ -165,6 +165,11 @@ If you are creating a branch that you want to immediately checkout, it's\n easier to use the git checkout command with its `-b` option to create\n a branch and check it out with a single command.\n \n+When a branch is renamed so that it overwrites an existing branch unintended\n+problems can arise. This is because git refuses to discard the configuration\n+section of the overwritten branch. As a result git can become confused if, for\n+example, the branches involved were used for tracking two different remote\n+branches. The only way to fix this is to edit the configuration file manually.\n \n Author\n ------\n-- \n1.5.3.4.1481.g854da-dirty\n\n-- \nJonas Fonseca\n"},{"id":"58032","messageId":"7vlk9g1k1q.fsf@gitster.siamese.dyndns.org","threadId":"10587","inReplyTo":"20071102091734.GC10141@diku.dk","subject":"Re: [PATCH] Mention that git-branch -M can cause problems for tracking branches","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-02T20:14:57Z","receivedAt":"2007-11-02T20:14:57Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jonas Fonseca <fonseca@diku.dk> writes:\n\n> Signed-off-by: Jonas Fonseca <fonseca@diku.dk>\n> ---\n>  Documentation/git-branch.txt |    5 +++++\n>  1 files changed, 5 insertions(+), 0 deletions(-)\n>\n>  I made a patch to discard the overwritten branch's configuration\n>  section, which Spearce felt was too lossy a behaviour. However, since\n>  it confused me, I think it should at least be mentioned in the manpage.\n>  Maybe the warning message from git should also be added to improve its\n>  \"googlability\".\n>\n> diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt\n> index 5e81aa4..def4e85 100644\n> --- a/Documentation/git-branch.txt\n> +++ b/Documentation/git-branch.txt\n> @@ -165,6 +165,11 @@ If you are creating a branch that you want to immediately checkout, it's\n>  easier to use the git checkout command with its `-b` option to create\n>  a branch and check it out with a single command.\n>  \n> +When a branch is renamed so that it overwrites an existing branch unintended\n> +problems can arise. This is because git refuses to discard the configuration\n> +section of the overwritten branch. As a result git can become confused if, for\n> +example, the branches involved were used for tracking two different remote\n> +branches. The only way to fix this is to edit the configuration file manually.\n\nI do not understand this bit about \"refuse\".\n\n - To \"refuse to discard\", somebody has to ask to discard ---\n   who asks so and when?\n\n - Is there a reason to \"refuse\" when such a removal request is\n   made?  If so, what is it?  If not, why refusal?\n"},{"id":"58045","messageId":"20071102220411.GA13666@diku.dk","threadId":"10587","inReplyTo":"7vlk9g1k1q.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] Mention that git-branch -M can cause problems for tracking branches","fromName":"Jonas Fonseca","fromEmail":"fonseca@diku.dk","sentAt":"2007-11-02T22:04:11Z","receivedAt":"2007-11-02T22:04:11Z","isPatch":true,"sender":{"key":"fonseca@diku.dk","avatar":"https://gravatar.com/avatar/f82f3ad698717c51873b020c750a92438c820a24056dc39fe4d07baa10a92264?d=mp&s=160"},"body":"Junio C Hamano <gitster@pobox.com> wrote Fri, Nov 02, 2007:\n> Jonas Fonseca <fonseca@diku.dk> writes:\n> \n> > Signed-off-by: Jonas Fonseca <fonseca@diku.dk>\n> > ---\n> >  Documentation/git-branch.txt |    5 +++++\n> >  1 files changed, 5 insertions(+), 0 deletions(-)\n> >\n> >  I made a patch to discard the overwritten branch's configuration\n> >  section, which Spearce felt was too lossy a behaviour. However, since\n> >  it confused me, I think it should at least be mentioned in the manpage.\n> >  Maybe the warning message from git should also be added to improve its\n> >  \"googlability\".\n> >\n> > diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt\n> > index 5e81aa4..def4e85 100644\n> > --- a/Documentation/git-branch.txt\n> > +++ b/Documentation/git-branch.txt\n> > @@ -165,6 +165,11 @@ If you are creating a branch that you want to immediately checkout, it's\n> >  easier to use the git checkout command with its `-b` option to create\n> >  a branch and check it out with a single command.\n> >  \n> > +When a branch is renamed so that it overwrites an existing branch unintended\n> > +problems can arise. This is because git refuses to discard the configuration\n> > +section of the overwritten branch. As a result git can become confused if, for\n> > +example, the branches involved were used for tracking two different remote\n> > +branches. The only way to fix this is to edit the configuration file manually.\n> \n> I do not understand this bit about \"refuse\".\n> \n>  - To \"refuse to discard\", somebody has to ask to discard ---\n>    who asks so and when?\n\nIMO, the user asks when using git-branch -M. And in case it is not clear\nthe problem arises for the command sequence:\n\n\t$ git branch --track o-next origin/next\n\t$ git branch --track m-next madcoder/next\n\t$ git branch -M o-next m-next\n\t$ git remote\n\tWarning: more than one branch.m-next.remote\n\t...\n\n>  - Is there a reason to \"refuse\" when such a removal request is\n>    made?  If so, what is it?  If not, why refusal?\n\nPersonally, I don't see why we need to refuse, since git-branch -M is\nsomewhat similar to saying -m (rename) plus adding a \"force\" flag\nmeaning: \"yes, I know that this will potentially throw away settings for\nan already existing branch\".\n\nThe main reason to \"refuse\" the removal is that for the general case,\ne.g. when using `git-config --rename-section`, this can potentially lead\nto loss of valuable config settings. This was pointed out by Shawn in\nhis reply to my patch[0]. I agreed to this in my follow-up and asked if\nit would be acceptable to add an additional flag to so that git-branch\ncan switch on this request for removal.\n\n[0] http://thread.gmane.org/gmane.comp.version-control.git/61291\n\n-- \nJonas Fonseca\n"},{"id":"58049","messageId":"7vodecz3du.fsf@gitster.siamese.dyndns.org","threadId":"10587","inReplyTo":"20071102220411.GA13666@diku.dk","subject":"Re: [PATCH] Mention that git-branch -M can cause problems for tracking branches","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-02T22:30:53Z","receivedAt":"2007-11-02T22:30:53Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jonas Fonseca <fonseca@diku.dk> writes:\n\n> The main reason to \"refuse\" the removal is that for the general case,\n> e.g. when using `git-config --rename-section`, this can potentially lead\n> to loss of valuable config settings. This was pointed out by Shawn in\n> his reply to my patch[0]. I agreed to this in my follow-up and asked if\n> it would be acceptable to add an additional flag to so that git-branch\n> can switch on this request for removal.\n\nSo when you rename branch.foo section to branch.bar, instead of\nreplacing the whole existing branch.bar with what used to be in\nbranch.foo, you _append_ that to branch.bar?\n\nThat sounds insane.\n\nWhat good does it do to keep what used to be branch.bar?  The\nold contents in the section are by no means \"valuable\".  They\nwere about 'bar' and do not even have anything to do with the\nbranch being renamed, which used to be called 'foo'.\n\nShawn's example of modifying multi-valued variable is\nirrelevant.  Over there, we have options to replace everything\nor append to it, don't we?\n\nIf the option is --rename-section, that is \"rename section\", not\n\"merge section\".  If for some reason a merge section operation\nis needed, that should be supplied in a separate patch, but for\nthe branch renaming I really do not see the need for it.\n"}]}