5

(Note: Github usage appears in bounds GitHub issues asked on Stack Overflow)

PRs that move code around, even within the same function, appear very onerous on Github, even when they don't do anything else. I have created a very basic PR to demonstrate this: https://github.com/tommyjcarpenter/github_test/pull/1/commits/2afb07ec5c6b56724bd10c6b56386299493bbb43. All the repo does is define two functions, and PRs a change to move the first below the second. The diff on github shows 20 lines removed and 21 added. One would assume the diff could be shown as a trivial "code move".

Now imagine this with a lot more functions and a lot more trivial code moves.

It seems git itself IS able to detect such changes: Using Git diff to detect code movement + How to use diff options

So, is there a way to swap out the diffing algorithm such that PRs like this don't look so onerous? Does github use it's own internal algorithm or does it use your default diffing algorithm?

(EDIT: this also appears to make account-level contributions on Github a bit misleading: someone that just moves code around may be shown to make a huge number of additions and deletions to a repository, thus giving the impression that they are a large contributor, when in fact they didn't contribute any functionality)

Community
  • 1
  • 1
Tommy
  • 12,588
  • 14
  • 59
  • 110
  • This sounds like a bug report/feature request to Github, not a SO question. – Bergi Jul 26 '16 at 20:07
  • 1
    It is unclear whether it is actually a bug or whether there is something in place that can be done about this. That's why I am asking. That said, It appears github requires that you email them and does not actually have a public issues/features page, so in the meantime I have also added this here but this is NOT Github's page: https://github.com/isaacs/github/issues/729 – Tommy Jul 26 '16 at 20:48

1 Answers1

5

I suspect if this sort of feature existed, it would be a hidden feature like hiding-of-whitespaces in diffs.

The challenge I see for Github to implement different diffing algos is the implications to contribution metrics. Contribution metrics (i.e. contributers, PR size) would now have to be footnoted with the algorithm used in order to properly audit and review changes.

As a work around, you could separate formatting commits from functional change commits to at least be able to distinguish between the two via commit history.

mikehwang
  • 490
  • 3
  • 10