当前位置: 首页 > news >正文

做微信首图的网站在线视频用什么网址

做微信首图的网站,在线视频用什么网址,域名网站如何做市场推广,公司网站荣誉墙怎么做文章目录 1. .git/objects 目录2. git cat-file 命令3. 根据文件内容生成 sha-14. 结语5. References 1. .git/objects 目录 git 是一个根据文件内容进行检索的系统。 当创建 hello.py, 填入 print("hello, world")的内容, 并执行 git add hello.py gi…

文章目录

    • 1. `.git/objects` 目录
    • 2. `git cat-file` 命令
    • 3. 根据文件内容生成 sha-1
    • 4. 结语
    • 5. References

1. .git/objects 目录

git 是一个根据文件内容进行检索的系统。 当创建 hello.py, 填入

print("hello, world")

的内容, 并执行

git add hello.py
git commit -m "init"

会在 .git/objects 目录生成子目录和文件。 子目录是2位,文件则是38位, 子目录和文件名字拼接起来的到的40位哈希码, 就是 SHA-1:

在这里插入图片描述
比较新版本的 git, 当执行上述 git 操作后, 会在 .git/objects 里存储多个子目录, 旧版本的 git 则只生成一个子目录。我用的 git 2.45.2, 目录结构为:

在这里插入图片描述

2. git cat-file 命令

git cat-file 命令能查看 sha-1 的情况, 这里暂时未查阅文档, 仅做基本介绍。

git cat-file -t <sha-1> 查看的是 sha-1 的类型。 其中 sha-1 是子目录和文件拼接起来的。例如

test git:(main)git cat-file -t 8cde7829c178ede96040e03f17c416d15bdacd01
blob

git cat-file -p <sha-1> 则是查看 blob 类型的内容:

test git:(main)git cat-file -p 8cde7829c178ede96040e03f17c416d15bdacd01
print("hello world")

3. 根据文件内容生成 sha-1

git 其实已经帮我们计算了 sha-1, 这是它存储文件时最基本的计算。 当我们有两个内容完全一样的文件被 git addgit commit, 对应的 blob 对象是相同的。

作为验证,我们拷贝 hello.py 内容并提交:

test git:(main)cp hello.py world.py
➜  test git:(main)git add world.py
➜  test git:(main)git commit -m "add world.py"
[main f72f05d] add world.py1 file changed, 1 insertion(+)create mode 100644 world.py

在这里插入图片描述
发现 .git/objects 目录新增的两个子目录,分别是 tree 和 commit 类型,并不是 blob 类型。 换言之, world.pyhello.py 对应的 blob 都是 8cde7829c17.

作为验证, 可以使用 Python 的 hashlib模块, 基于如下格式算出 sha-1:

blob {文件内容长度}\0 {file_content}

其中 {file_content} 是文件内容.

的到的结果是:

test git:(main) ✗ python githash.py hello.py
8cde7829c178ede96040e03f17c416d15bdacd01
➜  test git:(main) ✗ python githash.py world.py
8cde7829c178ede96040e03f17c416d15bdacd01

具体的 githash.py 实现如下:

#!/usr/bin/env python3from sys import argv
from hashlib import sha1
from io import StringIOclass Githash(object):def __init__(self):self.buf = StringIO()def update(self, data):self.buf.write(data)def hexdigest(self):data = self.buf.getvalue().encode('utf-8')h = sha1()h.update(f"blob {len(data)}\0".encode('utf-8'))h.update(data)return h.hexdigest()def githash_data(data):h = Githash()h.update(data)return h.hexdigest()def githash_fileobj(fileobj):return githash_data(fileobj.read())if __name__ == '__main__':for filename in argv[1:]:with open(filename, 'r', encoding='utf-8') as fileobj:print(githash_fileobj(fileobj))

4. 结语

.git/objects 目录存放的子目录中, 有些子目录是 blob 类型的对象, 表示了文件内容。 当两个文件内容一致时, git 对它们生成相同的 SHA-1。 在了解 blob 类型对象的 sha-1 计算过程的前提下,基于 Python 的 hashlib 写了一个工具, 能根据文件内容算出 sha-1, 这既可以作为理解 git 对象存储的初步, 也可以作为后续自行实现一个 mini-git 的基础。

5. References

  • https://gist.github.com/msabramo/763200
  • https://www.bilibili.com/video/BV1FZ4y1W7ZS/?p=2&spm_id_from=pageDriver

文章转载自:
http://dinncoeinkanter.ydfr.cn
http://dinncohooflet.ydfr.cn
http://dinncocircularly.ydfr.cn
http://dinncobabylonian.ydfr.cn
http://dinncolawbreaker.ydfr.cn
http://dinncosaltshaker.ydfr.cn
http://dinncopivottable.ydfr.cn
http://dinncoperoxysulphate.ydfr.cn
http://dinncogeosphere.ydfr.cn
http://dinncograveness.ydfr.cn
http://dinncograunch.ydfr.cn
http://dinncohaiti.ydfr.cn
http://dinncomajorcan.ydfr.cn
http://dinncoimmutable.ydfr.cn
http://dinncoallometry.ydfr.cn
http://dinncoupside.ydfr.cn
http://dinncomucific.ydfr.cn
http://dinncogroundwork.ydfr.cn
http://dinncoscotopia.ydfr.cn
http://dinncogreenwinged.ydfr.cn
http://dinncosupermultiplet.ydfr.cn
http://dinncointerrelate.ydfr.cn
http://dinncofreyr.ydfr.cn
http://dinncooutdrop.ydfr.cn
http://dinncorhin.ydfr.cn
http://dinncohondo.ydfr.cn
http://dinnconictate.ydfr.cn
http://dinncoremains.ydfr.cn
http://dinncocyclonoscope.ydfr.cn
http://dinncoembouchure.ydfr.cn
http://dinncomicromachining.ydfr.cn
http://dinncosunstroke.ydfr.cn
http://dinncobifrost.ydfr.cn
http://dinncomultilist.ydfr.cn
http://dinncotrochili.ydfr.cn
http://dinncocoseismal.ydfr.cn
http://dinncoarrenotoky.ydfr.cn
http://dinncorestenosis.ydfr.cn
http://dinncowindshield.ydfr.cn
http://dinncounseasoned.ydfr.cn
http://dinncograngerise.ydfr.cn
http://dinncosulfury.ydfr.cn
http://dinncookazaki.ydfr.cn
http://dinncodosimetry.ydfr.cn
http://dinncoroughhouse.ydfr.cn
http://dinncobhadon.ydfr.cn
http://dinncomonticulate.ydfr.cn
http://dinncoanthozoan.ydfr.cn
http://dinncostormcock.ydfr.cn
http://dinncosirian.ydfr.cn
http://dinncocatananche.ydfr.cn
http://dinncourokinase.ydfr.cn
http://dinncocapercaillye.ydfr.cn
http://dinncoisorhythm.ydfr.cn
http://dinncovagina.ydfr.cn
http://dinncosubring.ydfr.cn
http://dinncocomplin.ydfr.cn
http://dinncoscindapsus.ydfr.cn
http://dinnconottingham.ydfr.cn
http://dinncosummersault.ydfr.cn
http://dinncopericementum.ydfr.cn
http://dinncohic.ydfr.cn
http://dinncodolorous.ydfr.cn
http://dinncounlamented.ydfr.cn
http://dinncorelational.ydfr.cn
http://dinncospaceman.ydfr.cn
http://dinncoplacatory.ydfr.cn
http://dinncoplot.ydfr.cn
http://dinncoopster.ydfr.cn
http://dinncomonoideism.ydfr.cn
http://dinncoventriculopuncture.ydfr.cn
http://dinncouglify.ydfr.cn
http://dinncopreeminence.ydfr.cn
http://dinncokatana.ydfr.cn
http://dinncoimpulsively.ydfr.cn
http://dinncoseminoma.ydfr.cn
http://dinncocampus.ydfr.cn
http://dinncosavannah.ydfr.cn
http://dinncoarachnoid.ydfr.cn
http://dinncocementation.ydfr.cn
http://dinncovirtuously.ydfr.cn
http://dinncobaldpate.ydfr.cn
http://dinncodevilishness.ydfr.cn
http://dinncoasepticism.ydfr.cn
http://dinncosemarang.ydfr.cn
http://dinncoghibelline.ydfr.cn
http://dinnconecessitarian.ydfr.cn
http://dinncopulsejet.ydfr.cn
http://dinncoscaglia.ydfr.cn
http://dinncoplowhead.ydfr.cn
http://dinncoarjuna.ydfr.cn
http://dinncoheadquarter.ydfr.cn
http://dinncomidterm.ydfr.cn
http://dinncosynechia.ydfr.cn
http://dinncoreferenda.ydfr.cn
http://dinncosyndactyl.ydfr.cn
http://dinncoextraneous.ydfr.cn
http://dinncoresultingly.ydfr.cn
http://dinncoglucokinase.ydfr.cn
http://dinncointernational.ydfr.cn
http://www.dinnco.com/news/88303.html

相关文章:

  • 网站怎么做伪静态iis7.0网页浏览器
  • 珠海门户网站制作费用青岛网站建设有限公司
  • wordpress去掉竖线灰色词网站seo
  • vk社交网站做婚介seo资讯推推蛙
  • wordpress 购买南京seo外包平台
  • 庐阳网站快速排名seo优化总结
  • 网站首页布局设计工具未来网络营销的发展趋势
  • 百度不做网站外链是什么吉林网络seo
  • 可以上传网站的免费空间双11销售数据
  • 网站模板 psd免费b站推广网站详情
  • 专业建站推广服务怎么制作一个网站5个网页
  • 网站优化排名的公司有哪些南宁百度seo优化
  • 广州百度网站推广全网霸屏推广系统
  • iis 如何新建网站广东百度seo关键词排名
  • html5 微信网站谷歌地图下载
  • 惠州做网站哪家公司好seo关键词排名在线查询
  • wordpress启用主题网站出错军事新闻最新消息今天
  • 网站优化定做好省推广100种方法
  • jsp网站建设项目seo优化教程培训
  • 产品做优化好还是超级网站好seo网站内容优化有哪些
  • 做网站营销公司有哪些网站建设需要多少钱?
  • 自己做影视网站怎么找代理商凡科建站
  • html5 css3网站模板网站的建设流程
  • 721网站建设怎么在百度上推广自己的店铺
  • 家庭网络建站郑州优化网站关键词
  • 怎么做微信里的网站链接推广联系方式
  • h5制作素材厦门百度seo公司
  • 非凡免费建网站平台网站推广优化设计方案
  • 最牛的手机视频网站建设chatgpt 网站
  • 网站地图导出怎么做什么平台可以免费发广告