When you have docblocks above multiple functions removing a function creates a sub-optimal patch.
index.js:
/**
* Function foo description.
*/
function foo() {}
/**
* Function bar description.
*/
function bar() {}
Removing function foo with its docblock generates the following patch:
diff --git a/index.js b/index.js
index f4e18ef..933004f 100644
--- a/index.js
+++ b/index.js
@@ -1,9 +1,4 @@
/**
- * Function foo description.
- */
-function foo() {}
-
-/**
* Function bar description.
*/
function bar() {}
This means that any merge that brings with it commits that touch the space between function foo and function bar now result in a conflict.
For example imagine we created a branch feature-1
before removing foo, and in index.js
added a function foobar
between the two. The conflict would look as follows:
/**
<<<<<<< HEAD
=======
* Function foo description.
*/
function foo() {}
/**
* Function foobar description.
*/
function foobar() {}
/**
>>>>>>> feature-1
* Function bar description.
*/
function bar() {}
I imagine there would be no issue if the /**
was grabbed from the top instead. I'm sure there's a good reason for git to prefer removing from the end but I'd like to force it to grab it from the start. Is there a way to easily do this? Or is manual patch editing the only way?