Git: Equivalent to `--full-history` for` git bisect` and `git blame`

I have been using Git for about 7 years. A few days ago I found behavior that surprised me. I found git log , git blame and git bisect to show this strange behavior. Friend tell me about the --full-history sign on git log , which solved my problem. I want to know, for my own education, is there an equivalent fix for git blame and git bisect .

Feel free to see a problem with this repo: https://dl.dropboxusercontent.com/u/1927707/problematic_repo.7z

Here is his journal:

 $ git log --graph * commit b7a8d7aa001d06eb7491ab5fb447a8dd3aa421a8 | Author: Ram Rachum < ram@rachum.com > | Date: Tue Apr 19 17:45:01 2016 +0300 | | adding more to some-file | * commit 0aa833916e908ea93902a6c4c227f9a884a1bcef |\ Merge: 2413945 3068c7d | | Author: Ram Rachum < ram@rachum.com > | | Date: Tue Apr 19 17:44:31 2016 +0300 | | | | Merge branch 'master' into development | | | * commit 3068c7d2548f1798b6840f73b13a649937339f28 | | Author: Ram Rachum < ram@rachum.com > | | Date: Tue Apr 19 16:02:27 2016 +0300 | | | | Adding sugar to coffee | | * | commit 24139451ab954b1f0a9ef616775a3dba0ac81669 |/ Author: Ram Rachum < ram@rachum.com > | Date: Tue Apr 19 16:01:28 2016 +0300 | | Creating some-file | * commit cf02fbbc40104cd02eea4c7c6f134ef1fd7b5661 Author: Ram Rachum < ram@rachum.com > Date: Tue Apr 19 16:00:47 2016 +0300 Create coffee 

In the very first commit, the coffee file is added. In commit 3068c7d I added the string "sugar" to the coffee file. But then I merged this branch into the development branch, and an error was made in this merge, and the string β€œsugar” was deleted, leaving coffee empty. Then another b7a8d7a commit was b7a8d7a , creating an unrelated change.

Now I look at my coffee and don’t see sugar there. I clearly remember adding sugar to my coffee. I run git log coffee and get this output:

 $ git log coffee commit cf02fbbc40104cd02eea4c7c6f134ef1fd7b5661 Author: Ram Rachum < ram@rachum.com > Date: Tue Apr 19 16:00:47 2016 +0300 Create coffee 

What is it. git log shows neither my original agreement, which added sugar, nor the merger, which removed it. Two very important commits that are missing.

I was upset about an hour by this problem because it happened on a huge corporate repo where teams are much more difficult to find manually.

I also tried using git bisect and git blame to commit two commits, but both of these tools ignored the two commits. git bisect pointed me to a wrong commit after I finished doing all the git bisect bad and git bisect good actions.

Then, as I said at the beginning, a friend pointed me to the --full-history flag:

 $ git log --full-history --graph coffee * commit 0aa833916e908ea93902a6c4c227f9a884a1bcef |\ Merge: cf02fbb 3068c7d | | Author: Ram Rachum < ram@rachum.com > | | Date: Tue Apr 19 17:44:31 2016 +0300 | | | | Merge branch 'master' into development | | | * commit 3068c7d2548f1798b6840f73b13a649937339f28 |/ Author: Ram Rachum < ram@rachum.com > | Date: Tue Apr 19 16:02:27 2016 +0300 | | Adding sugar to coffee | * commit cf02fbbc40104cd02eea4c7c6f134ef1fd7b5661 Author: Ram Rachum < ram@rachum.com > Date: Tue Apr 19 16:00:47 2016 +0300 Create coffee 

This makes me happy because it shows two matching commits: one adds sugar and the merge that removes it. Therefore, my problem is resolved. But I would love to know how to behave git bisect and git blame . Somebody knows?

+7
git version-control git-log git-blame git-bisect
source share
1 answer

Interesting. Since there is no line there, git blame starts completely useless. As noted in the documentation for git blame :

The report does not say anything about rows that have been deleted or replaced; you need to use a tool like git diff or the pickax interface is briefly mentioned in the next paragraph.

In this case, we can run git log -SSugar to find where it went:

 $ git log --pretty=oneline -SSugar 3068c7d2548f1798b6840f73b13a649937339f28 Adding sugar to coffee 

but git blame will not immediately help us find where it came out. (And as you just discovered, if we want to find this line when mentioning files, we may need --full-history , since adding paths (paths) to limit git log commits will take into account also simplifies simplifying the history by trimming each commit to contain only the specified files and then use this TREESAME code.)

Starting with the famous good rev, we can now try --reverse [ edit : I noticed 3068c7d2548f1798b6840f73b13a649937339f28 == master and actually used master here, probably should have used SHA-1 directly]:

 $ git blame --reverse master..HEAD coffee ^3068c7d (Ram Rachum 2016-04-19 16:02:27 +0300 1) Sugar 

This seems to mean that 3068c7d is the last rev that the line exists in, so it needs to be removed in some or all of the children of this particular path, which is true:

 $ git log --oneline --graph --decorate --all * b7a8d7a (HEAD -> development) adding more to some-file * 0aa8339 Merge branch 'master' into development |\ | * 3068c7d (master) Adding sugar to coffee * | 2413945 Creating some-file |/ * cf02fbb Create coffee 

There is only one message, which is a child of 3068c7d , namely 0aa8339 , therefore:

 $ git show -m 0aa8339 commit 0aa833916e908ea93902a6c4c227f9a884a1bcef (from 3068c7d2548f1798b6840f73b1 Merge: 2413945 3068c7d Author: Ram Rachum < ram@rachum.com > Date: Tue Apr 19 17:44:31 2016 +0300 Merge branch 'master' into development diff --git a/coffee b/coffee index 4d0f160..e69de29 100644 --- a/coffee +++ b/coffee @@ -1 +0,0 @@ -Sugar diff --git a/some-file b/some-file new file mode 100644 index 0000000..e69de29 

(we need -m to get git to compare the merge with both parents). And it finds it, in a little roundabout way.


(Meanwhile, there seems to be no cure for the bisect problem. Well, other than "avoid evil sinks" ...)

0
source share

All Articles