modocache / gift Goto Github PK
View Code? Open in Web Editor NEWSwift bindings to libgit2. But you should use https://github.com/SwiftGit2/SwiftGit2 instead!
License: MIT License
Swift bindings to libgit2. But you should use https://github.com/SwiftGit2/SwiftGit2 instead!
License: MIT License
Currently Gift is built as an OS X framework, and so can only be used in OS X projects.
StatusDeltaOptions
takes an array of paths when initialized. This is a list of path or path patterns to files that should be included in the status delta enumeration. However, these paths are not passed to libgit2--thus any paths specified by the user are ignored.
Were Gift to allocate unsafe pointers to those paths, to be used by git_strarray, those pointers would have to be freed after they are no longer needed. Gift doesn't have a good way to ensure those pointers are freed yet.
rake dependencies build
is broken on my Mac. I haven't tried to debug it yet.
Just a git clone
and then rake dependencies build
.
[ 96%] Building C object CMakeFiles/git2.dir/src/unix/map.c.o
[ 97%] Building C object CMakeFiles/git2.dir/src/unix/realpath.c.o
[ 98%] Building C object CMakeFiles/git2.dir/deps/http-parser/http_parser.c.o
[ 99%] Building C object CMakeFiles/git2.dir/src/hash/hash_generic.c.o
In file included from /Users/erg/sedit/deps/Gift/External/libgit2/src/hash/hash_generic.c:10:
/Users/erg/sedit/deps/Gift/External/libgit2/src/hash/hash_generic.h:13:8: error: redefinition of 'git_hash_ctx'
struct git_hash_ctx {
^
/Users/erg/sedit/deps/Gift/External/libgit2/src/hash/hash_common_crypto.h:15:8: note: previous definition is here
struct git_hash_ctx {
^
/Users/erg/sedit/deps/Gift/External/libgit2/src/hash/hash_generic.c:121:11: error: no member named 'H' in 'struct git_hash_ctx'
A = ctx->H[0];
~~~ ^
/Users/erg/sedit/deps/Gift/External/libgit2/src/hash/hash_generic.c:122:11: error: no member named 'H' in 'struct git_hash_ctx'
B = ctx->H[1];
~~~ ^
/Users/erg/sedit/deps/Gift/External/libgit2/src/hash/hash_generic.c:123:11: error: no member named 'H' in 'struct git_hash_ctx'
C = ctx->H[2];
~~~ ^
/Users/erg/sedit/deps/Gift/External/libgit2/src/hash/hash_generic.c:124:11: error: no member named 'H' in 'struct git_hash_ctx'
D = ctx->H[3];
~~~ ^
/Users/erg/sedit/deps/Gift/External/libgit2/src/hash/hash_generic.c:125:11: error: no member named 'H' in 'struct git_hash_ctx'
E = ctx->H[4];
~~~ ^
/Users/erg/sedit/deps/Gift/External/libgit2/src/hash/hash_generic.c:217:7: error: no member named 'H' in 'struct git_hash_ctx'
ctx->H[0] += A;
~~~ ^
/Users/erg/sedit/deps/Gift/External/libgit2/src/hash/hash_generic.c:218:7: error: no member named 'H' in 'struct git_hash_ctx'
ctx->H[1] += B;
~~~ ^
/Users/erg/sedit/deps/Gift/External/libgit2/src/hash/hash_generic.c:219:7: error: no member named 'H' in 'struct git_hash_ctx'
ctx->H[2] += C;
~~~ ^
/Users/erg/sedit/deps/Gift/External/libgit2/src/hash/hash_generic.c:220:7: error: no member named 'H' in 'struct git_hash_ctx'
ctx->H[3] += D;
~~~ ^
/Users/erg/sedit/deps/Gift/External/libgit2/src/hash/hash_generic.c:221:7: error: no member named 'H' in 'struct git_hash_ctx'
ctx->H[4] += E;
~~~ ^
/Users/erg/sedit/deps/Gift/External/libgit2/src/hash/hash_generic.c:224:5: error: redefinition of 'git_hash_init'
int git_hash_init(git_hash_ctx *ctx)
^
/Users/erg/sedit/deps/Gift/External/libgit2/src/hash/hash_common_crypto.h:23:17: note: previous definition is here
GIT_INLINE(int) git_hash_init(git_hash_ctx *ctx)
^
/Users/erg/sedit/deps/Gift/External/libgit2/src/hash/hash_generic.c:226:7: error: no member named 'size' in 'struct git_hash_ctx'
ctx->size = 0;
~~~ ^
/Users/erg/sedit/deps/Gift/External/libgit2/src/hash/hash_generic.c:229:7: error: no member named 'H' in 'struct git_hash_ctx'
ctx->H[0] = 0x67452301;
~~~ ^
/Users/erg/sedit/deps/Gift/External/libgit2/src/hash/hash_generic.c:230:7: error: no member named 'H' in 'struct git_hash_ctx'
ctx->H[1] = 0xefcdab89;
~~~ ^
/Users/erg/sedit/deps/Gift/External/libgit2/src/hash/hash_generic.c:231:7: error: no member named 'H' in 'struct git_hash_ctx'
ctx->H[2] = 0x98badcfe;
~~~ ^
/Users/erg/sedit/deps/Gift/External/libgit2/src/hash/hash_generic.c:232:7: error: no member named 'H' in 'struct git_hash_ctx'
ctx->H[3] = 0x10325476;
~~~ ^
/Users/erg/sedit/deps/Gift/External/libgit2/src/hash/hash_generic.c:233:7: error: no member named 'H' in 'struct git_hash_ctx'
ctx->H[4] = 0xc3d2e1f0;
~~~ ^
/Users/erg/sedit/deps/Gift/External/libgit2/src/hash/hash_generic.c:238:5: error: redefinition of 'git_hash_update'
int git_hash_update(git_hash_ctx *ctx, const void *data, size_t len)
^
/Users/erg/sedit/deps/Gift/External/libgit2/src/hash/hash_common_crypto.h:30:17: note: previous definition is here
GIT_INLINE(int) git_hash_update(git_hash_ctx *ctx, const void *data, size_t len)
/*
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[2]: *** [CMakeFiles/git2.dir/src/hash/hash_generic.c.o] Error 1
make[1]: *** [CMakeFiles/git2.dir/all] Error 2
make: *** [all] Error 2
rake aborted!
RAKE TASK FAILED: mkdir -p External/libgit2/build && \
cd External/libgit2/build && \
cmake -DBUILD_SHARED_LIBS:BOOL=OFF -DBUILD_CLAR:BOOL=OFF -DTHREADSAFE:BOOL=ON ..
cmake --build .
/Users/erg/sedit/deps/Gift/Scripts/helpers.rb:3:in `run'
Scripts/build_osx.rake:22:in `block (3 levels) in <top (required)>'
Tasks: TOP => build => build:osx => build:osx:libgit2
(See full trace by running task with --trace)
I just installed libssl, and my version is different from the version specified in the project file.
Here's some output from the changes I made to Gift.xcodeproj/project.pbxproj
- /usr/local/Cellar/openssl/1.0.1l/lib/libssl.a,
- /usr/local/Cellar/openssl/1.0.1l/lib/libcrypto.a,
+ /usr/local/Cellar/openssl/1.0.1j_1/lib/libssl.a,
+ /usr/local/Cellar/openssl/1.0.1j_1/lib/libcrypto.a,
The README should include step-by-step instructions on how to use Gift from within an OS X or iOS app (the latter being dependent upon #3). Bonus points for including diagrams and images.
Gift already includes all of the infrastructure needed to wrap libgit2 in clean Swift functions, as well as all the test infrastructure needed to test those wrappers. Huzzah!
But it could use some more features. Using Gift, I should be able to (in descending order of importance/difficulty):
git remote add
and git remote rm
git reset
git blame
on a particular file in a repositorygit stash save
and git stash apply
on a working directoryThe following features might be worth working on later:
git_tag_foreach
takes a callback function pointer to a C function--Swift doesn't make it easy to interop with such an API, so this will require writing a C function, getting a pointer to it from Swift, etc. (EDIT: It's possible to use progress callback APIs from Swift, see: dbaeace.)Note that a "remote" repository doesn't have to be an external resource. We can fetch from remotes that exist on the local filesystem--and we should, in order to keep our tests fast!
We don't have to include all these features in the v0.1.0 release, but the more the better!
Use https://github.com/thoughtbot/NimbleFox and https://github.com/ashfurrow/Nimble-Snapshots as templates for how to create a distributable Nimble matcher library.
Gift allows users to specify some aspects of how a revision is checked out. But libgit2 provides even more options that Gift has yet to support. CheckoutOptions
should also allow users to configure the following libgit2 git_checkout_options
attributes:
int disable_filters
, a boolean indicating whether to disable some filters, like CRLF conversionunsigned int dir_mode
unsigned int file_mode
int file_open_flags
unsigned int notify_flags
, a set of git_checkout_notify_t
flagsgit_checkout_notify_cb notify_cb
, a callback fired when an event matching the flags above occursgit_strarray paths
, a set of paths to checkoutgit_tree *baseline
const char *target_directory
, an alternative checkout path for the working directoryconst char *ancestor_label
const char *our_label
const char *their_label
git_checkout_perfdata_cb perfdata_cb
Gift allows users to specify some aspects of how a repository is cloned. But libgit2 provides even more options that Gift has yet to support. CloneOptions
should also allow users to configure the following libgit2 git_clone_options
attributes:
int bare
const char* checkout_branch
, the name of the branch to checkout after cloninggit_signature *signature
, the identity used when updating the refloggit_repository_create_cb repository_cb
git_remote_create_cb remote_cb
, a callback used to create the git_remote
. Dependent upon #18.New contributors should be able to setup the repository's dependencies in a single line on the command line--they're currently just explained (poorly) on the README.
We should consider using a Rakefile--I can stomach the script being dependent on Ruby being installed if that makes it clearer and easier to maintain.
Tests for the Rake tasks would be awesome. But is that even possible?
I started playing around with updating Gift for Swift 2, and was wondering if there has been any work towards this elsewhere? I don't see any branches for it.
One question that I have is what the best course of action would be with regards to error handling. It appears that LlamaKit has been subsumed into the Result project, but Swift 2 also has native error handling capabilities now. Is the Result approach with an Either type preferred, or Swift's own native error handling going forward?
I'd be willing to put some work into this, but don't want to head down a path that isn't the preferred approach.
Contributors should be able to ensure all tests pass before submitting a pull request. Once the repository is made public, Travis CI will use this script to test the repository.
For an example, see Quick's test script.
As I mentioned in #4, I think this should be in a Rakefile or something equally easy to maintain.
Gift allows users to specify how a repository should be initialized. But libgit2 provides even more callbacks that Gift has yet to support. RepositoryInitializationOptions
should also allow users to configure the following libgit2 git_repository_init_options
attributes:
const char *workdir_path
const char *description
const char *template_path
const char *initial_head
const char *origin_url
I want to be able to get the blame information for a file in a repository:
let repository = cloneRepository(NSURL(string: "git://git.libssh2.org/libssh2.git")!)
let blame: Result<Blame, NSError> = repository.flatMap { $0.blame("README.md") }
I want to be able to see who was responsible for which lines. That probably involves porting git_blame_hunk
to Gift as well. Not sure what the API for that should look like, but suggestions welcome!
Most of the TODOs in the project right now are for missing documentation. Remove all TODOs, either by resolving them or by creating a GitHub issue to track it.
libgit2 defined a git_remote
struct, which is something Gift has no notion of. Port git_remote
to Gift in order to support remote operations, like fetching from and pushing to a remote repository.
I want to be able to stash uncommitted changes:
let repository = openRepository(NSURL(fileURLWithPath: "/Users/modocache/Desktop/MyRepo")!)
let index = repository.flatMap { $0.index }
let commit = index.flatMap { $0.stash(message: "Saving some work for another day") }
I'd also like to be able to apply stashed changes somehow. Not sure what that API should look like yet, but suggestions welcome!
Gift allows users to specify callbacks that should be executed when performing remote operations, such as a clone or push. But libgit2 provides even more callbacks that Gift has yet to support. RemoteCallbacks
should also allow users to specify the following libgit2 git_remote_callbacks
callbacks:
git_cred_acquire_cb credentials
, used when the remote requires authentication.git_transport_certificate_check_cb certificate_check
, used to determine whether an unauthenticated connection should proceedint (*update_tips)(const char *refname, const git_oid *a, const git_oid *b, void *data)
, fired whenever a local reference is updated by the remote operationgit_packbuilder_progress pack_progress
, provides progress information on packinggit_push_transfer_progress push_transfer_progress
, provides progress information on pushingint (*push_update_reference)(const char *refname, const char *status, void *data)
, called when references are updated due to a pushlibgit2.a
and friends should be built on users' machines.
@dbgrandi reported an error when running the install scripts because he was using Xcode 6.1, which doesn't know about iPhone simulator 8.2.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.