Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

10-git-internals transfer-protocols 中 SSH 小节的例子是否有问题? #147

Closed
zwpaper opened this issue Jun 24, 2015 · 10 comments
Closed

Comments

@zwpaper
Copy link
Contributor

zwpaper commented Jun 24, 2015

例子如下:

[source,console]
----
$ ssh -x git@server "git-receive-pack 'simplegit-progit.git'"
005bca82a6dff817ec66f4437202690a93763949 refs/heads/master report-status \
    delete-refs side-band-64k quiet ofs-delta \
agent=git/2:2.1.1+github-607-gfba4028 delete-refs
003e085bb3bcb608e1e84b2432f8ecbe6306e7e7 refs/heads/topic
0000
----

0x005b = 91,应为本行长度,即 91 字节,但是

005bca82a6dff817ec66f4437202690a93763949 refs/heads/master report-status \
    delete-refs side-band-64k quiet ofs-delta \
agent=git/2:2.1.1+github-607-gfba4028 delete-refs

的长度为 164,并不是 91。

相应的

003e085bb3bcb608e1e84b2432f8ecbe6306e7e7 refs/heads/topic

的长度为 57,不等于 0x3e,即 62。


于是我自己做测试

ssh -x git@github.com "git-receive-pack 'zwpaper/progit2-zh'"
00ca82d2b8601d253dd1df545d66543d12adba06f73c refs/heads/06-github-4-managing-orgreport-status delete-refs side-band-64k quiet atomic ofs-delta agent=git/2:2.4.0~peff-faster-fetch-pruning-1043-gc837c96
0053f6a3af3bcd0da7f51393a4d746b72346aa12b886 refs/heads/10-git-internals-packfiles
005e83cc8df409dd347e173bcdd9c630bf245185f3f2 refs/heads/double_quote_mark_in_translation_note
003faf9ee732e6977aa621e30c8ceb152375f0911346 refs/heads/master
0057be6fc3f4ce49ed58c5e6e5fd778796bcdec70461 refs/heads/smart_dumb_in_TRANSLATION_NOTE
0000Connection to github.com closed by remote host.
00ca82d2b8601d253dd1df545d66543d12adba06f73c refs/heads/06-github-4-managing-orgreport-status delete-refs side-band-64k quiet atomic ofs-delta agent=git/2:2.4.0~peff-faster-fetch-pruning-1043-gc837c96

第一行,长度为200,0xca = 202。
相应的其它各行也是差两个字节。
我理解可能是 \n\r

但也不应该是书上的例子,不知道谁能说明一下。

@networm
Copy link
Member

networm commented Jun 24, 2015

@zwpaper 我刚才看了一下你这个问题,我觉得例子没有错,因为最可能的原因是不可见字符。可能这些不可见字符在放到这儿时已经弄没了。
要先彻底排除不可见字符的影响,很简单,把命令输出重定向到文件中,用十六进制编辑器打开数数字节就知道了。

$ ssh -x git@github.com "git-receive-pack 'zwpaper/progit2-zh'" > result.bin

打开 result.bin 看看就知道了,我刚才测试了一下,没有问题,输出的结果是正确的。

@networm
Copy link
Member

networm commented Jun 24, 2015

@zwpaper 英文版我也拉取到最新大概看了下,和中文版的例子一样,没有改动,你也可以看下。

@networm
Copy link
Member

networm commented Jun 24, 2015

@zwpaper 另外我刚才用 VIM 文本模式打开过那个结果文件,的确有个不可见字符被转义显示出来了。

@zwpaper
Copy link
Contributor Author

zwpaper commented Jun 24, 2015

@networm 我也去英文版看了一下,但是我怕是我理解不到位,所以先在这边问一下。
我也把输出转到文件中看了一下,我执行的命令的输出是对的,前面 4 个字符指出了本行的长度。

@networm
Copy link
Member

networm commented Jun 24, 2015

@zwpaper 那就没问题了,例子中有不可见字符丢失并没问题,需要的人自己做实验就可以了。

@networm
Copy link
Member

networm commented Jun 24, 2015

@zwpaper 如果没问题的话这个 Issue 可以关闭了。

@zwpaper
Copy link
Contributor Author

zwpaper commented Jun 24, 2015

@networm 我的意思是自己执行的命令可以看出前面 4 个字符是指的本行长度,但是例子的输出应该是有问题的,例子的行长度甚至比行首 4 个字符所说明的还要长。

@networm
Copy link
Member

networm commented Jun 24, 2015

@zwpaper 那需要给作者提一个 Issue,让他重新跑一次这个命令,把原文修正了。然后我们也可以拉取新的。

@zwpaper
Copy link
Contributor Author

zwpaper commented Jun 24, 2015

@networm 我去提一个,问问看。

@networm
Copy link
Member

networm commented Jun 24, 2015

@zwpaper OK

@zwpaper zwpaper closed this as completed Jun 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants