The LibGit2 module could do with some work. Some possible changes
LibGit2.checkout instead of LibGit2.branch!! suffixEnum and FlagEnum (pending #19470) for constants whenever possiblerebase! will silently abort if it failsrevparse as wellStrArrayStruct: manually calls Libc.malloc, but then frees via LibGit2 git_strarray_freeBuffer: is an immutable object, but needs a finalizerSignatureStruct, GitSignature, Signature objects should be simplifiedLibGit2.get into more usefully-named functionsGitBlob(repo::GitRepo, hash::GitHash)GitObject, automatically resolve its type via git_object_type functionLibGit2.get(T, repo, oid) should throw an error (TypeError?) if incorrect type T is used.GitConfig objects act like an Associative{String,String} (i.e. overload getindex/setindex!)GitAnyObject to GitUnknownObject #19935Oid to GitHash #19878GitHash and short hashes: see https://github.com/JuliaLang/julia/pull/19878#issuecomment-270714556LibGit2.fetch should return nothing (since it will throw an error for any other value)LibGit2.reset! and rebase should return current HEAD commitLibGit2.upstream and LibGit2.lookup_branch should throw errors if not found, instead of returning nothingGitHash objects as null values.newbase option for rebase! (cf https://github.com/JuliaLang/julia/pull/19651#discussion_r94463640)Base.next(::LibGit2.Rebase) (or until new iteration protocol is in place)LibGit2.owner and LibGit2.repositorywith and explicit finalize/close calls (pending #19660)show methods for various objectsGitBlobGitCommitGitRemoteGitSignatureGitTagGitTreeEntryGitReferenceGitIndexDiffDeltaDiffFileFetchHeadGitTreeGitDiffGitAnnotatedGitRebasegit_*_options structsisdiff to a more descriptive name (https://github.com/JuliaLang/julia/pull/20155#discussion_r97181726)cat?content.Some of these are breaking, so we may want to get the deprecations in place before 0.6.
I should say that I would love some help with this if anyone is keen.
Maybe add a
item to that list.
Currently we have show for:
Oid (soon to be Hash)GitErrorIndexEntryRebaseOperationThe IndexEntry and RebaseOperation ones are really barebones.
One issue that has arisen a couple of times now (e.g. https://github.com/JuliaLang/PkgDev.jl/issues/101) is how to check if an object is in a repo, then do or not do something, e.g. in calls to GitBlob(repo, ...).
The old code would return nothing, which is probably not a good idea as (1) it's type unstable, and (2) it is returning a type of a different object than called by the constructor.
Two possible options, neither of which I'm particularly keen on:
Nullable{GitBlob}(repo, ...) method:nobj = Nullable{GitBlob}(repo, hash)
if !isnull(nobj)
obj = get(nobj)
...
end
tryobject or something)?in method:if hash in repo
obj = GitBlob(repo, hash)
...
end
GitBlob, and not say, a GitCommit?getindex(repo, ...)?Any better ideas? Or preferences on which is the least worst?
always returning Nullable{result} for most of these (probably using a function name instead of the type constructor name as the exported API) is what I'd prefer
any suggestions for such a name?
query_blob?
are_you_there_blob_its_me_margaret?
i_cant_believe_its_not_blobcedonia
tryobject?
functions should mirror CLI (command line interface) git functionality when possible
- e.g. LibGit2.checkout instead of LibGit2.branch!
- possible exceptions when CLI does multiple things in one go
Does this mean that LibGit2.checkout won't be able to create a branch? I would be ok with that.
The other problem is that you often want to know the reason why the field is null, e.g. https://github.com/JuliaLang/julia/pull/20752/files#diff-82889f262e9bc3ab1b675224c253a830R163
What if we were to define a special GitNullable type?:
immutable GitNullable{T}
code::Error.Code
value::T
end
Base.isnull(x::GitNullable) = x.code != Error.GIT_OK
and we were to create lower-level "try" interfaces based on this?
Not really a libgit2-specific concept, but would certainly be useful here. Ref https://github.com/iamed2/ResultTypes.jl
Here's a confusing one that I came across in #20916: git checkout can do several different things:
--patch option)-b/-B option)On the other hand, the libgit2 git_checkout_* functions only do 1 (and available in Julia via, e.g. checkout_tree). At the moment, we provide functionality for 1 & 2 via checkout! and 1,2 & 3 via branch!.
Too late for 0.6, but it would be nice to have a better and more consistent way to handle this.
I think the trying to emulate the git CLI one-on-one is not the best idea 鈥撀爐he ways that it's overloaded are confusing and hard to use, IMO. Probably better to have a cleaner API that's more like an easy-to-use version of the libgit2 API.
Another one: in a couple of places it is useful to immediately peel an object obtained from a GitHash or refspec (i.e. to get the GitTree underlying a GitCommit).
Two options:
GitTree(repo, hash, peel=true)
peel, e.g.:peel(GitTree, repo, hash)