Skip to main content



      Home
Home » Eclipse Projects » EGit / JGit » Mismatch between git clone and JGit's cloneRepository
Mismatch between git clone and JGit's cloneRepository [message #1854845] Wed, 14 September 2022 03:47 Go to next message
Eclipse UserFriend
I'm trying to replicate the suggestion in this stackoverflow answer:
https://stackoverflow.com/a/65464092
Basically I tried to replicate
git clone --no-checkout --depth 1 <repo>

with
Git.cloneRepository()
			.setURI(REMOTE)
			.setDirectory(localPath)
			.setDepth(1)
			.setNoCheckout(true)
			.call();

But, instead of showing a list of the files in the repo,
git ls-tree -r HEAD

gives me
fatal: Not a valid object name HEAD

The main difference I see between the files checked out by git/JGit
in .git/ is that in the JGit's version .git/ref/heads/master is missing (while still being referenced in .git/HEAD).
Is there any parameter I'm missing to make this thing work as expected? Thanks.

[Updated on: Wed, 14 September 2022 08:31] by Moderator

Re: Mismatch between git clone and JGit's cloneRepository [message #1854908 is a reply to message #1854845] Sat, 17 September 2022 09:58 Go to previous messageGo to next message
Eclipse UserFriend
No, there is no parameter missing. JGit only sets HEAD correctly if it does a checkout. This might be a bug in JGit, possibly the same as bug 438013. Looks like JGit's CloneCommand should set HEAD in any case, whether it'll do a check-out or not.
Re: Mismatch between git clone and JGit's cloneRepository [message #1854965 is a reply to message #1854908] Tue, 20 September 2022 18:46 Go to previous messageGo to next message
Eclipse UserFriend
The problem with HEAD should be fixed in JGit 6.4.0-SNAPSHOT. But note bug 580769 for a (minor) difference in behavior for shallow clones.
Re: Mismatch between git clone and JGit's cloneRepository [message #1854989 is a reply to message #1854965] Thu, 22 September 2022 07:57 Go to previous messageGo to next message
Eclipse UserFriend
Thanks to all of you.
Is there a maven repo for snapshot versions?
Re: Mismatch between git clone and JGit's cloneRepository [message #1854999 is a reply to message #1854989] Thu, 22 September 2022 15:02 Go to previous message
Eclipse UserFriend
Davide Rossi wrote on Thu, 22 September 2022 11:57
Is there a maven repo for snapshot versions?

Try https://repo.eclipse.org/content/repositories/jgit-snapshots/ .
Previous Topic:Most efficient way to retrieve diffentries across all commits
Next Topic:Limit blob size with cloneRepository (equivalent to --filter=blob:limit=)
Goto Forum:
  


Current Time: Thu May 22 16:37:34 EDT 2025

Powered by FUDForum. Page generated in 0.03330 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top