Git Merging Guide

From Funtoo
Jump to navigation Jump to search

This page is here to show Funtoo Linux developers different techniques that can be used to merge various things.

Comparing Experimental and Master

The best way to get a quick and dirty understanding of the differences between experimental and master is to do this:

root # cd /root/git/funtoo-overlay
root # git diff --stat origin/master origin/experimental

This will show a summary of what modifications where made on a file-by-file basis.

Package Replacement: Funtoo Overlay (branch to branch)

When merging in funtoo-overlay, we might want to merge things from experimental to master. To do this, first pick a specific package to compare changes:

root # cd /root/git/funtoo-overlay
root # git diff --stat origin/master origin/experimental app-shells/bash
 app-shells/bash/bash-3.1_p17.ebuild   |  150 -------------------------
 app-shells/bash/bash-3.2_p51.ebuild   |  199 ---------------------------------
 app-shells/bash/bash-4.0_p37.ebuild   |  193 --------------------------------
 app-shells/bash/bash-4.0_p38.ebuild   |  193 --------------------------------
 app-shells/bash/bash-4.1_p10.ebuild   |  191 -------------------------------
 app-shells/bash/bash-4.1_p7-r1.ebuild |  189 -------------------------------
 app-shells/bash/bash-4.1_p9-r1.ebuild |  189 -------------------------------
 app-shells/bash/bash-4.2_p10.ebuild   |    5 +-
 8 files changed, 2 insertions(+), 1307 deletions(-)

The "----" in the diff above shows that several ebuilds were removed ("----" means many lines were removed) in the experimental branch, and bash-4.2_p10.ebuild had slight modifications. This looks like a good candidate for grabbing from experimental to replace entirely what is in master. Here's an example of something that is not a good candidate for a wholesale replacement:

root # git diff --stat origin/master origin/experimental sys-apps/pciutils
 sys-apps/pciutils/Manifest                         |    3 -
 sys-apps/pciutils/files/conf.d-pciparm             |   28 -------
 sys-apps/pciutils/files/init.d-pciparm             |   80 --------------------
 .../files/pciutils-3.1.4-install-lib.patch         |   40 ----------
 sys-apps/pciutils/files/pciutils-3.1.7-fbsd.patch  |   11 ---
 .../files/pciutils-3.1.7-install-lib.patch         |   41 ----------
 .../pciutils-3.1.8-avoid-segfault-on-init.patch    |   16 ----
 sys-apps/pciutils/files/pciutils.cron              |    2 -
 sys-apps/pciutils/pciutils-3.1.8-r1.ebuild         |   76 -------------------
 9 files changed, 0 insertions(+), 297 deletions(-)

In this example above, sys-apps/pciutils had a lot of cleanups in experimental, but the output above indicates that there is a new pciutils-3.1.8-1.ebuild in master that is not experimental. If we replace what is in master with that in experimental, we will lose the new ebuild! So we wouldn't want to do a wholesale replacement in this case. Old ebuilds that disappear are cleanups, but new ebuilds that disappear are not. Be sure to pay attention to whether the ebuilds that are being removed are old or new.

Back to our bash example. To inspect changes in more detail to make sure they are acceptable, specify the modified ebuild directly and drop the --stat option:

root # git diff origin/master origin/experimental app-shells/bash/bash-4.2_p10.ebuild
diff --git a/app-shells/bash/bash-4.2_p10.ebuild b/app-shells/bash/bash-4.2_p10.ebuild
index 0c497ea..e603c15 100644
--- a/app-shells/bash/bash-4.2_p10.ebuild
+++ b/app-shells/bash/bash-4.2_p10.ebuild
@@ -37,7 +37,7 @@ SRC_URI="mirror://gnu/bash/${MY_P}.tar.gz $(patches)
 
 LICENSE="GPL-3"
 SLOT="0"
-KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~sparc-fbsd ~x86-fbsd"
+KEYWORDS="*"
 IUSE="afs bashlogger examples mem-scramble +net nls plugins vanilla"
 
 DEPEND=">=sys-libs/ncurses-5.2-r2
@@ -69,7 +69,6 @@ src_unpack() {
        cd lib/readline
        [[ ${READLINE_PLEVEL} -gt 0 ]] && epatch $(patches -s ${READLINE_PLEVEL} readline ${READLINE_VER})
        cd ../..
-       
        epatch "${FILESDIR}"/${PN}-4.1-document-system-bashrc.patch
 }
 
@@ -104,7 +103,7 @@ src_compile() {
        myconf="${myconf} --with-curses"
 
        myconf="${myconf} --without-lispdir" #335896
-       
+
        use plugins && append-ldflags -Wl,-rpath,/usr/$(get_libdir)/bash
        econf \
                $(use_with afs) \

OK, these look like changes we want to merge into the master branch. Actually, we want to basically 'adopt' all these bash changes into master -- a wholesale import so that app-shells/bash in master looks exactly like that in experimental. To do this, we want to wipe out what is currently in the master branch related to app-shells/bash, and replace it entirely with the exact contents of app-shells/bash in the experimental branch.

This can be done as follows:

root # git rm -rf app-shells/bash
root # git checkout origin/experimental -- app-shells/bash

Now, let's review the changes git made. These are not yet committed:

root # git diff --cached --stat
 app-shells/bash/bash-3.1_p17.ebuild   |  150 -------------------------
 app-shells/bash/bash-3.2_p51.ebuild   |  199 ---------------------------------
 app-shells/bash/bash-4.0_p37.ebuild   |  193 --------------------------------
 app-shells/bash/bash-4.0_p38.ebuild   |  193 --------------------------------
 app-shells/bash/bash-4.1_p10.ebuild   |  191 -------------------------------
 app-shells/bash/bash-4.1_p7-r1.ebuild |  189 -------------------------------
 app-shells/bash/bash-4.1_p9-r1.ebuild |  189 -------------------------------
 app-shells/bash/bash-4.2_p10.ebuild   |    5 +-
 8 files changed, 2 insertions(+), 1307 deletions(-)

Looks good. These changes are already staged for commit -- notice the --cached option above. If you don't use --cached, you won't see any changes, because they're already cached for commit. Let's commit them:

root # git commit -m "bash updates from experimental"
root # git push origin master

If we made any local changes to existing files that had not yet been added, and wanted to include those with the commit, we could use the -a option with git commit, above. Once the commit has been made, you should no longer see anything related to app-shells/bash listed when doing a diff of the branches.