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

Re: bug deleting "unmerged" branch (2.12.3)

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 29, 2017, 00:58 UTC
Message-ID
<xmqqtvxd6gu9.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<5A1D70FD020000A100029137@gwsmtp1.uni-regensburg.de>
"Ulrich Windl" <Ulrich.Windl@rz.uni-regensburg.de> writes:
> I think if more than one branches are pointing to the same commit,
> one should be allowed to delete all but the last one without
> warning. Do you agree?

That comes from a viewpoint that the only purpose "branch -d" exists in addition to "branch -D" is to protect objects from "gc". Those who added the safety feature may have shared that view originally, but it turns out that it protects another important thing you are forgetting.

Imagine that two topics, 'topicA' and 'topicB', were independently forked from 'master', and then later we wanted to add a feature that depends on these two topics. Since the 'feature' forked, there may have been other developments, and we ended up in this topology:

    ---o---o---o---o---o---M
        \   \          
         \   o---A---o---F
          \         /  
           o---o---o---o---B

where A, B and F are the tips of 'topicA', 'topicB' and 'feature' branches right now [*1*].

Now imagine we are on 'master' and just made 'topicB' graduate. We would have this topology.

    ---o---o---o---o---o---o---M
        \   \                 /
         \   o---A---o---F   /
          \         /       /
           o---o---o---o---B

While we do have 'topicA' and 'feature' branches still in flight, we are done with 'topicB'. Even though the tip of 'topicA' is reachable from the tip of 'feature', the fact that the branch points at 'A' is still relevant. If we lose that information right now, we'd have to go find it when we (1) want to further enhance the topic by checking out and building on 'topicA', and (2) want to finally get 'topicA' graduate to 'master'.

Because removal of a topic (in this case 'topicB') is often done after a merge of that topic is made into an integration branch, "branch -d" that protects branches that are yet to be merged to the current branch catches you if you said "branch -d topic{A,B}" (or other equivalent forms, most likely you'd have a script that spits out list of branches and feed it to "xargs branch -d").

So, no, I do not agree.
[Footnotes]
*1* Since the 'feature' started developing, there were a few commits
    added to 'topicB' but because the feature does not depend on
    these enhancements to that topic, B is ahead of the commit that
    was originally merged with the tip of 'topicA' to form the
    'feature' branch.
Previous: Philip OakleyNext: Ulrich Windl
Message 6 of 14 in “bug deleting "unmerged" branch (2.12.3)”
  1. Ulrich WindlNov 28, 2017
  2. Johannes SchindelinNov 28, 2017
  3. Antw: Re: bug deleting "unmerged" branch (2.12.3)Ulrich Windl, Nov 29, 2017
  4. Johannes SchindelinNov 29, 2017
  5. Philip OakleyDec 2, 2017
  6. Junio C HamanoNov 29, 2017
  7. Antw: Re: bug deleting "unmerged" branch (2.12.3)Ulrich Windl, Nov 29, 2017
  8. Philip OakleyDec 2, 2017
  9. Junio C HamanoDec 3, 2017
  10. Philip OakleyDec 3, 2017
  11. Antw: Re: bug deleting "unmerged" branch (2.12.3)Ulrich Windl, Dec 4, 2017
  12. Philip OakleyDec 8, 2017
  13. Antw: Re: Re: bug deleting "unmerged" branch (2.12.3)Ulrich Windl, Dec 11, 2017
  14. Philip OakleyDec 12, 2017

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.