(Pssst. Check out my Git Submodules Cheat Sheet for a quick reference.)
This post is the result of my investigations into how Git submodules work and how to use them. My goal in investigating submodules was to decide if they would be an effective way to share specs among the various Ruby FFI implementations (Ruby-FFI for MatzRuby, JRuby’s FFI, Rubinius’ FFI, etc.). We wanted all the projects to be able to include the specs as a subdirectory of their main repository so that they could easily run them, yet we also needed an easy way to keep all the projects in sync. Continue reading Your Git Submodule and You
Here’s a handy tip that shows off one of the little conveniences that makes me love Git.
In Subversion, if you made a mistake in one of your commits — too bad. At best, you might be able to edit the revision log, if your repository was configured to allow that (Sourceforge repositories aren’t).
In Git, as long as you haven’t pushed upstream yet, it’s trivial to change the commit log, or even the actual commit contents!
Continue reading Git tip: Fix a mistake in a previous commit
Miscellaneous tip of the day, mostly putting it here so I’ll remember it later!
In recent versions of Emacs, you can use lisp expressions to process the replacement result when running a search/replace regexp command (e.g. replace-regexp). The syntax for that is:
The real handy part is that \0, \1, …, \9 work even inside the expression, allowing you to run an expression on the result of your search.
As a contrived example, if you wanted to change every vowel in the buffer to upper case, you could replace-regexp with the following search regexp and replacement regexp:
In a real use case, I wanted to convert words like “m11”, “m12”, “m23”, etc. to “m00”, “m01”, “m12” — subtracting one from each digit in the name. Here are the search and replacement regexps I used:
m\,(- (string-to-int \1) 1)\,(- (string-to-int \2) 1)