Skip to content

Instantly share code, notes, and snippets.

@pjf
Last active January 2, 2016 01:39
Show Gist options
  • Save pjf/8231962 to your computer and use it in GitHub Desktop.
Save pjf/8231962 to your computer and use it in GitHub Desktop.
The curious matter of finding a given merge

My problem:

I'm working on a project where upstream doesn't use source control of any sort. Yes, that's exactly the same reaction I had as well.

I keep track of their releases on a branch named upstream. When new releases are made, I add them to this branch as a single commit, so at least I know what changed (in bulk) from the last release.

My changes (usually!) end up in the official releases, but because they don't use source control, my commits never do. Hence I want to find all the commits I've made since the last merge, as an "approximation" of what's changed between my release and theirs. Simple git log A..B isn't what I want here.

So, here's the network graph. I want to find the last point on master where upstream was merged in. In this case, that's 9039b22b .

To make matters more fun, sometimes there's a few fix-ups done (on a side-branch of upstream) after upstream is imported, but before the merge into master. They're great for keeping the master branch clean and tidy, but make this particular problem harder. However we can rely upon 'upstream' to always point to the commit we want to search from.

Also, we can't rely upon finding just the last merge in general, because all sorts of things get merged into master (ie: contributions from every other developer who does use source control). I could try to do some sort of magic looking at text messages, but humans edit those. Likewise I don't want to use a tag which keeps moving, because moving public tags in git is evil, and having code which relies upon private tags is misguided.

Yes, this is all horribly painful. It's inspired posts on how wonderful FOSS is when done properly, and it's not been contributing to my happiness. Yes, I'm trying very hard to change processes. You can shed tears for me if you like.

@pjf
Copy link
Author

pjf commented Jan 3, 2014

@shiftkey: It feels pretty cool! I also think I'm going to need more than the three hours of sleep I've had to fully comprehend what you've done. Damn my late night coding sessions... ;)

It also teaches me the git log --graph command, which I've never really used before! That's awesome! :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment