5 status](https://gitlab.com/oyvholm/utils/badges/master/pipeline.svg)
7 This is a collection of scripts I've had in my `~/bin/` directory since
8 the previous century. Some of them are quite specific for my own use,
9 but many of them have evolved into a mature state and could probably
10 have their own repository as their own project. That will probably not
11 happen, as most of the scripts consists of only one file.
13 The `master` branch is considered stable and will never be rebased.
14 Every new functionality or bug fix is created on topic branches which
15 may be rebased now and then. All tests on `master` (executed with "make
16 test") should succeed. If any test fails, it’s considered a bug. Please
17 report any failing tests in the issue tracker.
22 Everything here created by Øyvind A. Holm (<sunny@sunbase.org>) is
23 licensed under the GNU General Public License version 2 or later.
28 This repository can be cloned from
30 - `git@gitlab.com:oyvholm/utils.git` /
31 <https://gitlab.com/oyvholm/utils.git> (Main repo)
32 - `git@bitbucket.org:sunny256/utils.git`
33 - `ssh://sunny256@repo.or.cz/srv/git/sunny256-utils.git`
35 The repositories are synced with
36 [Gitspread](https://gitlab.com/oyvholm/gitspread).
41 These scripts are stable and ready for public use.
43 ### Git extensions, check out first
47 Scan the current repository for dangling heads (dead branches where the
48 branch names have been deleted) or tags and create branches with the
49 format `commit-SHA1` and `tag-SHA1`. This makes it easy to locate
50 branches and tags that shouldn't have been deleted. No need to dig
51 around in the reflog anymore. Needs `git-delete-banned`.
55 Delete remote and local branches specified on the command line, but can
56 be used with the output from `git log --format=%d` or `%D`. A quick and
57 easy way to clean up the branch tree with copy+paste.
61 Execute commands in remote ssh repositories. For example, to make all
62 connected ssh repos (if they have a local shell, of course) fetch all
63 new commits from all remotes:
65 git-rcmd -c "git fetch --all --prune"
69 Execute a command with only the staged changes in Git applied.
71 If you have lots of unrelated uncommitted changes in the current
72 repository and want to split up the commit, how can you easily check if
73 the changes passes the test suite? With all the other unrelated changes
74 it can be hard to make sure that only relevant changes becomes part of
75 the commit, and that they don't result in regressions. This script
76 clones the repository to the directory `.testadd.tmp` in the current
77 directory and applies the staged chenges there (unless
78 `-u`/`--unmodified` is specified), chdirs to the same relative directory
79 in the clone and executes the command specified on the command line
82 If the command contains any options starting with `-`, add `--` in front
83 of the command so they won't be parsed by git-testadd, or surround it
88 user@host:~/src/myproject/src/t $ git-testadd make test
90 The command will be executed in `~/src/myproject/src/t/.testadd.tmp/`
91 with only the staged changes applied.
93 user@host:~/src/myproject/src/t $ git-testadd -- ./run-tests -v
95 This command contains a `-v` option. Disable option parsing of the
96 command by prefixing it with `--`.
98 $ git-testadd "make && cd t && make 2>&1 | less || echo fail"
100 With quotes, even control operators and pipes can be used.
104 Useful for working with topic branches. Create subbranches separated
105 with a full stop in the branch name. It can create new subbranches,
106 merge to parent branches or `master` with or without fast-forward and
107 squash the whole branch to the parent branch or `master`.
109 ### Other stable Git extensions
113 Scan remotes for branches and recreate them in the local repository.
117 Change the state of the current repository to/from a bare repository
118 to/from a regular repository.
122 Alias for `git bisect`, but allows execution from a subdirectory.
124 #### git-delete-banned
126 Delete unwanted `commit-SHA1` branches and `tag-SHA1` tags created by
127 `git-dangling`. Some people like to keep old branches around after
128 they've been squashed or rebased, but there are always some worthless
129 branches around that only clutter the history. Those commits can be
130 specified in `~/.git-dangling-banned`, and this command will delete
133 #### git-delete-old-branches
135 Delete obsolete Git branches locally and from all remotes. For each
136 branch, display a `git diff --stat` against all local and remote
137 branches with this name, a simplified `git log --graph`, and finally a
138 `git log` with patch against all branches. Display this in less(1), and
139 ask if all branches with this name should be deleted.
141 The following responses are valid:
143 - **y** - Delete all branches with this name locally and from all
144 remotes and mark it as garbage.
145 - **n** - Don't delete the branch. If `-o`/`--once` is used later, files
146 marked with `n` will not be checked.
147 - **d** - Mark branch as "don't know", to be perused later.
148 - **q** - Exit the program.
150 The answers can also be stored in an SQLite database to automate
155 Delete all remote and local branches specified on the command line.
159 Ignore files in Git. Automatically update `.gitignore` in the local
160 directory (default) or add the file, directory or symlink to the
161 `.gitignore` at the top of the repository. Directories will have a slash
162 automatically added, and if the file/directory/symlink already exists in
163 Git, it will be removed from the repository without touching the actual
168 Show log differences between branches with optional patch.
172 Merge a topic branch without using fast-forward, always create a merge
173 commit. This is used for collecting related changes together and makes
174 things like `git log --oneline --graph` more readable. IMHO. After the
175 branch is merged, it's deleted.
179 Filter output from `git branch` through this to remove `commit-SHA1`
184 Push to all predefined remotes with a single command.
186 #### git-restore-dirs
188 Restore empty directories from the `.emptydirs` file created by
193 Shortcut for `git rcmd -c "git pull --ff-only"`.
197 Store the names of all empty directories in a file called `.emptydirs`
198 at the top of the repository. The names are zerobyte-separated to work
199 with all kinds of weird characters in the directory names. Use
200 `git-restore-dirs` to recreate the directories.
202 #### git-wait-until-clean
204 If there are any modifications or unknown files in the current
205 repository, wait until it's been cleaned up. Useful in scripts where the
206 following commands need a clean repository. Can also ignore unknown
207 files or check for the existence of ignored files.
213 Read text from stdin or files and convert from am/pm to 24-hour clock.
217 Insert, replace or delete UTC timestamp from filenames.
221 Cripple the file modtime by truncating odd seconds to even. To make life
222 easier for rsync and friends if one has to interact with those kinds of
227 Edit an SQLite 3.x database file in your favourite text editor. The
228 original version is backuped with the file modification time in the file
229 name as seconds since 1970-01-01 00:00:00 UTC.
233 Read text from stdin and output all lines with bytes > U+007F.
237 Read text from stdin and print all lines containing invalid UTF-8.
241 Print timestamp when a specific goal will be reached. Specify start date
242 with value, goal value and current value, and it will print the date and
243 time of when the goal will be reached.
247 Create commented-out Vim fold markers (<!-- \{\{\{_num_ -->)
248 with header level in Commonmark/Markdown files at the end of every
249 header line where hash signs are used. Useful for big documents.
253 Pad decimal or hecadecimal numbers with zeroes to get equal length.
257 Split contents into files based on separation bytes.
259 ## Stable, but has some limitations
263 Sort the rows in an SQLite database. A backup of the previous version is
264 copied to a \*.bck file containing the date of the file modification
265 time in the file name.
269 - git-add-missing-gpg-keys
288 Create a graph in Gnuplot of the commit activity. Needs `ep`,
289 `inc\_epstat` and `stpl`. And Gnuplot, of course.
291 FIXME: `ep` is in Nårwidsjn.
303 "git What's New". Create an ASCII representation of all commits that
304 contain the current commit. Useful after a `git fetch` to list all new
305 commits. Needs `git-lc`.
307 FIXME: Uses "git lg". Change that to a proper `git log` command or put
353 - README.build-git.md
397 - construct\_call\_graph.py
443 - filtrer\_access\_log
597 - remove\_perltestnumbers
675 - tmux\_local\_install.sh
703 - vgr – Run a command through Valgrind
733 File ID: a8487d1c-1c4f-11e5-b5a1-398b4cddfd2b
734 vim: set ts=2 sw=2 sts=2 tw=72 et fo=tcqw fenc=utf8 :
735 vim: set com=b\:#,fb\:-,fb\:*,n\:> ft=markdown :