8000 Allow revwalk to traverse shallow clones by albfan · Pull Request #5268 · libgit2/libgit2 · GitHub
[go: up one dir, main page]

Skip to content

Allow revwalk to traverse shallow clones #5268

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

Closed
wants to merge 1 commit into from

Conversation

albfan
Copy link
Contributor
@albfan albfan commented Oct 15, 2019

This patch allow to traverse shallow clones.

mkdir build
cmake -DBUILD_EXAMPLES=ON -DBUILD_SHARED_LIBS=ON -DTHREADSAFE=ON ..
make
cd build/examples
git clone --depth 5 https://github.com/libgit2/libgit2 shallow-clone
cd shallow-clone
../lg2 log
commit ef5a3851fdece852569ffebf3537883223744a7a
Merge: 1f9b497 3335a03
Author: Patrick Steinhardt <ps@pks.im>
Date:   Fri Oct 11 07:47:17 2019 +0200

    Merge pull request #5257 from henkesn/master
    
    Fix file locking on POSIX OS

commit 1f9b4970c5227909aedd79249eae16585712343f
Merge: 6716e2f ebabb88
Author: Patrick Steinhardt <ps@pks.im>
Date:   Fri Oct 11 07:44:10 2019 +0200

    Merge pull request #5260 from pks-t/pks/cmake3
    
    cmake: update minimum CMake version to v3.5.1
...

That will show 5 commits from master and a bunch of parents from them (not showed all to avoid noise). That match with

git log --graph --oneline --decorate --all
*   ef5a385 (HEAD -> master, origin/master, origin/HEAD) Merge pull request #5257 from henkesn/master
|\  
* \   1f9b497 Merge pull request #5260 from pks-t/pks/cmake3
|\ \  
| | * 3335a03 refs: fix locks getting forcibly removed
* | |   6716e2f Merge pull request #5248 from dlax/parse-patch-empty-files
|\ \ \  
| |_|/  
|/| |   
| | * ebabb88 cmake: update minimum CMake version to v3.5.1
| |/  
|/|   
* |   f04a58b Merge pull request #4445 from tiennou/shallow/dry-commit-parsing
|\ \  
| * | 5cf17e0 commit_list: store in/out-degrees as uint16_t
| * | 5988cf3 (grafted) commit_list: unify commit information parsing
|  /  
* |   0ec0b2b Merge pull request #5239 from pks-t/pks/docker-non-root-builds
|\ \  
* | | 63307cb (grafted) Merge pull request #5226 from pks-t/pks/regexp-api
 / /  
| * b61810b patch_parse: handle patches with new empty files
| * 7032537 (grafted) Merge pull request #5106 from tiennou/fix/ref-api-fixes
* 3c884cc (grafted) azure: avoid building and testing in Docker as root

Basically implement the @arthurschreiber comment #3058 (comment)

TODO:

  • parse <GIT_DIR>/.git/shallow and confirm that parents not finded are expected

I'm not sure if there're corner cases as don't know much about .git/shallow structure.

seems it basically grafted all parents from 5 last comments (or something like that)

$ cat .git/shallow 
3c884cc31a13f63f3d4095e1c7fcf11e003fb019
5988cf34f0c77a426510c3bff665fd8a1e8cceb9
63307cbad7408b38693e73b74560a063da21f530
70325370667370159d5b85690c6dd5db17be3b20

Relates to #3058

@pks-t
Copy link
Member
pks-t commented Oct 17, 2019

Thanks a lot for your pull request.

Please note that there's #5254 already that essentially implements revwalks and some more functionality that's required for shallow clones. As #5254 builds on @tiennou's original work from #4331, which goes a bit deeper than the changes proposed herein, it's likely that #5254 will be merged in favor of your PR.

@albfan
Copy link
Contributor Author
albfan commented Oct 17, 2019

Nice. Let me close this and stick to that. Let's see If I can contribute there.

@albfan albfan closed this Oct 17, 2019
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

Successfully merging this pull request may close these issues.

2 participants
0