4 ms·
Question to HN: I'm trying to find the commit that originally added this line. How do you do this elegantly? Git blame: https://github.com/facebook/react/blam
by nothrabannosir 11y ago
Question to HN: I'm trying to find the commit that originally added this line. How do you do this elegantly?
Git blame:
https://github.com/facebook/react/blame/80bff5397bf854750dbe7c286f61654ea58938c5/src/umd/ReactUMDEntry.js https://github.com/facebook/react/blame/80bff5397bf854750dbe...
The last commit for this line:
https://github.com/facebook/react/commit/d17091ddebf317173eb30e3ab4a8e28e124c8f50 https://github.com/facebook/react/commit/d17091ddebf317173eb...
It says:
src/React.js → src/umd/ReactUMDEntry.js
and essentially, the line was moved two spots down. Now I want to see the git blame before this change. Here is where it gets messy...
Best I can think of is go to the parent commit:
https://github.com/facebook/react/commit/d8ee071c92994879fa82ba4d2775b4f38fb78f1d https://github.com/facebook/react/commit/d8ee071c92994879fa8...
Then look for the original file, src/React.js. So I go to "browse files at this revision", browse to the src/ dir, click React.js, then blame again:
https://github.com/facebook/react/blame/d8ee071c92994879fa82ba4d2775b4f38fb78f1d/src/React.js https://github.com/facebook/react/blame/d8ee071c92994879fa82...
Alright, we're there.
Is there an easier way? This feels very convoluted and hacky...
- tokenizerrr 11y agogit bisect with a grep?
- tokenizerrr 11y agoJust did this to make sure. My steps for the interested: Start with a file named `check` with the contents: grep "__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED" src/React.js && exit 1 exit 0 The commit is good if the line isn't there, the commit is bad if the line is there. Then find the first commit in the entire repository (it's 75897c2dcd1dd3a6ca46284dd37e13d22b4b16b4): git rev-list --max-parents=0 HEAD Then run: git bisect start HEAD 75897c2dcd1dd3a6ca46284dd37e13d22b4b16b4 git bisect run ./check And a few seconds later git will tell us that it was commit https://github.com/facebook/react/commit/b2ca3349c27b57b1e9462944cbe4aaaf76783d2b https://github.com/facebook/react/commit/b2ca3349c27b57b1e94...: b2ca3349c27b57b1e9462944cbe4aaaf76783d2b] Actually build react-dom file with the build running ./check React.__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactDOM; b2ca3349c27b57b1e9462944cbe4aaaf76783d2b is the first bad commit commit b2ca3349c27b57b1e9462944cbe4aaaf76783d2b Author: Paul O’Shannessy <paul@oshannessy.com> Date: Tue Sep 8 10:13:24 2015 -0700 Actually build react-dom file with the build :100644 100644 8b66781299e8980740f8f9a13ad31a0cb30fd684 c20a6aa20e3d3d26c63cf3ac7ee087c93dd8a7d6 M .eslintignore :100644 100644 e99175b6a10b11857f4c6242341731af6138c3ca 3f4a02e3e372af1b04b5bb2f1ee2b4384ef22295 M Gruntfile.js :040000 040000 7e99fe9ef7324209890325e2fd9a4a430a706814 1aeab86f880dbf4366709930d7134921bee9401e M grunt :040000 040000 357233750d2d661818a5ba70ab21fe8049ab9583 154a4f6f867aa8eddc8637aadae8bd3c38e794eb M src :040000 040000 4216cc98bca3b6d6276bdfbbb29a1ca14bed1972 1e90bf75ef899c6a0ed0484c5138f4d62f32b8d4 M vendor bisect run success `git log -S` might be better for this specific case, but `git bisect` is far more powerful so it's very useful to know how it works.
- frandroid 11y agoI don't think there's a better way, I do GitHub archaeology like this all the time.
- lost_name 11y agoI had the same question, and without actually cloning the repo I wish I had a better answer. I found, looking through the tags, that src/React.js was added in 0.14-stable, then I examined the history of React.js to find this commit: https://github.com/facebook/react/commit/b2ca3349c27b57b1e9462944cbe4aaaf76783d2b https://github.com/facebook/react/commit/b2ca3349c27b57b1e94... Additionally, I dug this up: https://github.com/facebook/react/pull/4814#discussion-diff-39007098 https://github.com/facebook/react/pull/4814#discussion-diff-... https://github.com/facebook/react/pull/4814 https://github.com/facebook/react/pull/4814 "I changed it to __SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED to make our German friends less grossed out. I'm going to do the examples in a separate PR."
- atesti 11y agoWhat was the thing that might have grossed out German friends? I'm German and I can't see any funny word here
- lost_name 11y agoI edited it in; my apologies. SECRET was SEKRET, which apparently means "secretion" in German. Ultimately this doesn't answer the question of why is it named this way.
- Manishearth 11y agoUse pickaxe $ git log -S__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED commit d17091ddebf317173eb30e3ab4a8e28e124c8f50 Author: Paul O’Shannessy <paul@oshannessy.com> Date: Thu Mar 24 11:00:38 2016 -0700 Make Browserify-specific modules to remove DOM dependencies from npm package commit 712199ef9830359c35c1c2442d79676396c06a2d Author: Jim <jsfb@github> Date: Mon Oct 5 15:02:34 2015 -0700 React -> ReactDOM for render() and findDOMNode() commit b2ca3349c27b57b1e9462944cbe4aaaf76783d2b Author: Paul O’Shannessy <paul@oshannessy.com> Date: Tue Sep 8 10:13:24 2015 -0700 Actually build react-dom file with the build
- timbuckley 11y agoPerfect solution! $ git log -p -S "SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED"