var merged =newTile(positions.next,tile.value *2);merged.mergedFrom = [tile, next];self.grid.insertTile(merged);self.grid.removeTile(tile);// Converge the two tiles' positionstile.updatePosition(positions.next);// Update the scoreself.score +=merged.value;// The mighty 2048 tileif (merged.value ===2048) self.won =true;
$ git bisect bad v2.8.0-rc0
Bisecting: 297 revisions left to test after this (roughly 8 steps)
[563e38491eaee6e02643a22c9503d4f774d6c5be] Fifth batch for 2.8 cycle
$ make -j8 && make install
$ git --version
git version 2.7.0.297.g563e384
$ http_proxy=bad_proxy no_proxy=* git ls-remote http://internal-git-server/git/repo.git
fatal: unable to access 'http://internal-git-server/git/repo.git/': Couldn't resolve proxy 'bad_proxy'
对这个版本进行标记。
这是一个坏版本:
$ git bisect bad
Bisecting: 126 revisions left to test after this (roughly 7 steps)
[e572fef9d459497de2bd719747d5625a27c9b41d] Merge branch 'ep/shell-command-substitution-style'
我们可以机械地重复上面4、5的步骤,直到最终定位。但是人工操作很容易出错。如果对版本标记错了,把 good 写成了 bad 或者相反, 就要执行 git bisect reset 重来。(小窍门:git bisect log 可以显示 git bisect 标记操作日志)
#!/bin/sh
make -j8 && make install && \
git --version && \
http_proxy=bad_proxy no_proxy=* \
git ls-remote http://internal-git-server/git/repo.git
case $? in
0)
exit 0
;;
128)
exit 1
;;
*)
exit 128
;;
esac
然后敲下如下命令,开始自动执行二分查找:
$ git bisect run sh git-proxy-bug-test.sh
自动化查找过程可能需要几分钟,站起来走走,休息一下眼睛。再回到座位,最终的定位结果就展现在了眼前:
372370f1675c2b935fb703665358dd5567641107 is the first bad commit
commit 372370f1675c2b935fb703665358dd5567641107
Author: Knut Franke <k.franke@science-computing.de>
Date: Tue Jan 26 13:02:48 2016 +0000
http: use credential API to handle proxy authentication
Currently, the only way to pass proxy credentials to curl is by including them
in the proxy URL. Usually, this means they will end up on disk unencrypted, one
way or another (by inclusion in ~/.gitconfig, shell profile or history). Since
proxy authentication often uses a domain user, credentials can be security
sensitive; therefore, a safer way of passing credentials is desirable.
If the configured proxy contains a username but not a password, query the
credential API for one. Also, make sure we approve/reject proxy credentials
properly.
For consistency reasons, add parsing of http_proxy/https_proxy/all_proxy
environment variables, which would otherwise be evaluated as a fallback by curl.
Without this, we would have different semantics for git configuration and
environment variables.
Helped-by: Junio C Hamano <gitster@pobox.com>
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Helped-by: Elia Pinto <gitter.spiros@gmail.com>
Signed-off-by: Knut Franke <k.franke@science-computing.de>
Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
:040000 040000 de69688dd93e4466c11726157bd2f93e47e67330 d19d021e8d1c2a296b521414112be0966bd9f09a M Documentation
:100644 100644 f46bfc43f9e5e8073563be853744262a1bb4c5d6 dfc53c1e2554e76126459d6cb1f098facac28593 M http.c
:100644 100644 4f97b60b5c8abdf5ab0610382a6d6fa289df2605 f83cfa686823728587b2a803c3e84a8cd4669220 M http.h
二分查找运行成功
解决问题
既然我们知道引入 Bug 的提交,让我们看看这个提交:
$ git show --oneline --stat 372370f1675c2b935fb703665358dd5567641107
372370f http: use credential API to handle proxy authentication
Documentation/config.txt | 10 +++++--
http.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++
http.h | 1 +
3 files changed, 85 insertions(+), 3 deletions(-)
http: honor no_http env variable to bypass proxy
Curl and its families honor several proxy related environment variables:
* http_proxy and https_proxy define proxy for http/https connections.
* no_proxy (a comma separated hosts) defines hosts bypass the proxy.
This command will bypass the bad-proxy and connect to the host directly:
no_proxy=* https_proxy=http://bad-proxy/ \
curl -sk https://google.com/
Before commit 372370f (http: use credential API to handle proxy auth...),
Environment variable "no_proxy" will take effect if the config variable
"http.proxy" is not set. So the following comamnd won't fail if not
behind a firewall.
no_proxy=* https_proxy=http://bad-proxy/ \
git ls-remote https://github.com/git/git
But commit 372370f not only read git config variable "http.proxy", but
also read "http_proxy" and "https_proxy" environment variables, and set
the curl option using:
curl_easy_setopt(result, CURLOPT_PROXY, proxy_auth.host);
This caused "no_proxy" environment variable not working any more.
Set extra curl option "CURLOPT_NOPROXY" will fix this.
Signed-off-by: Jiang Xin <xin.jiang@huawei.com>