...
- Find the repo for the patch file.(For ex : here the patch file is index.patch.)
- Clone the repo. For ex:
- Checkout the branch for which you want to create the patch.
- $ git checkout 1905_sprint
Branch '1905_sprint' set up to track remote branch '1905_sprint' from 'origin'.
Switched to a new branch ' 1905_sprint' - $ git branch
* 1905_sprint
master
4. Find the location of the patch file in the repo.
...
- Next find the repo for the actual source file to which the patch file was getting patched. ( For ex: here the source file is index.php)
- clone the repo.
- checkout the required branch.
- $ git checkout 1905_sprint
Branch '1905_sprint' set up to track remote branch '1905_sprint' from 'origin'.
Switched to a new branch ' 1905_sprint' - $ git branch
* 1905_sprint
master
- Cherry-pick the required changes also.
...
- create another directory, and clone the source code repo (as in step 2). For ex :
- Checkout the required branch
$ git checkout 1905_sprint
Branch '1905_sprint' set up to track remote branch '1905_sprint' from 'origin'.
Switched to a new branch ' $ git checkout 1905_sprint'- $ git branch
* 1905_sprint
master
- Copy the patch file from the patch repo (step 1) to the current directory.
...
- Now you can use "Meld tool" to compare between files to refresh the patch. Here you can compare between the source file generated in step 2 (which will have the required changes) and the source file generated in step-3 (which will have the patch appied on to it).
- During comparing between source files make sure that you take only the required changes (changes available in actual source file step-2) to the patched file generated in step-3.
- Once all changes are taken , you can verify the patch by checking the option file/format as patch in the tool. Save the updated file and copy it to your repo (repo generated in step-2).
- Now in your repo , you will have 2 source file (for ex: one will be index.php --original file with the required changes and index_bk.php --updated file with patch applied and also your changes).
- In terminal , you can use command "diff -ruN file1 file2 > new_patch_file.patch" to generate a new patch.
- For ex : diff -ruN index.php index_bk.php > new_index.patch
Step 5 :
- Open the newly created patch file, update the file location correctly and save it. For ex :
--- git/source/Styles/xb3/code/index.php 2019-05-20 05:56:54.047078876 +0000
+++ git.1/source/Styles/xb3/code/index.php 2019-05-20 06:26:56.000000000 +0000
...
- In order to verify the newly created patch, you can create a temporary folder, clone the repo, checkout the required branch. Now copy the latest patch (new_index.patch) here.
- In the terminal, give the command patch -p1 < new_index.patch, will apply the patch to the source file. It should not fail.
...
- Now for pushing the latest patch, clone the repo for patch (step-1)
- checkout the required branch.
- $ git checkout 1905_sprint
- copy the latest patch(new_index.patch in this case) to the actual patch file available in the repo.
- $ cp ../src/new_index.patch meta-pacexf3/recipes-ccsp/ccsp/ccsp-webui/index.patch
- $ git status
- It will show the file as modified. Perform git add.
- $ git add meta-pacexf3/recipes-ccsp/ccsp/ccsp-webui/index.patch
- $ git commit
- Update if any commit message has to be added and try to push the changes.
- $ git push origin HEAD:refs/for/1905_sprint
- It fails for commit message upload. For ex : you may get error like this :
- remote: ERROR: [6b429fb] missing Change-Id in commit message footer
- remote:
- remote: Hint: To automatically insert Change-Id, install the hook:
- remote: gitdir=$(git rev-parse --git-dir); scp -p -P 29418 rkumar840@gerrit.teamccp.com:hooks/commit-msg ${gitdir}/hooks/
- remote: And then amend the commit:
- remote: git commit --amend
- Run the command mention in logs.
- $ gitdir=$(git rev-parse --git-dir); scp -p -P 29418 rkumar840@gerrit.teamccp.com:hooks/commit-msg ${gitdir}/hooks/
- $ git commit --amend (No change-id is assigned to the change.)
- $ git commit --amend (change-id has assigned now.)
- $ git push origin HEAD:refs/for/1905_sprint
- This will push the changes successfully to the branch. You can open the gerrit link and verify.
- Put the same topic name for the patch and the source file , trigger the verification.
...