[ipxe-devel] patches & git

Geert Stappers stappers at stappers.nl
Mon May 4 20:14:06 UTC 2020


On Sat, May 02, 2020 at 05:16:07PM +0200, Geert Stappers wrote:
In-Reply-To: <20200502151607.5qxqmj5ocbuorsjr at gpm.stappers.nl>
> Some happy git flow
> 
>   git checkout master
>   git pull
>   git checkout -b myfeaturebranch
>   # the actual development
>   git add  files_worked_on
>   git commit
>   # further development
>   git add  files_worked_on 
>   git commit
>   git format-patch master
>   # now you have patches that can be shared / distributed / emailed
>    
> At recieving end
> 
>   git checkout master
>   git checkout -b reviewbranch
>   git am  *.patch
>   # actual reviewing
>   git checkout master
>   git rebase reviewbranch


Off-list  asked  more information about it.
Now sharing it here also.

-----8<---8<---8<----- exercise material start

# getting a clean sheet
rm -f ????-*.patch
git checkout master
git branch -D sandbox

# start preparation of our playground
git checkout master
git checkout -b sandbox HEAD~4
git checkout master
git format-patch sandbox
#  there are now patches \o/
ls -l *.patch
#cat *.patch       #  have peek at them
#head *.patch      #  or an even smaller glimps


# start
git checkout sandbox     # back at playground
git diff master | wc -l
git log | head -n 4
head -n 4 0001-*.patch

git am 0001-*.patch   # git Apply Mail      <--------------------

git log | head -n 4

git am *.patch      # Apply Mail, using globing, triggers an "error"

git am --abort      # untrigger that "error"

rm -f 0001-*.patch  # avoid retriggering
git am *.patch      # Apply Mail, using globing
git log | head
git diff master | wc -l

git checkout master
git branch -d sandbox   # triggers an advice
git rebase sandbox      # doing something with the advice
git branch -d sandbox

-----8<---8<---8<----- exercise material end


Now  more real life 

-----8<---8<---8<-----  `git am 0001-foo.patch` versus `git am < 0001-foo.patch` start
Preparation: Have the attachments of ONE email saved.
Saving the attachments of several emails at same location
can get you a name collision ...

Be in the directory with the iPXE  git repository

Move the attachments to working directory
(or save them there rightaway)


  git checkout master

<screenshot justfor="sync">
$ git status
On branch master
Your branch is up to date with 'origin/master'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        0001-src-Makefile.housekeeping-lines-reshuffled.patch
        0002-Reproducible-builds.patch

nothing added to commit but untracked files present (use "git add" to track)
stappers at rosa:~/src/ipxe
$ 
</screenshot>

  git checkout -b reviewbranch
  git am *.patch

Hey, I got `Patch format detection failed.`     OOPS   CHIPS

  for P in $( ls *.patch)
  do
    git am < $P
  done


<screenshot for="comparision">
stappers at rosa:~/src/ipxe
$ git am *.patch
Patch format detection failed.
stappers at rosa:~/src/ipxe
$ for P in $( ls *.patch )
> do
>   git am < $P
> done
Applying: src/Makefile.housekeeping: lines reshuffled
Applying: Reproducible builds
stappers at rosa:~/src/ipxe
$ 
</screenshot>

-----8<---8<---8<-----  `git am 0001-foo.patch` versus `git am < 0001-foo.patch` end


Hope this helps.

May the source be with you.


Regards
Geert Stappers

P.S.
cleanup suggestion

  git checkout master
  git rebase reviewbranch
  git branch -d reviewbranch

-- 
Silence is hard to parse



More information about the ipxe-devel mailing list