The evolution of a line of code

Sometimes, I run into situations where I'd like to see the changes over a range of code.

Imagine this rather common scenario. You are responsible for upgrading a dependency when suddenly a line of code that your application owns starts throwing an error. You go to that line and type git blame only to find that the most recent change to this line was a repo wide syntax fix. Oh no! What to do?

Well, I suppose I should pre-empt the many comments that will assuredly tell me "You can just do X," or "Have you tried Y" by saying that I'm interested in knowing more ways to do this. And as they say, "There is more than one way to skin a cat". Wait, why is that an expression? Yikes, moving on.

This has happened to me a number of times. And usually I'll use GitHub's new feature to track back through Git blame, or use git log for the file and track the changes that way. However, I found a neat way to do this a bit more precisely.

git log --pretty=short -L90,95:package.json  

If you man git-log you'll get this great description of how to leverage git-log's -L flag.

Long story short, the most common use-case (that I've found) you pass a range as <start>,<end>:<file>. And it will spit out the changes across commits of that range.

Which is pretty neat.

It also accepts a regex, with some complicated rules as to what that means (better outlined in the man page). And for the <end> you can specify a context modifier. So you could specify I want to see this line through the history plus-or-minus <context-modifier>, which will show that many lines before and after. You do so by using the + or - character and a number, e.g.: -L50:+3 or -L50:-5 to show 3 lines after or 5 lines before, respectively

Anyways, hope this helps. Cheers šŸ»

If your team needs help upgrading Ember-CLI, or with Ember in general, please contact us at http://www.201-created.com/