HACKING (2663B)
1 Hacking 2 ======= 3 4 Code style 5 ---------- 6 7 I tend to write programs in C using my own style, which is described at: 8 9 https://strahinja.org/tekstovi/softver/kodni-standard/ 10 11 (page in Serbian). To automate the formatting of code, I use the program 12 clang-format with the configuration file located at: 13 14 https://git.sr.ht/~strahinja/dotfiles/tree/master/item/.clang-format 15 16 This repository should also contain a copy of that file. You can format the 17 files before creating patches to send to me by using the command 18 19 $ clang-format -i filename.c # also applies to *.h 20 21 issued from the main directory of the repository. 22 23 24 Creating customizations (git) 25 ----------------------------- 26 27 It is perhaps the most efficient to create a separate branch with your 28 modifications in the repository, then: 29 30 $ git branch my_feature # if the branch doesn't already exist 31 $ git checkout my_feature 32 33 and after making changes: 34 35 $ git add -A 36 $ git commit -sS 37 $ git format-patch master --stdout > my_feature.patch 38 39 You can then send the file my_feature.patch by email to my public inbox at 40 41 ~strahinja/public-inbox (replace_with_at_sign) lists.sr.ht 42 43 To update the branch holding your feature when the upstream changes, you can 44 instead do: 45 46 $ git checkout my_feature 47 $ git rebase --rebase-merges master 48 $ git format-patch master --stdout > my_feature.patch 49 50 51 Creating customizations (got) 52 ----------------------------- 53 54 Note: to my knowing so far, got doesn't support git's email-based workflow; the 55 closest thing to git email patches made by git-format-patch(1) is the output of 56 `got diff -d`. 57 58 59 * Option 1 (requires git) 60 61 Since the _repository directory_ (**not** the work tree directory!) is a bare 62 git repository, git can be used to generate the patch: 63 64 $ cd $(got info | awk '/repository:/{print $2}') 65 $ git format-patch master..my_feature --stdout > my_feature.patch 66 67 68 * Option 2 (got only) 69 70 With got: 71 72 $ got branch my_feature # if the branch doesn't already exist 73 $ got update -b my_feature # if it does 74 75 and after making changes: 76 77 $ got add -R . 78 $ got commit 79 $ got diff -d master my_feature > my_feature.diff 80 81 The .diff file can be converted to the format digestable by git-am, for 82 example using the script gotfp[1] and sent with the ending .patch to the same 83 address as above: 84 85 ~strahinja/public-inbox (replace_with_at_sign) lists.sr.ht 86 87 To update the branch holding your feature when the upstream changes, you can 88 instead do: 89 90 $ got update -b master 91 $ got rebase my_feature 92 $ got diff -d master my_feature > my_feature.diff 93 94 and convert the .diff file to .patch. 95 96 [1]: https://git.sr.ht/~strahinja/dotfiles/tree/master/item/bin/gotfp