【问题标题】:git bisect manual vs git bisect rungit bisect 手动与 git bisect 运行
【发布时间】:2020-07-26 14:02:27
【问题描述】:

我正在学习git bisect

让我们猜测以下线性 git 历史:

* A commit-1     # HEAD
* B commit-2
* C commit-3
* D commit-4     # First bad commit
* E commit-5
* F commit-6
* G commit-7
* H commit-8     # Is good

然后,我开始二分:

git bisect start
git bisect bad HEAD      # A commit-1
git bisect good H        # H commit-8

我有一个运行一些测试的脚本,如果我手动运行测试并将每个提交标记为 badgood,它遵循以下步骤:

E commit-5     # OK
C commit-3     # FAIL
D commit-4     # FAIL

所以,它说D commit-4 是第一个错误提交,这是正确的


但是,如果我使用git bisect run ../outside/test.sh,它会执行以下操作:

E commit-5     # OK
C commit-3     # FAIL
B commit-2     # FAIL
A commit-1     # FAIL

A commit-1 是第一个错误提交,这是错误的

所以,如果我理解这里的二分搜索,一旦C commit-3 是错误的,第一个错误的提交应该是它自己或者在下面。

我在这里缺少什么? 为什么他们会有不同的行为? 看起来git bisect run 正在运行不同的算法。

我的git版本是:2.19.0

谢谢

【问题讨论】:

  • 在开始第二个 bisect 会话(即自动运行)之前,您是否 git bisect reset
  • 是的,我做到了。实际上,我将这两个过程重复了两次,但得到了相同的结果
  • 您的 test-repository-and-test-script 是否普遍可用,例如在 GitHub 或类似网站上?
  • 这是一个私人仓库,但我将准备一个公共示例并检查它是如何进行的
  • 嗯,看起来有点像您的test.sh 返回错误的退出状态。如果结果是OK,它应该返回0

标签: git binary-search-tree git-bisect


【解决方案1】:

刚刚发现问题:

我的脚本是:

#!/bin/bash

npm test
echo "STATUS: $?"

exit $?

所以当npm start 返回1echo 语句时,将最新的退出代码更改为0,这是我在exit 中使用的那个。

感谢您指出script

【讨论】:

    猜你喜欢
    • 2020-10-09
    • 1970-01-01
    • 2020-08-23
    • 2018-06-03
    • 2012-01-25
    • 2013-11-03
    • 2017-08-30
    • 2013-06-20
    • 2016-12-25
    相关资源
    最近更新 更多