On 3/2/18 2:45 PM, H. S. Teoh wrote:
On Fri, Mar 02, 2018 at 02:23:14PM -0500, Andrei Alexandrescu via Digitalmars-d 
But I don't have a simple method to ascribe the blame to a specific
PR. Is the only way to look at the date then look at the log? Thanks.
-- Andrei

This is how I usually do it:

1) Find the hash of the offending git commit, usually using git bisect
    or git blame.

2) git checkout master; git log --graph | less
    (In place of `less`, use any pager that has scrollback capability. Or
    leave out the `| less` if the default pager invoked by git has
    scrollback ability.)

3) Do a search for the commit's hash. Usually, this will be a commit
    buried somewhere inside a series of commits in the offending PR.

4) Scroll up until you find the commit that merged the PR. The commit
    message will contain the PR number.  Note that this is why you need
    --graph in the call to git log, because otherwise commits from random
    PRs will be interspersed together and there will be no easy way to
    trace them.  Using --graph will give you a visual cue as to which
    commits belong to the PR so that you can trace it to the merging
    point, and it also does a topological sort, which tends to cluster
    related commits together better than the default setting.

There's probably a one-liner to do this, but I prefer using git log
--graph because it also lets me see the context of the original commit
and scroll around to see any other commits that might be relevant.

It's easier than that.

The git blame view in github shows it as this commit:


If you look in the upper left, it shows "master (#1181)", where 1181 is the PR that merged it. Click on the "#1181" and it brings you to the PR.


Reply via email to