libgit2 / libgit2/pygit2

algos to sort the entries:readme-edits

未关闭
#1,006 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
Python
星标
1.7k
派生
408
平均合并
2 天 57 分钟
30 天内合并 PR
7

描述

I found the problem: git_tree.entries uses 2 different algos to sort the entries:

entry_search_cmp and entry_sort_cmp
entry_search_cmp makes an alphabetic sort, but entry_sort_cmp is more sophisticated (directories and files are not sorted the same way).

So i see 3 solutions:
1- We need to sort the list alphabetically before make the search (problem: git_vector_bsearch2 makes a sort)
2- We split entry_search_cmp into 2 functions: entry_search_file_cmp and entry_search_dir_cmp, we use gitfo_cmp_path and we search for a file and after for a directory.
3- Maybe we can always (everywhere) use an alphabetic sort???
4- An other better solution, ...

I made this patch:

https://github.com/versmisse/libgit2/commit/8ee19a25ab4b54ff583bb46093610db0f53d2ab5

to test the solution and it works fine with git_tree_entry_byname. But it is not very clean (i change a private member (_cmp)) and incomplete (we must find a solution for all bsearch2 in the code).

Originally posted by @versmisse in https://github.com/libgit2/libgit2/issues/127#issuecomment-1038775

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 git_tree.entries、entry_search_cmp、entry_sort_cmp 以及 issue 中描述的 git_vector_bsearch2 调用开始。比较链接的补丁,并为 git_tree_entry_byname 和其他 bsearch2 的使用确定一致的搜索与排序策略;完成的标准是 entry 查找行为正确,且不通过修改 private member 作为变通方案。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
devtools
Issue 类型
缺陷
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
需要澄清
新手友好度
20/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。