Showing posts with label tools. Show all posts
Showing posts with label tools. Show all posts

2014/06/23

Git ahead

Almost since I started using git I found myself following the tip 'don't git pull, use git fetch and git merge'. I have found this tip useful specially to prevent unexpected disruptive changes to come to my local branch.

I used to fetch changes and take a look at incoming commits with the command:

git log <current branch>..origin/<current branch>

In my work environment, our git repo has grown quite a bit and the names of the branches have started to get longer and longer. Besides, I thought there should be a way to not have to tell git the name of the current branch, since it already knows its name. So I included this alias in my git configuration.

git config --global alias.ahead '!git log HEAD..$(git rev-parse --abbrev-ref --symbolic-full-name @{u})'

So now I can simply write git ahead after fetching from remote to get the log of incoming commits for the current branch I'm working on.

2010/12/15

xmllint and xsltproc

I've been recently developing XSL transformations. I've been implementing C++ code to edit XML files using XPath values too.

I had previously used xsltproc, the command line utility distributed together with libxslt to test and debug my XSL transformations.

I have also used xmllint to validate hand-written XML files in order to be both well-formed and valid against a given DTD or XSchema.

But I recently discovered a wonderful xmllint feature: the --shell option. It runs an interactive shell that allows the user to navigate within the XML document as in a file system. But navigating is not the most useful feature I found for the shell option: it's the xpath command.

It allows to quickly check what node-set will be obtained when applying an XPath expression to a given XML input file.


It's a really useful utility when writing complex XPath expressions or checking out results for XPath expressions on complex documents.