git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git bisect for reachable commits only

From
Christian Couder <christian.couder@gmail.com>
Date
Aug 1, 2016, 15:41 UTC
Message-ID
<CAP8UFD118RdB5dX2-wEm5VnKud7sirHhdC9kvWmXV0eAQHvfsA@mail.gmail.com>
In-Reply-To
<CABEd3j--sxCwv6fWmNxTtdpgwU0_YKbfiFONX6TsQFZGn79yuQ@mail.gmail.com>
On Mon, Aug 1, 2016 at 12:02 PM, Oleg Taranenko <olegtaranenko@gmail.com> wrote:
Show 11 quoted lines
> Guys,
>
> further investigation shows, git bisect is broken from its core... really.
> Let consider 3rd a bit more complicated scenario
>
> #cd ..
> #rm -rf bisect3
> mkdir bisect3
> cd bisect3
> git init
> git touch coffee
git touch is not a git command
> git commit -am "create coffee"
you need to "git add coffee" first otherwise it doesn't work
Show 12 quoted lines
> git branch tee
> echo sugar >> coffee
> git commit -am "add sugar"  # we are still in master branch
> echo "milk" >> coffee
> git commit -am "milk for coffee"
> ex +g/sugar/d -cwq coffee  # introducing 'bug'
> git commit -am "somehow remove sugar"
> echo "mixing..." >> coffee
> git commit -am "coffee mixing"
>
> git checkout tee            # get back to coffee without sugar
> git touch tee

git touch is not a git command it might be an alias you have that does `touch "$@" && git add "$@"`

Show 56 quoted lines
> git commit -am "tee"
>
> git branch cocktail
> echo "sugar" >> tee
> git commit -am "sugar for tee"
> echo "milk" >> tee
> git commit -am "milk for tee"
> echo "mixing..." >> tee
> git commit -am "tee mixing"
>
> git checkout cocktail
> git touch cocktail
> git commit -am "prepare cocktail"
> echo orange >>cocktail
> git commit -am "add orange juice"
> echo rum >>cocktail
> git commit -am "add rum"
> echo mixing >> cocktail
> git commit -am "cocktail mixing"
> cat cocktail  #orange, rum, mixing
> git merge tee
> git merge master
>
> git touch serve
> git commit -am "serving..."
>
> git log --full-history --graph --pretty=oneline
>
> * 059adf903a2cbc06fe05dda4c916e2c586907f23 serving...
> *   efc89d5253d3126defc7362c25ef069ae9b43fc7 Merge branch 'master' into cocktail
> |\
> | * dd41e230a3cac5d51a1e994747ff470e2af03cae coffee mixing
> | * c2a44672f1197f34e04cd0fd66434a2b286b574e somehow remove sugar
> | * f50352cfb6bc4a237b73c95ed7ebca074603ae11 milk for coffee
> | * 79b253b316cdc3668697afe473610e35b453ab2f add sugar
> * |   2d626eb5cfaa40a4503be58a5ed27f1ececa6d02 Merge branch 'tee' into cocktail
> |\ \
> | * | 7aba690c6c6f73f1906871c9dbf9737ec11a152b tee mixing
> | * | eca611a93697359ec7a52f4a045461180bc365c3 milk for tee
> | * | 7d6844724d0e81751ec1a67c1ffdf0d0fb932350 sugar for tee
> * | | 6754e816922989d5870ec3452437bbbe6aca4d0f cocktail mixing
> * | | 5cbbf0f0882c497590838b163210db3a393b647e add rum
> * | | b46d7d8a361daae382fbef7acabda5416d23da46 add orange juice
> * | | e571fdd09582e40fc54ffc5a4f112eac2b9f2c8e prepare cocktail
> |/ /
> * | 041a5a53704bccc60c489f8c9a4742bad79d5a95 tee
> |/
> * a52a4fa6770d000a9f4e9e297739a6dc88c0cc50 create coffee
>
> As you can see, no tricks with amended history, but...
>
> git bisect start HEAD 79b2
> Bisecting: 8 revisions left to test after this (roughly 3 steps)
> [6754e816922989d5870ec3452437bbbe6aca4d0f] cocktail mixing
> cat coffee
> git bisect bad

Why is it bad? Is it because there is no sugar? In this case you are searching for a commit that removed sugar.

Show 19 quoted lines
> Bisecting: 2 revisions left to test after this (roughly 1 step)
> [e571fdd09582e40fc54ffc5a4f112eac2b9f2c8e] prepare cocktail
> git bisect bad
> Bisecting: 0 revisions left to test after this (roughly 0 steps)
> [041a5a53704bccc60c489f8c9a4742bad79d5a95] tee
> git bisect bad
> 041a5a53704bccc60c489f8c9a4742bad79d5a95 is the first bad commit
> commit 041a5a53704bccc60c489f8c9a4742bad79d5a95
> Author: Oleg Taranenko <olegtaranenko@gmail.com>
> Date:   Mon Aug 1 10:53:52 2016 +0200
>
>     tee
>
> :000000 100644 0000000000000000000000000000000000000000
> e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 A tee
>
> git bisect ever not looked into the path where good commit is
> declared. Instead it found somehow most common ancestor from whole
> tree (a52a create coffee),  assume it is GOOD commit (why !?)

Yes, and the reason is that all the ancestors of a good commit are considered good. That's because git bisect supposes that there is only one transition from good to bad. Otherwise we would need a more complex algorithm to find all the transitions from good to bad, and that is not generally needed.

Show 7 quoted lines
> and
> check only ^1 (not ^2) parent commit for testing as a potential bug
> commit.
> No wonder now, I got a disaster result, looking in my heavy enterprise
> repository.
>
> Can somebody take care of this issue?
I haven't looked at your previous issue much, sorry I have been busy these days.
Previous: Oleg TaranenkoNext: Junio C Hamano
Message 7 of 14 in “git bisect for reachable commits only”
  1. Oleg TaranenkoJul 29, 2016
  2. Junio C HamanoJul 29, 2016
  3. Oleg TaranenkoJul 31, 2016
  4. Jakub NarębskiJul 31, 2016
  5. Junio C HamanoAug 1, 2016
  6. Oleg TaranenkoAug 1, 2016
  7. Christian CouderAug 1, 2016
  8. Junio C HamanoAug 1, 2016
  9. Christian CouderAug 1, 2016
  10. Junio C HamanoAug 1, 2016
  11. Oleg TaranenkoAug 2, 2016
  12. Stefan BellerAug 2, 2016
  13. Junio C HamanoAug 2, 2016
  14. Oleg TaranenkoAug 4, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.