Fixes #5361 - Simplify repo-merge.sh by using function instead of duplicated code

Fixes #5361 - Simplify repo-merge.sh by using function instead of duplicated code

cf http://www.rudder-project.org/redmine/issues/5361