[SOLVED] Git newbie - Generating a patch against the git repository

I git pulled, versioned to 19.07.1 and added a ramips device for a Trendnet TEW-810DR. This device is an exact clone of the D-Link DIR-810L. Trendnet's GPL source even contains an MTD6 partion labeled "MyDLink". It built without errors and installed using the instructions in the TEW-810DR/DIR-810L device pages.

I duplicated the git pull and generated my own local diff for my own future builds. I would like to submit to the project and need some spoon feeding advice on how to generate a diff against the current git snapshot.

A basic flow:

Summary
# git workflow example for PR submission
# Assumes some setup of the git environs on your build machine i.e. name/email for signoff
# Clone your own forked tree on Github
$ git clone https://github.com/MONIKER/source.git
$ cd source/
# Make a feature branch just for the PR you want to make
$ git checkout -b update-thisBit
# Do your changes and commit them
$ nano package/kernel/thisBit/Makefile 
$ git add package/kernel/thisBit/Makefile 
$ git commit -s -m "target: Add blah and more" -m "Holy verbosity Batman"
# Push your feature branch to Github
$ git push origin update-thisBit
# navigate to https://github.com/MONIKER/source and it should offer you a button to create a pull request.

# if someone wants a change from you, go into your local clone and amend your changes.
# Move back into your cloned source
$ cd source/
# Checkout the feature branch
$ git checkout update-thisBit
# Edit your files again, incorporate the wanted changes
$ nano package/kernel/thisBit/Makefile 
# Amend your commit (means merge the latest changes with those already present in the commit)
$ git add package/kernel/thisBit/Makefile 
$ git commit --amend
# Force-push your rewritten history back to Github
$ git push origin update-thisBit --force
# At this point your pull request commits are automatically updated.

1 Like

Is your recommendation based on the git-pull reference in these guidelines?
https://openwrt.org/submitting-patches#creating_a_patch.

Since I'm new at it, I worry about sending some garbage and would be more comfortable generating/reviewing my own patch and inserting it into the body of an openwrt-devel email.

That's the basic gist of doing a PR, which I find more conducive to supporting a feedback loop. If you want to submit via devel email follow the wiki linked. I find that so... 1990s, but that is what the kernel folks use and is well recognised. To each their own.

1 Like

Typically the following two commands should do

git format-patch ^origin/openwrt-19.01
git send-email --to xx@yy.com 000n-zz.patch

You may need to setup gitconfig for the send-email command to work.

I would suggest initially sending the mail to your own address and reviewing them against the requirements/suggestions laid out in the guide.

I recall reading that the project prefers diff against the current snapshot. For more context, I'm using Debian 10 and since this is a one-shot commit (hopefully), I'd like to minimize the software I install and the number of project registrations - I've already registered with the forums and the opewrt-devel mailing list.

jsh@PooBear:~/OpenWRT/openwrt$ git format-patch ^origin/openwrt-19.01
fatal: bad revision '^origin/openwrt-19.01'

Was 19.01 a typo 19.07 or a reference to the current snapshot?

Yes, I forgot about this. Changes should be applied to master branch first, then selectively backported to release version.

If I understand it correctly, your change is on 19.07 branch. To ensure the diff also applies cleanly to master,

  1. Run git format-patch to make a diff against 19.07
  2. Checkout a new branch based on current master. git checkout -b new-dev origin/master
  3. Apply the patch just made on the new branch. Resolve conflicts should they exist.
  4. Run test
  5. Run format-patch again.

A typo. origin/openwrt-19.07 as I understand it refers to local snapshot of branch 19.07 of remote origin

Thanks for the guidance. Out of concern for flooding the git repo with my attemps, I inserted the patch into an email to openwrt-devel@openwrt.org.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.