Some of the PLplot developers (including me) are relatively
inexperienced with git so the purpose of this git blog is to discuss
new issues or new killer features we have discovered with git, and I
hope others here participate in this series of posts as well as a
pretty good method of jointly increasing the level of our git
expertise.

Today's story concerns "git format-patch" and "git am" which is the
recommended way (for a rebase workflow like ours) to collaborate on a
topic branch that is not yet ready for merge with master.  The issue
is the preparer of the patch using "git format-patch" (Phil in this
case) has an option to either (1) include all commits since his topic
branch split off from master or else (2) include only those commits on
his topic branch since he last distributed his patch series.  He chose
option 1 which does have the advantage of being more self-contained
(if somebody wants to start following his work) but requires (I just
discovered) more care in using "git am" to apply his series of commits
to my local topic branch where his previous series of commits had
already been committed.

I naively thought that "git am" would simply ignore commits in Phil's
patch that had already been made on my topic branch, but sadly this
turned out not to be the case, and here was the result:

software@raven> git am /home/irwin/Phil.Rosenberg/20150123/wxRedesign_v2.patch 
>/tmp/wxRedesign_v2.patch.out
/home/software/plplot/HEAD/plplot.git/.git/rebase-apply/patch:216: trailing 
whitespace.
// A plplot wxWindow template. To create an actual plplot wxWindow use 
/home/software/plplot/HEAD/plplot.git/.git/rebase-apply/patch:280: trailing 
whitespace.

/home/software/plplot/HEAD/plplot.git/.git/rebase-apply/patch:406: trailing 
whitespace.

error: bindings/wxwidgets/wxPLplotwindow.cpp: does not exist in index
error: patch failed: bindings/wxwidgets/wxPLplotwindow.h:20
error: bindings/wxwidgets/wxPLplotwindow.h: patch does not apply

One obvious brute-force way out of this was to delete the topic branch and
start over by hand, but this is what the --abort option for "git am" is
supposed to do so I tried that.

software@raven> git am --abort \
/home/irwin/Phil.Rosenberg/20150123/wxRedesign_v2.patch \
> /tmp/wxRedesign_v2.patch.out1
previous rebase directory 
/home/software/plplot/HEAD/plplot.git/.git/rebase-apply still exists
but mbox given.

As documented (but I missed it until after the fact) you should not include a 
patch file
when using the --abort option.

So to review, I had tried to apply Phil's patch series incorrectly, and then
attempted to abort the git am session incorrectly.  So batting 0-2 so
far!  :-)

I figured the net result of these failed operations was no file
changes other than storing Phil's patch series in .git/rebase-apply.
So I tried the following experiment which worked!

software@raven> git am -i

Note the lack of reference to Phil's patch series for this command
(i.e., it likely used information in .git/rebase-apply to access his
series).  Also note the -i option allows me to interactively apply his
patches.  So with the aid of "git log --oneline" to learn the last
commit in my topic branch, I hammered on the -n key (for no) for ~34
times (until that last commit in my topic branch showed up), then gave
one more "n" then finished with "y" (for yes) to select the last
patches in the series to bring my private topic branch up to date with
Phil's.

When done with this, the "git status" command showed pristine results,
and git log --oneline showed that Phil's 3 extra commits had been
applied on top of the previous ones.  Also, .git/rebase-apply no
longer existed.  So from all this evidence it appears I had success.

So the next time I get another full series of patches from Phil, I will
know to use

git am -i <patch_series_file_name>

(note, this time with a patch-series file if no previous mistakes
have occurred with git am) to select the subset of those that I need
to bring me up to date.

So the moral of this story is so long as you have a backup plan in
mind (in this case to delete the whole branch and start over with a
new topic branch), it is useful to experiment with git to learn
something new about it (in this case the usefulness of the -i option
for the "git am" command to select the commits that you need from a
complete patch series to bring you up to date).

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state
implementation for stellar interiors (freeeos.sf.net); the Time
Ephemerides project (timeephem.sf.net); PLplot scientific plotting
software package (plplot.sf.net); the libLASi project
(unifont.org/lasi); the Loads of Linux Links project (loll.sf.net);
and the Linux Brochure Project (lbproject.sf.net).
__________________________

Linux-powered Science
__________________________

------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel

Reply via email to