gitflow-avh icon indicating copy to clipboard operation
gitflow-avh copied to clipboard

The "git flow {bugfix,feature} delete <name>" command orphans child branches with no warning

Open jkankiewicz opened this issue 5 years ago • 0 comments

Ideally every bugfix/feature branch should be based upon the develop branch but the git flow {bugfix,feature} start <name> command does support an optional <base> argument for when it shouldn't. When the bugfix/feature branch identified by that <base> argument is deleted before the child branch identified by the <name> argument is finished, the .git/config file will still contain an invalid reference to the former branch within the latter branch's section and the git flow {bugfix/feature} delete command will not even output a warning that the child branch's base reference is now invalid. For example,

$ git flow feature start parent
Switched to a new branch 'feature/parent'

Summary of actions:
- A new branch 'feature/parent' was created, based on 'develop'
- You are now on branch 'feature/parent'

Now, start committing on your feature. When done, use:

     git flow feature finish parent

$ git flow feature start child feature/parent
Switched to a new branch 'feature/child'

Summary of actions:
- A new branch 'feature/child' was created, based on 'feature/parent'
- You are now on branch 'feature/child'

Now, start committing on your feature. When done, use:

     git flow feature finish child

$ git flow feature delete parent
Deleted branch feature/parent (was ecb52f56).

Summary of actions:
- Feature branch 'feature/parent' has been deleted.
- You are now on branch 'feature/child'

$ cat .git/config
...
[gitflow "branch.feature/child"]
	base = feature/parent
...
$ git flow feature finish child
Fatal: The base 'feature/parent' doesn't exists locally or is not a branch. Can't finish the feature branch 'feature/child'.

At the very least the git flow {bugfix,feature} delete <name> command should output warnings for every bugfix/feature branch that has been orphaned by their parent branch's deletion but it would be even safer for the command's invocation to fail and output the list of child branches that would be orphaned as the reason for its failure.

To enable the parent branch's deletion, the user would first have to rebase all of the listed child branches upon a new parent using the git flow {bugfix/feature} rebase <name> --base <base> command (#407).

jkankiewicz avatar Mar 03 '20 19:03 jkankiewicz