Difference between pages "Package:Whenjobs" and "Git Merging Guide"

(Difference between pages)
 
 
Line 1: Line 1:
{{Ebuild
+
This page is here to show Funtoo Linux developers different techniques that can be used to merge various things.
|Summary=A cron daemon replacement that is powerful, yet simple.
+
|CatPkg=sys-process/whenjobs
+
|Maintainer=Golodhrim,
+
|Repository=Funtoo Overlay
+
}}
+
{{fancywarning|This document is a work in progress, as we are still investigating whenjobs for funtoo usage. For information about it see Funtoo tickets about [http://bugs.funtoo.org/browse/FL-316 whenjobs], [http://bugs.funtoo.org/browse/FL-337 initscript], [http://bugs.funtoo.org/browse/FL-338 User Feedback] and [http://bugs.funtoo.org/browse/FL-351 this document].}}
+
== What are whenjobs? ==
+
  
Whenjobs was written by Richard Jones from [http://www.redhat.com RedHat Linux]. Whenjobs is designed to be a cron daemon replacement with some improvements over normal cron-jobs. Further, we have added some improvements to Whenjobs. Whenjobs gives users a more simple syntax for jobs to run and, with Funtoo improvements, an effective user-management option for whenjobs -- that way we fixed the default behaviour of whenjobs to not been able to run as root and let us execute the daemon on a per-user basis by default.
+
== Comparing Experimental and Master ==
  
=== Questions for help and testing ===
+
The best way to get a quick and dirty understanding of the differences between experimental and master is to do this:
 
+
We would like to get your feedback to [http://bugs.funtoo.org/browse/FL-338 FL-338]. So, please test and report your experience with whenjobs.
+
 
+
== How to install whenjobs ==
+
 
+
The installation of {{Package|sys-process/whenjobs}} is really easy, just merge it:
+
  
 
<console>
 
<console>
###i## emerge -avt whenjobs
+
# ##i##cd /root/git/funtoo-overlay
 +
# ##i##git diff --stat origin/master origin/experimental
 
</console>
 
</console>
  
== How to get started ==
+
This will show a summary of what modifications where made on a file-by-file basis.
  
As mentioned above, we added a user-management feature. Also, whenjobs has a changed syntax compared to normal cronjobs -- we will discuss that now.
+
== Package Replacement: Funtoo Overlay (branch to branch) ==
  
=== User management ===
+
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:
  
The user management for whenjobs is done with a single file located at <tt>/etc/whenjobs.users.conf</tt>. Just add a user to that file by a comma seperated list like:
+
<console>
 +
# ##i##cd /root/git/funtoo-overlay
 +
# ##i##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(-)</console>
  
<pre>
+
The "----" in the diff above shows that several ebuilds were removed ("----" means many lines were removed) in the experimental branch, and <tt>bash-4.2_p10.ebuild</tt> 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,user1,user2,user3
+
</pre>
+
 
+
where user1-user3 must be system-usernames, as they are checked. Please do not add any other lines to that file, as there is no way for comments in the file. In addition, adding other lines will break whenjobs -- you will not be able to start the daemon later. Currently, there is no initscript, but we are working on one and that initscript will then use that file in the same way.
+
 
+
=== whenjobs commands ===
+
 
+
There are some basic commands for whenjobs you should be aware of before we get to explain the script syntax for whenjobs:
+
 
+
To edit/list a job script, use:
+
  
 
<console>
 
<console>
# ##i##whenjobs -e | --edit
+
# ##i##git diff --stat origin/master origin/experimental sys-apps/pciutils
# ##i##whenjobs -l | --list
+
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(-)
 
</console>
 
</console>
  
in the above case we added both the short and long version in one line so please use either the '''-e''' or the '''--edit''' version as there is no piping done at that part. We will use the same syntax for further examples if there are multiple ways of calling the function we need.
+
In this example above, <tt>sys-apps/pciutils</tt> had a lot of cleanups in experimental, but the output above indicates that there is a new <tt>pciutils-3.1.8-1.ebuild</tt> 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.
  
Another import part is to set or get variables we want to set or set in whenjobs, that can be done with:
+
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 <tt>--stat</tt> option:
  
 
<console>
 
<console>
to get a variable:
+
# ##i##git diff origin/master origin/experimental app-shells/bash/bash-4.2_p10.ebuild
###i## whenjobs --get variable
+
diff --git a/app-shells/bash/bash-4.2_p10.ebuild b/app-shells/bash/bash-4.2_p10.ebuild
to set a variable or multiple varibles:
+
index 0c497ea..e603c15 100644
###i## whenjobs --set variable=value [variable=value ...]
+
--- a/app-shells/bash/bash-4.2_p10.ebuild
and to display all set variables:
+
+++ b/app-shells/bash/bash-4.2_p10.ebuild
###i## whenjobs --variables
+
@@ -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) \
 
</console>
 
</console>
  
Another important function in whenjobs is the way to start, stop and request the status of the per-user daemon:
+
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 <tt>app-shells/bash</tt> 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 <tt>app-shells/bash</tt>, and replace it entirely with the exact contents of <tt>app-shells/bash</tt> in the experimental branch.
<console>
+
 
# ##i##whenjobs --daemon-start
+
This can be done as follows:
# ##i##whenjobs --daemon-stop
+
# ##i##whenjobs --daemon-status
+
# ##i##whenjobs --daemon-restart
+
</console>
+
  
Finally we have the ability to inspect running jobs:
 
 
<console>
 
<console>
# ##i##whenjobs --jobs
+
# ##i##git rm -rf app-shells/bash
# ##i##whenjobs --cancel serial
+
# ##i##git checkout origin/experimental -- app-shells/bash
# ##i##whenjobs --start "name"
+
# ##i##whenjobs --tail serial
+
 
</console>
 
</console>
  
=== How to get started with whenjobs now ===
+
Now, let's review the changes git made. These are not yet committed:
 
+
First edit the above mentioned <tt>whenjobs.users.conf</tt> file if not already done and start a daemon on a per-user basis with
+
 
+
 
<console>
 
<console>
# ##i##whenjobs --daemon-start
+
# ##i##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(-)
 
</console>
 
</console>
  
Thats all for starting whenjobs and now we have time to write some whenjobs-scripts. We will use here some basic examples nothing for real time usage but it should be able to give you the impression on how to write your own scripts and use the variables in the later process. First we need to edit our whenjobs-script. This can be done by two ways:
+
Looks good. These changes are already staged for commit -- notice the <tt>--cached</tt> option above. If you don't use <tt>--cached</tt>, you won't see any changes, because they're already cached for commit. Let's commit them:
  
 
<console>
 
<console>
Version A) (manual way, not recommended)
+
# ##i##git commit -m "bash updates from experimental"
# ##i##EDITOR ~/.whenjobs/jobs.ml
+
# ##i##git push origin master
Edit the file with the scripts you want to use and save it, but after that you need to upload it so that whenjobs knows about it
+
# ##i##whenjobs --upload
+
Version B) (automatically by whenjobs, recommended)
+
# ##i##whenjobs -e  | --edit
+
just save your script now and whenjobs will upload it automatically for you.
+
 
</console>
 
</console>
  
So far we are now fine with getting to the scripts, next let us add some basics. We will now start with a periodic call, like if we would like to check out load everyage every 10 minutes we would do it like this:
+
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 <tt>-a</tt> option with <tt>git commit</tt>, above. Once the commit has been made, you should no longer see anything related to <tt>app-shells/bash</tt> listed when doing a diff of the branches.
 
+
{{fancywarning|A note aside, the scripts are real shell scripts, so parts beginning with a '''#''' are comments and parts without are the shell script commands that are executed!}}
+
 
+
<source lang="ocaml">
+
every 10 minutes :
+
<<
+
  # Get the current load average.
+
  load=`awk '{print $1}' /proc/loadavg`
+
  whenjobs --set --type float load=$load
+
>>
+
</source>
+
 
+
The power of whenjobs comes in game when you would like to base on a variable you set somewhere else:
+
 
+
<source lang="ocaml">
+
when load >= 6 :
+
<<
+
  mail -s "ALERT: high load average: $load" MAILADDRESS < /dev/null
+
>>
+
</source>
+
 
+
That part will notify a user via email when his load average is greater or equal to 6, as when statements are "edge-triggered".
+
 
+
The '''--type''' switch above for setting a variable can be one of '''bool, int, float, string or unit'''
+
 
+
==== Periodic expressions ====
+
 
+
For periodic expressions you have to use the following syntax
+
 
+
<source lang="ocaml">
+
every <period> :
+
<<
+
  # shell script
+
>>
+
</source>
+
 
+
where '''<period>''' is one of the following period expressions:
+
 
+
{| class="wikitable"
+
! <period>
+
! Description
+
!
+
! Special <period>
+
! Description
+
|-
+
| second
+
| runs every second
+
|
+
| X seconds
+
| runs every X seconds
+
|-
+
| minute
+
| runs every minute
+
|
+
| X minutes
+
| runs every X minutes
+
|-
+
| hour
+
| runs every hour
+
|
+
| X hours
+
| runs every X hours
+
|-
+
| day
+
| runs every day, at midnight UTC
+
|
+
| X days
+
| runs every X days, at midnight UTC
+
|-
+
| week
+
| runs every week, on a Thursday at midnight UTC
+
|
+
| X weeks
+
| runs every X weeks, on a Thursday at midnight UTC
+
|-
+
| month
+
| runs every month, on the 1st at midnight UTC
+
|
+
| X months
+
| runs every X month, on the 1st at midnight UTC
+
|-
+
| year
+
| runs every year, on the 1/1 at midnight UTC
+
|
+
| X years
+
| runs every X years, on the 1/1 at midnight UTC
+
|-
+
| decade
+
| runs every 10 years
+
|
+
| X decades
+
| runs every X decades
+
|-
+
| century
+
| runs every 100 years
+
|
+
| X centuries
+
| runs every X centuries
+
|-
+
| millenium
+
| runs every 1000 years
+
|
+
| X millenia
+
| runs every X mellenia
+
|}
+
 
+
==== When expressions ====
+
 
+
For dependent jobs you need to use the when-statements with the following syntax:
+
 
+
<source lang="ocaml">
+
when <expr> :
+
<<
+
  # shell script
+
>>
+
</source>
+
 
+
where '''<expr>''' is a when expression. But don't forget the colon between periods expression or when expression and the shell script.
+
 
+
All in all you can say, that a when-expression is a job which runs, when the described conditions become true.
+
 
+
{| class="wikitable"
+
! <expr>
+
! meaning
+
!
+
! <expr>
+
! meaning
+
|-
+
| expr && expr
+
| boolean "and" of the two sub-expressions
+
|
+
| ! expr
+
| boolean negative of expr
+
|-
+
| expr <nowiki>||</nowiki> expr
+
| boolean "or" of the two sub-expressions
+
|
+
| expr + expr
+
| for numeric sub-expression, this performs addition, for strings it performs string concatenation, else it returns an error.
+
|-
+
| expr < expr
+
| evaluates sub-expressions and compares them with the operator
+
|
+
| expr - expr
+
| evaluates sub-expressions and if both are numeric uses operator on them else returns error
+
|-
+
| expr <= expr
+
| evaluates sub-expressions and compares them with the operator
+
|
+
| expr * expr
+
| evaluates sub-expressions and if both are numeric uses operator on them else returns error
+
|-
+
| expr == expr
+
| evaluates sub-expressions and compares them with the operator
+
|
+
| expr / expr
+
| evaluates sub-expressions and if both are numeric uses operator on them else returns error
+
|-
+
| expr >= expr
+
| evaluates sub-expressions and compares them with the operator
+
|
+
| expr mod expr
+
| evaluates sub-expressions and if both are numeric uses operator on them else returns error (infix operator)
+
|-
+
| expr > expr
+
| evaluates sub-expressions and compares them with the operator
+
|
+
| len expr
+
| returns the length of the string in expr
+
|-
+
| variable
+
| returns the value of named variable
+
|
+
| prev variable
+
| returns previous value of named variable
+
|-
+
| changes variable
+
| same as !(prev variabel == variable)
+
|
+
| increases variable
+
| same as prev variable < variable
+
|-
+
| decreases variable
+
| prev variable > variable
+
|
+
| reloaded ()
+
| do not use it, it does not what you want (manpage warning)
+
|-
+
| false
+
| constant equals always false
+
|
+
| true
+
| constant equals always true
+
|-
+
| "any string"
+
| empty string in boolean = false, else equals true
+
|
+
| N
+
| any integer, boolean 0=false, non-zero=true
+
|-
+
| N. | .N | N.N | N.NeN
+
| and floating point number, boolean 0=false, non-zero=true
+
|
+
|
+
|
+
|}
+
 
+
==== shell scripts ====
+
 
+
The code between '''<< ... >>''' is a simple shell script and is executed using $SHELL. If $SHELL is not set, it is executed with '''/bin/sh'''
+
 
+
{| class="wikitable"
+
! available variable
+
! Description
+
|-
+
| $JOBNAME
+
| The name of the job. If the job has been named explicitly, then that name is available through this variable, else it will be some implicit name like '''job$1'''.
+
|-
+
| $JOBSERIAL
+
| The serial number of the job. This is simply a variable that increments each time a job is run, and is unique to that run of the job.
+
|-
+
| $HOME, $LOGNAME etc
+
| these are available as normal
+
|}
+
 
+
The shell scripts run with its current directory set to an temporary directory, that is cleaned up automacically after the job exists. So you don't have to worry about cleaning them up later. If you would like to store some values permanently, save the files to a well-known directory, eg. $HOME, '''/var''' etc.
+
 
+
All shell scripts are executed as the ordinary user. They have no special privileges.
+
 
+
==== Job names ====
+
 
+
If you like to give a job a unique name use the following syntax:
+
 
+
<source lang="ocaml">
+
job "JOBNAME"
+
every <period> :
+
<<
+
  # shell script
+
>>
+
</source>
+
 
+
==== OCAML expressions ====
+
 
+
You can also use OCAML expressions in the code. they are useful for factoring common code or strings, for example:
+
 
+
<source lang="ocaml">
+
let prefix = "daily_"
+
 
+
job (prefix ^ "virus_scan")
+
every day :
+
<<
+
  # shell script
+
>>
+
 
+
job (prefix ^ "disk_check")
+
every day :
+
<<
+
  # shell script
+
>>
+
</source>
+
 
+
===== initial value of variables =====
+
 
+
Variables are empty until they first get set, you can set a default starting value for a variable if you like with the following code
+
 
+
<source lang="ocaml">
+
let () =
+
  Whentools.set_variable "variable" "value";
+
  Whentools.set_variable_int "counter" 0
+
</source>
+
 
+
===== Pre functions =====
+
 
+
You can let arrange to run a '''pre''' function before a job runs. This function may decide to not run the job. One possible usage for that is the that you only want to have one job at time from the same job to run:
+
 
+
<source lang="ocaml">
+
job "only one"
+
pre (Whentools.one ())
+
every <period> :
+
<<
+
  # shell script
+
>>
+
</source>
+
 
+
===== Post functions =====
+
 
+
The same is for stuff after a job has run. This is handled by the '''post''' function.
+
 
+
<source lang="ocaml">
+
job "talk to me after finished"
+
post (Whentools.mailto "you@example.com")
+
every <period> :
+
<<
+
  # shell script
+
>>
+
</source>
+
 
+
===== Basic available Whentools functions =====
+
 
+
{| class="wikitable"
+
! function
+
! Description
+
|-
+
| style="vertical-align:top;"| whentools.mailto [~only_on_failure:true] [~from:from_address] email_address result
+
| This built-in post function sends the result of the script by email to the given email address.
+
 
+
If the optional "~only_on_failure:true" flag is set, then it is only sent out if the script failed.
+
 
+
If the optional "~from" flag is set, then the from address is set accordingly.  This is sometimes needed when sending mail.
+
 
+
Note the "result" parameter is passed implicitly by the daemon. You do not need to add it.
+
 
+
Here are some examples of using the mailto function:
+
 
+
<source lang="ocaml">
+
job "ex.1"
+
post (Whentools.mailto "you@example.com")
+
every 10 seconds :
+
<<
+
  # shell script 1
+
>>
+
 
+
job "ex.2"
+
post (Whentools.mailto ~only_on_failure:true "you@example.com")
+
every 10 seconds :
+
<<
+
  # shell script 2
+
>>
+
 
+
let from = "me@example.com"
+
let to_addr = "you@example.com"
+
 
+
job "ex.3"
+
post (Whentools.mailto ~from to_addr)
+
every 10 seconds :
+
<<
+
  # shell script 3
+
>>
+
</source>
+
|-
+
| style="vertical-align:top;"| Whentools.max n
+
| This built-in pre function ensures that a maximum of n instances of the job are running.
+
 
+
It checks the list of running jobs, and if n or more instances are already running, then it returns "false", which ensures that the new job is not started.
+
|-
+
| style="vertical-align:top;"| Whentools.one ()
+
| This built-in pre function ensures that only one instance of the job is running.  It is the same as calling: Whentools.max 1
+
 
+
|-
+
| style="vertical-align:top;"| Whentools.set_variable name string
+
| Set variable name to the string
+
|-
+
| Whentools.set_variable_bool name b
+
| Set variable name to the boolean value b
+
|-
+
| style="vertical-align:top;"| Whentools.set_variable_int name i
+
| Set variable name to the integer value i
+
|-
+
| style="vertical-align:top;"| Whentools.set_variable_string name s
+
| Set variable name to the string value <s>.  This is the same as Whentools.set_variable
+
|-
+
| style="vertical-align:top;"| Whentools.set_variable_float name f
+
| Set variable name to the floating point value f
+
|}
+
 
+
For the preinfo passed to the pre functions and results for the post functions have a view in the manpage.
+
 
+
== Examples ==
+
 
+
Finally here are some examples to which questions came up, hope you find them helpful for your first own tries... :)
+
 
+
<source lang="ocaml">
+
every 1 minute :
+
<<
+
  testtime=`date +%H%M`
+
  whenjobs --set --type int test=${testtime}
+
  whenjobs --set --type int runtime=0016
+
>>
+
 
+
when test == 0017 :
+
<<
+
  echo `date` >\> ~/test.log
+
>>
+
 
+
when test == runtime
+
<<
+
  whenjobs --get runtime >\> ~/test.log
+
>>
+
</source>
+
 
+
The above whenjobs have the need to run each day at a specific time, so we show you here two ways of doing it.
+
 
+
First we define a variable test for whenjobs based on the date with the HHMM output what would for example result in 0017 for 12:17am and 1428 for 2:28pm. then in the first when expression we test if our variable equals 0017 and if yes it runs, the second version is to define a second variable called runtime and then do like the second test does a test for it based on comparing both variables.
+
 
+
But now enough with that long doc, happy whenjobing for all of you... :)
+
 
+
  
[[Category:HOWTO]]
+
[[Category:Development]]
[[Category:Labs]]
+
[[Category:Tutorial]]
[[Category:Ebuilds]]
+
{{EbuildFooter}}
+

Latest revision as of 09:21, December 28, 2014

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:

# cd /root/git/funtoo-overlay
# 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:

# cd /root/git/funtoo-overlay
# 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:

# 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:

# 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:

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

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

# 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:

# git commit -m "bash updates from experimental"
# 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.