In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article focuses on "how to use git bisect to locate BUG in code". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to use git bisect to locate BUG in code.
Background
You may have encountered this situation. Yesterday, the module was developed before leaving work, the unit test passed, and the git commmit was covered with the computer.
The next day what came in the morning, continued development, submitted several commit, deployed a version in the afternoon, and found that BUG appeared in the code that passed the test yesterday.
What would you do at this time? it is possible to flip through the git log of the BUG code file and find that there are 20 commit? .
Your mood may be broken at this time.
Farewell to cyber manhunt bad commit find BUG ✌️ with git bisect
The specific method is to find the git hash in which you are sure the code is OK through the git log command, and then to find the git hash in which you currently appear BUG, and then use git bisect start to start our wonderful debug journey. Start tagging commit to tell git that the commit (just found out to make sure the code is commit hash of OK) is the git bisect good 5d5dba7 of OK that tells git that the current last commit code is BUG git bisect bad 692ac39git will do a binary search and then start test to verify that the commit code of the current hash is OK if the current code test fails, mark it as bad git bisect bad and vice versa if the current code test passes. Repeatedly test and mark good git bisect good until the bad commit is found, and then exit the git bisect mode git bisect reset
Attach the operation flow chart.
Attached official document Git Docs attached binary search visual animation binary search visualization attached my command line operation record wujunze@Mac: ~ / monkey/code/monkey-api develop $git bisect start [20:31:46] wujunze@Mac: ~ / monkey/code/monkey-api develop $git logg [20:31:50] wujunze@Mac: ~ / monkey/code/monkey- Api develop $git bisect good 16e91a8 [20:31:54] wujunze@Mac: ~ / monkey/code/monkey-api develop $git logg [20:31:59] wujunze@Mac: ~ / monkey/code/monkey-api develop $git bisect bad 692ac39 [20:32:04] Bisecting: 9 revisions left to test after this (roughly 3 steps) [cd1a0814fe21aa3e06020efb5aa4118ead17acce] not filter wujunze@Mac: ~ / monkey/code/monkey-api cd1a081 $git bisect bad [20:32:07] Bisecting: 4 revisions left to test after this (roughly 2 steps) [63bf3176854a4fe112d612cee3f6bacce9e77e7d] fix merge wujunze@Mac: ~ / monkey/code/monkey-api 63bf317 $git bisect good [20:32:11] Bisecting: 2 revisions left to test after this (roughly 1 step) [798239a0397c52127c721b8b84bb430b5fd0e83b] debug wujunze@Mac: ~ / monkey/code/monkey-api 798239a $git bisect bad [20:32:14] Bisecting: 0 revisions left to test after this (roughly 0 steps) [5d5dba7c3fc947768cc609493de9808f3d9cf635] fix assert logic wujunze@Mac: ~ / monkey/code/monkey-api 5d5dba7 $git bisect bad [20:32:23] 5d5dba7c3fc947768cc609493de9808f3d9cf635 is the first bad commitcommit 5d5dba7c3fc947768cc609493de9808f3d9cf635Author: wujunze Date: Tue Oct 29 18:20:36 2019 + 0800 fix assert logic:040000 040000 b5d77b6ac82d8427d1bc3a9db2213f6c10ea0d63 3f49c18b6569282f7fa2a2c935b9ba73d6d0fbc0 M app wujunze@Mac: ~ / monkey/code/monkey-api 5d5dba7 $git bisect reset [20:32:27] Previous HEAD position was 5d5dba7 fix assert logicSwitched to branch 'develop'Your branch is up to date with' origin/develop'. Wujunze@Mac: ~ / monkey/code/monkey-api develop $[20:36:38] so far, I believe you have a better understanding of "how to use git bisect to locate BUG in code" You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.