├── docs
├── config
│ ├── modules.ddoc
│ ├── settings.ddoc
│ └── all_modules.ddoc
├── assets
│ ├── img
│ │ ├── bird.png
│ │ ├── icon-css3.png
│ │ ├── icon-html5.png
│ │ ├── less-small.png
│ │ ├── github-16px.png
│ │ ├── icon-github.png
│ │ ├── icon-twitter.png
│ │ ├── grid-18px-masked.png
│ │ ├── glyphicons-halflings.png
│ │ ├── responsive-illustrations.png
│ │ ├── glyphicons-halflings-white.png
│ │ └── glyphicons
│ │ │ ├── glyphicons_009_magic.png
│ │ │ ├── glyphicons_042_group.png
│ │ │ ├── glyphicons_079_podium.png
│ │ │ ├── glyphicons_163_iphone.png
│ │ │ ├── glyphicons_266_book_open.png
│ │ │ ├── glyphicons_082_roundabout.png
│ │ │ ├── glyphicons_214_resize_small.png
│ │ │ └── glyphicons_155_show_thumbnails.png
│ ├── ico
│ │ ├── favicon.ico
│ │ ├── apple-touch-icon-114-precomposed.png
│ │ ├── apple-touch-icon-57-precomposed.png
│ │ └── apple-touch-icon-72-precomposed.png
│ └── js
│ │ ├── google-code-prettify
│ │ └── prettify.css
│ │ ├── README.md
│ │ └── application.js
└── bootdoc.css
├── .gitmodules
├── src
├── SciTEDirectory.properties
└── git
│ ├── c
│ ├── all.d
│ ├── net.d
│ ├── odb.d
│ ├── oid.d
│ ├── tag.d
│ ├── attr.d
│ ├── blob.d
│ ├── diff.d
│ ├── pack.d
│ ├── push.d
│ ├── refs.d
│ ├── tree.d
│ ├── util.d
│ ├── clone.d
│ ├── graph.d
│ ├── index.d
│ ├── merge.d
│ ├── notes.d
│ ├── refdb.d
│ ├── reset.d
│ ├── stash.d
│ ├── trace.d
│ ├── types.d
│ ├── branch.d
│ ├── commit.d
│ ├── common.d
│ ├── config.d
│ ├── errors.d
│ ├── ignore.d
│ ├── reflog.d
│ ├── remote.d
│ ├── status.d
│ ├── indexer.d
│ ├── message.d
│ ├── object_.d
│ ├── refspec.d
│ ├── revwalk.d
│ ├── threads.d
│ ├── checkout.d
│ ├── revparse.d
│ ├── strarray.d
│ ├── sys
│ │ ├── refs.d
│ │ ├── index.d
│ │ ├── commit.d
│ │ ├── config.d
│ │ ├── repository.d
│ │ ├── odb_backend.d
│ │ └── refdb_backend.d
│ ├── version_.d
│ ├── signature.d
│ ├── submodule.d
│ ├── transport.d
│ ├── repository.d
│ ├── odb_backend.d
│ ├── cred_helpers.d
│ └── package.d
│ ├── exception.d
│ ├── net.d
│ ├── merge.d
│ ├── package.d
│ ├── LICENSE_1_0.txt
│ ├── config.d
│ ├── revparse.d
│ ├── signature.d
│ ├── revwalk.d
│ ├── object_.d
│ ├── blob.d
│ ├── version_.d
│ ├── types.d
│ ├── trace.d
│ ├── clone.d
│ ├── commit.d
│ ├── util.d
│ ├── branch.d
│ ├── tag.d
│ ├── submodule.d
│ ├── reference.d
│ ├── checkout.d
│ ├── tree.d
│ ├── index.d
│ ├── oid.d
│ ├── common.d
│ ├── diff.d_
│ ├── attribute.d
│ └── transport.d
├── .gitignore
├── samples
├── SciTEDirectory.properties
├── network
│ ├── common.d
│ ├── clone.d
│ ├── ls_remote.d
│ ├── index_pack.d
│ ├── main.d
│ └── fetch.d
├── showindex
│ └── showindex.d
├── build.d
├── merge
│ └── merge.d
└── diff
│ └── diff.d
├── package.json
├── .travis.yml
├── porting.md
├── todo.md
├── tools
└── translate.d
└── README.md
/docs/config/modules.ddoc:
--------------------------------------------------------------------------------
1 | MODULES =
2 | $(MODULE git.repository)
3 |
--------------------------------------------------------------------------------
/docs/assets/img/bird.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/s-ludwig/dlibgit/HEAD/docs/assets/img/bird.png
--------------------------------------------------------------------------------
/docs/assets/ico/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/s-ludwig/dlibgit/HEAD/docs/assets/ico/favicon.ico
--------------------------------------------------------------------------------
/docs/assets/img/icon-css3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/s-ludwig/dlibgit/HEAD/docs/assets/img/icon-css3.png
--------------------------------------------------------------------------------
/docs/assets/img/icon-html5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/s-ludwig/dlibgit/HEAD/docs/assets/img/icon-html5.png
--------------------------------------------------------------------------------
/docs/assets/img/less-small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/s-ludwig/dlibgit/HEAD/docs/assets/img/less-small.png
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "test/repo"]
2 | path = test/repo
3 | url = https://github.com/libgit2/TestGitRepository
4 |
--------------------------------------------------------------------------------
/docs/assets/img/github-16px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/s-ludwig/dlibgit/HEAD/docs/assets/img/github-16px.png
--------------------------------------------------------------------------------
/docs/assets/img/icon-github.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/s-ludwig/dlibgit/HEAD/docs/assets/img/icon-github.png
--------------------------------------------------------------------------------
/docs/assets/img/icon-twitter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/s-ludwig/dlibgit/HEAD/docs/assets/img/icon-twitter.png
--------------------------------------------------------------------------------
/docs/assets/img/grid-18px-masked.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/s-ludwig/dlibgit/HEAD/docs/assets/img/grid-18px-masked.png
--------------------------------------------------------------------------------
/docs/assets/img/glyphicons-halflings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/s-ludwig/dlibgit/HEAD/docs/assets/img/glyphicons-halflings.png
--------------------------------------------------------------------------------
/docs/assets/img/responsive-illustrations.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/s-ludwig/dlibgit/HEAD/docs/assets/img/responsive-illustrations.png
--------------------------------------------------------------------------------
/docs/assets/img/glyphicons-halflings-white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/s-ludwig/dlibgit/HEAD/docs/assets/img/glyphicons-halflings-white.png
--------------------------------------------------------------------------------
/src/SciTEDirectory.properties:
--------------------------------------------------------------------------------
1 | if PLAT_WIN
2 | build=$(SciteDirectoryHome)\..\build\build.bat
3 |
4 | command.go.$(file.patterns.d)=$(build)
5 |
--------------------------------------------------------------------------------
/docs/assets/ico/apple-touch-icon-114-precomposed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/s-ludwig/dlibgit/HEAD/docs/assets/ico/apple-touch-icon-114-precomposed.png
--------------------------------------------------------------------------------
/docs/assets/ico/apple-touch-icon-57-precomposed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/s-ludwig/dlibgit/HEAD/docs/assets/ico/apple-touch-icon-57-precomposed.png
--------------------------------------------------------------------------------
/docs/assets/ico/apple-touch-icon-72-precomposed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/s-ludwig/dlibgit/HEAD/docs/assets/ico/apple-touch-icon-72-precomposed.png
--------------------------------------------------------------------------------
/docs/assets/img/glyphicons/glyphicons_009_magic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/s-ludwig/dlibgit/HEAD/docs/assets/img/glyphicons/glyphicons_009_magic.png
--------------------------------------------------------------------------------
/docs/assets/img/glyphicons/glyphicons_042_group.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/s-ludwig/dlibgit/HEAD/docs/assets/img/glyphicons/glyphicons_042_group.png
--------------------------------------------------------------------------------
/docs/assets/img/glyphicons/glyphicons_079_podium.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/s-ludwig/dlibgit/HEAD/docs/assets/img/glyphicons/glyphicons_079_podium.png
--------------------------------------------------------------------------------
/docs/assets/img/glyphicons/glyphicons_163_iphone.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/s-ludwig/dlibgit/HEAD/docs/assets/img/glyphicons/glyphicons_163_iphone.png
--------------------------------------------------------------------------------
/docs/assets/img/glyphicons/glyphicons_266_book_open.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/s-ludwig/dlibgit/HEAD/docs/assets/img/glyphicons/glyphicons_266_book_open.png
--------------------------------------------------------------------------------
/docs/assets/img/glyphicons/glyphicons_082_roundabout.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/s-ludwig/dlibgit/HEAD/docs/assets/img/glyphicons/glyphicons_082_roundabout.png
--------------------------------------------------------------------------------
/docs/assets/img/glyphicons/glyphicons_214_resize_small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/s-ludwig/dlibgit/HEAD/docs/assets/img/glyphicons/glyphicons_214_resize_small.png
--------------------------------------------------------------------------------
/docs/assets/img/glyphicons/glyphicons_155_show_thumbnails.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/s-ludwig/dlibgit/HEAD/docs/assets/img/glyphicons/glyphicons_155_show_thumbnails.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.rar
2 | *.obj
3 | *.dat
4 | *.exe
5 | *.o
6 | *.lib
7 | *.7z
8 | *.a
9 | *.dll
10 | *.lib
11 | .dub/
12 | bin/*.dll
13 | bin/*.lib
14 | docs/*.html
15 | __test__library__
16 |
--------------------------------------------------------------------------------
/samples/SciTEDirectory.properties:
--------------------------------------------------------------------------------
1 | if PLAT_WIN
2 | build=$(SciteDirectoryHome)\build.d
3 | if PLAT_GTK
4 | build=$(SciteDirectoryHome)\build.d
5 |
6 | command.go.$(file.patterns.d)=rdmd $(build) $(FileNameExt)
7 |
--------------------------------------------------------------------------------
/src/git/c/all.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.all;
3 | public import deimos.git2.all;
4 |
5 | pragma(msg, "Deprecated import git.c.all used. Please import deimos.git2.all instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/net.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.net;
3 | public import deimos.git2.net;
4 |
5 | pragma(msg, "Deprecated import git.c.net used. Please import deimos.git2.net instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/odb.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.odb;
3 | public import deimos.git2.odb;
4 |
5 | pragma(msg, "Deprecated import git.c.odb used. Please import deimos.git2.odb instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/oid.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.oid;
3 | public import deimos.git2.oid;
4 |
5 | pragma(msg, "Deprecated import git.c.oid used. Please import deimos.git2.oid instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/tag.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.tag;
3 | public import deimos.git2.tag;
4 |
5 | pragma(msg, "Deprecated import git.c.tag used. Please import deimos.git2.tag instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/attr.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.attr;
3 | public import deimos.git2.attr;
4 |
5 | pragma(msg, "Deprecated import git.c.attr used. Please import deimos.git2.attr instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/blob.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.blob;
3 | public import deimos.git2.blob;
4 |
5 | pragma(msg, "Deprecated import git.c.blob used. Please import deimos.git2.blob instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/diff.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.diff;
3 | public import deimos.git2.diff;
4 |
5 | pragma(msg, "Deprecated import git.c.diff used. Please import deimos.git2.diff instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/pack.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.pack;
3 | public import deimos.git2.pack;
4 |
5 | pragma(msg, "Deprecated import git.c.pack used. Please import deimos.git2.pack instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/push.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.push;
3 | public import deimos.git2.push;
4 |
5 | pragma(msg, "Deprecated import git.c.push used. Please import deimos.git2.push instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/refs.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.refs;
3 | public import deimos.git2.refs;
4 |
5 | pragma(msg, "Deprecated import git.c.refs used. Please import deimos.git2.refs instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/tree.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.tree;
3 | public import deimos.git2.tree;
4 |
5 | pragma(msg, "Deprecated import git.c.tree used. Please import deimos.git2.tree instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/util.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.util;
3 | public import deimos.git2.util;
4 |
5 | pragma(msg, "Deprecated import git.c.util used. Please import deimos.git2.util instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/clone.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.clone;
3 | public import deimos.git2.clone;
4 |
5 | pragma(msg, "Deprecated import git.c.clone used. Please import deimos.git2.clone instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/graph.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.graph;
3 | public import deimos.git2.graph;
4 |
5 | pragma(msg, "Deprecated import git.c.graph used. Please import deimos.git2.graph instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/index.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.index;
3 | public import deimos.git2.index;
4 |
5 | pragma(msg, "Deprecated import git.c.index used. Please import deimos.git2.index instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/merge.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.merge;
3 | public import deimos.git2.merge;
4 |
5 | pragma(msg, "Deprecated import git.c.merge used. Please import deimos.git2.merge instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/notes.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.notes;
3 | public import deimos.git2.notes;
4 |
5 | pragma(msg, "Deprecated import git.c.notes used. Please import deimos.git2.notes instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/refdb.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.refdb;
3 | public import deimos.git2.refdb;
4 |
5 | pragma(msg, "Deprecated import git.c.refdb used. Please import deimos.git2.refdb instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/reset.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.reset;
3 | public import deimos.git2.reset;
4 |
5 | pragma(msg, "Deprecated import git.c.reset used. Please import deimos.git2.reset instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/stash.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.stash;
3 | public import deimos.git2.stash;
4 |
5 | pragma(msg, "Deprecated import git.c.stash used. Please import deimos.git2.stash instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/trace.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.trace;
3 | public import deimos.git2.trace;
4 |
5 | pragma(msg, "Deprecated import git.c.trace used. Please import deimos.git2.trace instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/types.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.types;
3 | public import deimos.git2.types;
4 |
5 | pragma(msg, "Deprecated import git.c.types used. Please import deimos.git2.types instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/branch.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.branch;
3 | public import deimos.git2.branch;
4 |
5 | pragma(msg, "Deprecated import git.c.branch used. Please import deimos.git2.branch instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/commit.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.commit;
3 | public import deimos.git2.commit;
4 |
5 | pragma(msg, "Deprecated import git.c.commit used. Please import deimos.git2.commit instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/common.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.common;
3 | public import deimos.git2.common;
4 |
5 | pragma(msg, "Deprecated import git.c.common used. Please import deimos.git2.common instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/config.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.config;
3 | public import deimos.git2.config;
4 |
5 | pragma(msg, "Deprecated import git.c.config used. Please import deimos.git2.config instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/errors.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.errors;
3 | public import deimos.git2.errors;
4 |
5 | pragma(msg, "Deprecated import git.c.errors used. Please import deimos.git2.errors instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/ignore.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.ignore;
3 | public import deimos.git2.ignore;
4 |
5 | pragma(msg, "Deprecated import git.c.ignore used. Please import deimos.git2.ignore instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/reflog.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.reflog;
3 | public import deimos.git2.reflog;
4 |
5 | pragma(msg, "Deprecated import git.c.reflog used. Please import deimos.git2.reflog instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/remote.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.remote;
3 | public import deimos.git2.remote;
4 |
5 | pragma(msg, "Deprecated import git.c.remote used. Please import deimos.git2.remote instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/status.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.status;
3 | public import deimos.git2.status;
4 |
5 | pragma(msg, "Deprecated import git.c.status used. Please import deimos.git2.status instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/indexer.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.indexer;
3 | public import deimos.git2.indexer;
4 |
5 | pragma(msg, "Deprecated import git.c.indexer used. Please import deimos.git2.indexer instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/message.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.message;
3 | public import deimos.git2.message;
4 |
5 | pragma(msg, "Deprecated import git.c.message used. Please import deimos.git2.message instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/object_.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.object_;
3 | public import deimos.git2.object_;
4 |
5 | pragma(msg, "Deprecated import git.c.object_ used. Please import deimos.git2.object_ instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/refspec.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.refspec;
3 | public import deimos.git2.refspec;
4 |
5 | pragma(msg, "Deprecated import git.c.refspec used. Please import deimos.git2.refspec instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/revwalk.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.revwalk;
3 | public import deimos.git2.revwalk;
4 |
5 | pragma(msg, "Deprecated import git.c.revwalk used. Please import deimos.git2.revwalk instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/threads.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.threads;
3 | public import deimos.git2.threads;
4 |
5 | pragma(msg, "Deprecated import git.c.threads used. Please import deimos.git2.threads instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/checkout.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.checkout;
3 | public import deimos.git2.checkout;
4 |
5 | pragma(msg, "Deprecated import git.c.checkout used. Please import deimos.git2.checkout instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/revparse.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.revparse;
3 | public import deimos.git2.revparse;
4 |
5 | pragma(msg, "Deprecated import git.c.revparse used. Please import deimos.git2.revparse instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/strarray.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.strarray;
3 | public import deimos.git2.strarray;
4 |
5 | pragma(msg, "Deprecated import git.c.strarray used. Please import deimos.git2.strarray instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/sys/refs.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.sys.refs;
3 | public import deimos.git2.sys.refs;
4 |
5 | pragma(msg, "Deprecated import git.c.sys.refs used. Please import deimos.git2.sys.refs instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/version_.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.version_;
3 | public import deimos.git2.version_;
4 |
5 | pragma(msg, "Deprecated import git.c.version_ used. Please import deimos.git2.version_ instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/signature.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.signature;
3 | public import deimos.git2.signature;
4 |
5 | pragma(msg, "Deprecated import git.c.signature used. Please import deimos.git2.signature instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/submodule.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.submodule;
3 | public import deimos.git2.submodule;
4 |
5 | pragma(msg, "Deprecated import git.c.submodule used. Please import deimos.git2.submodule instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/sys/index.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.sys.index;
3 | public import deimos.git2.sys.index;
4 |
5 | pragma(msg, "Deprecated import git.c.sys.index used. Please import deimos.git2.sys.index instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/transport.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.transport;
3 | public import deimos.git2.transport;
4 |
5 | pragma(msg, "Deprecated import git.c.transport used. Please import deimos.git2.transport instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/repository.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.repository;
3 | public import deimos.git2.repository;
4 |
5 | pragma(msg, "Deprecated import git.c.repository used. Please import deimos.git2.repository instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/sys/commit.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.sys.commit;
3 | public import deimos.git2.sys.commit;
4 |
5 | pragma(msg, "Deprecated import git.c.sys.commit used. Please import deimos.git2.sys.commit instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/sys/config.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.sys.config;
3 | public import deimos.git2.sys.config;
4 |
5 | pragma(msg, "Deprecated import git.c.sys.config used. Please import deimos.git2.sys.config instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/odb_backend.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.odb_backend;
3 | public import deimos.git2.odb_backend;
4 |
5 | pragma(msg, "Deprecated import git.c.odb_backend used. Please import deimos.git2.odb_backend instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/cred_helpers.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.cred_helpers;
3 | public import deimos.git2.cred_helpers;
4 |
5 | pragma(msg, "Deprecated import git.c.cred_helpers used. Please import deimos.git2.cred_helpers instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/sys/repository.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.sys.repository;
3 | public import deimos.git2.sys.repository;
4 |
5 | pragma(msg, "Deprecated import git.c.sys.repository used. Please import deimos.git2.sys.repository instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/sys/odb_backend.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.sys.odb_backend;
3 | public import deimos.git2.sys.odb_backend;
4 |
5 | pragma(msg, "Deprecated import git.c.sys.odb_backend used. Please import deimos.git2.sys.odb_backend instead.");
6 |
--------------------------------------------------------------------------------
/src/git/c/sys/refdb_backend.d:
--------------------------------------------------------------------------------
1 | // This file is just a placeholder, please use the libgit2 package directly instead
2 | module git.c.sys.refdb_backend;
3 | public import deimos.git2.sys.refdb_backend;
4 |
5 | pragma(msg, "Deprecated import git.c.sys.refdb_backend used. Please import deimos.git2.sys.refdb_backend instead.");
6 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "dlibgit",
3 | "description": "Library for operating on GIT repositories based on libgit2",
4 | "copyright": "Copyright © 2013 Andrej Mitrovic, 2014 © David Nadlinger, 2014 © Sönke Ludwig",
5 | "license": "LGPL 2",
6 | "authors": ["Andrej Mitrovic", "David Nadlinger", "Sönke Ludwig"],
7 | "dependencies": {
8 | "libgit2": ">=0.19.2 <0.21.0"
9 | },
10 | "excludedSourceFiles": ["src/git/c/*"]
11 | }
12 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: d
2 |
3 | install:
4 | - LIBGIT2_VER=0.20.0
5 | - curl -fsSL https://github.com/libgit2/libgit2/archive/v${LIBGIT2_VER}.tar.gz | tar -xzf -
6 | - pushd libgit2-${LIBGIT2_VER}/
7 | - cmake -DCMAKE_INSTALL_PREFIX=${HOME}/libgit2 .
8 | - make -j2
9 | - make install
10 | - popd
11 | - export LIBRARY_PATH="${HOME}/libgit2/lib:${LIBRARY_PATH}"
12 | - export LD_LIBRARY_PATH="${HOME}/libgit2/lib:${LD_LIBRARY_PATH}"
13 |
14 | script:
15 | - dub test
16 |
--------------------------------------------------------------------------------
/porting.md:
--------------------------------------------------------------------------------
1 | Fully ported modules:
2 |
3 | - git.c.common
4 | - git.c.oid
5 | - git.c.trace
6 | - git.c.ignore (folded into GitRepo)
7 | - git.c.types
8 |
9 | Partially ported modules:
10 |
11 | - git.c.config
12 | - git.c.repository (dependencies on other APIs not yet ported)
13 | - git.c.version_
14 |
15 | Doesn't need porting:
16 |
17 | - git.c.errors (using exceptions)
18 | - git.c.threads (default init/deinit happens in shared module ctor/dtor)
19 | - git.c.message (just one prettifier function)
20 |
--------------------------------------------------------------------------------
/src/git/exception.d:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright Andrej Mitrovic 2013.
3 | * Distributed under the Boost Software License, Version 1.0.
4 | * (See accompanying file LICENSE_1_0.txt or copy at
5 | * http://www.boost.org/LICENSE_1_0.txt)
6 | */
7 | module git.exception;
8 |
9 | /**
10 | Exception thrown when a git operation fails.
11 | */
12 | class GitException : Exception
13 | {
14 | @safe pure nothrow this(string msg, string file = __FILE__, size_t line = __LINE__, Throwable next = null)
15 | {
16 | super(msg, file, line, next);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/docs/config/settings.ddoc:
--------------------------------------------------------------------------------
1 | PROJECTNAME = dlibgit
2 | REFERENCETOP = git.version_.html
3 | REPOSRCTREE = https://github.com/AndrejMitrovic/dlibgit/tree/master
4 | TITLEBARTEXT = dlibgith home
5 | RESOURCEROOT =
6 | ISSUETRACKER = https://github.com/AndrejMitrovic/dlibgit/issues/$1
7 | DEFAULTPACKAGE = git
8 | PACKAGESEP = .
9 | FAVICON = $(RESOURCEROOT)assets/ico/favicon.ico
10 | LOGOSRC = $(RESOURCEROOT)assets/img/icon-github.png
11 | LOGOALT = $(PROJECTNAME)
12 | LOGOLINK = $(REFERENCETOP)
13 | COPYRIGHT = Andrej Mitrovic
14 | COPYRIGHTFOOTER = © $(COPYRIGHT) 2013-$(YEAR)
15 |
--------------------------------------------------------------------------------
/samples/network/common.d:
--------------------------------------------------------------------------------
1 | module common;
2 |
3 | import git.c;
4 |
5 | struct fetch_dl_data
6 | {
7 | git_remote* remote;
8 | git_off_t* bytes;
9 | git_indexer_stats* stats;
10 | int ret;
11 | int finished;
12 | }
13 |
14 | struct clone_dl_data
15 | {
16 | git_indexer_stats fetch_stats;
17 | git_indexer_stats checkout_stats;
18 | git_checkout_opts opts;
19 | int ret;
20 | int finished;
21 | string url;
22 | string path;
23 | }
24 |
25 | // temporary until we figure out a safe alternative
26 | __gshared clone_dl_data clone_data;
27 | __gshared fetch_dl_data fetch_data;
28 |
29 | alias int function(git_repository*, int, string[]) git_cb;
30 |
--------------------------------------------------------------------------------
/src/git/net.d:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright Sönke Ludwig 2014.
3 | * Distributed under the Boost Software License, Version 1.0.
4 | * (See accompanying file LICENSE_1_0.txt or copy at
5 | * http://www.boost.org/LICENSE_1_0.txt)
6 | */
7 | module git.net;
8 |
9 | import git.oid;
10 |
11 | import deimos.git2.net;
12 |
13 | import std.conv;
14 |
15 |
16 | struct GitRemoteHead {
17 | package this(in git_remote_head* h)
18 | {
19 | this.local = h.local != 0;
20 | this.oid = GitOid(h.oid);
21 | this.localOid = GitOid(h.loid);
22 | this.name = h.name.to!string();
23 | }
24 |
25 | bool local;
26 | GitOid oid;
27 | GitOid localOid;
28 | string name;
29 | }
30 |
--------------------------------------------------------------------------------
/src/git/merge.d:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright Vladimir Panteleev 2015.
3 | * Distributed under the Boost Software License, Version 1.0.
4 | * (See accompanying file LICENSE_1_0.txt or copy at
5 | * http://www.boost.org/LICENSE_1_0.txt)
6 | */
7 | module git.merge;
8 |
9 | import deimos.git2.merge;
10 | import deimos.git2.types;
11 |
12 | import git.index;
13 | import git.repository;
14 | import git.tree;
15 | import git.util;
16 |
17 | GitIndex mergeTrees(GitRepo repo, GitTree ancestor_tree, GitTree our_tree, GitTree their_tree, const git_merge_tree_opts* opts = null)
18 | {
19 | git_index* index;
20 | require(git_merge_trees(&index, repo.cHandle(), ancestor_tree.cHandle(), our_tree.cHandle(), their_tree.cHandle(), opts) == 0);
21 | return GitIndex(repo, index);
22 | }
23 |
--------------------------------------------------------------------------------
/docs/assets/js/google-code-prettify/prettify.css:
--------------------------------------------------------------------------------
1 | .com { color: #93a1a1; }
2 | .lit { color: #195f91; }
3 | .pun, .opn, .clo { color: #93a1a1; }
4 | .fun { color: #dc322f; }
5 | .str, .atv { color: #D14; }
6 | .kwd, .linenums .tag { color: #1e347b; }
7 | .typ, .atn, .dec, .var { color: teal; }
8 | .pln { color: #48484c; }
9 |
10 | .prettyprint {
11 | padding: 8px;
12 | background-color: #f7f7f9;
13 | border: 1px solid #e1e1e8;
14 | }
15 | .prettyprint.linenums {
16 | -webkit-box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
17 | -moz-box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
18 | box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
19 | }
20 |
21 | /* Specify class=linenums on a pre to get line numbering */
22 | ol.linenums {
23 | margin: 0 0 0 33px; /* IE indents via margin-left */
24 | }
25 | ol.linenums li {
26 | padding-left: 12px;
27 | color: #bebec5;
28 | line-height: 18px;
29 | text-shadow: 0 1px 0 #fff;
30 | }
--------------------------------------------------------------------------------
/docs/bootdoc.css:
--------------------------------------------------------------------------------
1 | .symbol-target {
2 | padding-top: 40px;
3 | margin-top: -40px;
4 | width: 1px; /* '0' will not work for Opera */
5 | display: inline-block;
6 | }
7 |
8 | .sidebar-list-entry {
9 | white-space: nowrap;
10 | overflow: hidden;
11 | text-overflow: ellipsis;
12 | }
13 |
14 | .highlighted-symbol {
15 | background-color: rgba(255, 200, 0, 0.5);
16 | }
17 |
18 | .declaration-content {
19 | margin: 6px 18px;
20 | }
21 |
22 | .tree-node, .tree-leaf {
23 | text-transform: none;
24 | }
25 |
26 | .custom-icon-list {
27 | list-style-type: none;
28 | }
29 |
30 | .hidden {
31 | display: none;
32 | }
33 |
34 | .d_keyword {
35 | color: blue;
36 | }
37 |
38 | .d_string {
39 | color: red;
40 | }
41 |
42 | .d_comment {
43 | color: gray;
44 | }
45 |
46 | .inlinecode {
47 | font-family: "Consolas", "Bitstream Vera Sans Mono", "Andale Mono", "Monaco", "DejaVu Sans Mono", "Lucida Console", "monospace";
48 | }
49 |
50 | [class*='ddoc-icon-'] {
51 | display: inline-block;
52 | width: 16px;
53 | height: 16px;
54 | }
55 |
--------------------------------------------------------------------------------
/src/git/package.d:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright Andrej Mitrovic 2013.
3 | * Distributed under the Boost Software License, Version 1.0.
4 | * (See accompanying file LICENSE_1_0.txt or copy at
5 | * http://www.boost.org/LICENSE_1_0.txt)
6 | */
7 | module git;
8 |
9 | public
10 | {
11 | import git.attribute;
12 | import git.blob;
13 | import git.branch;
14 | import git.checkout;
15 | import git.clone;
16 | import git.commit;
17 | import git.common;
18 | import git.config;
19 | import git.credentials;
20 | import git.exception;
21 | import git.index;
22 | import git.net;
23 | import git.object_;
24 | import git.oid;
25 | import git.reference;
26 | import git.remote;
27 | import git.repository;
28 | import git.revparse;
29 | import git.revwalk;
30 | import git.signature;
31 | import git.submodule;
32 | import git.tag;
33 | import git.trace;
34 | import git.transport;
35 | import git.tree;
36 | import git.types;
37 | import git.version_;
38 | }
39 |
40 | private
41 | {
42 | import deimos.git2.all;
43 | import git.util;
44 | }
45 |
--------------------------------------------------------------------------------
/src/git/LICENSE_1_0.txt:
--------------------------------------------------------------------------------
1 | Boost Software License - Version 1.0 - August 17th, 2003
2 |
3 | Permission is hereby granted, free of charge, to any person or organization
4 | obtaining a copy of the software and accompanying documentation covered by
5 | this license (the "Software") to use, reproduce, display, distribute,
6 | execute, and transmit the Software, and to prepare derivative works of the
7 | Software, and to permit third-parties to whom the Software is furnished to
8 | do so, all subject to the following:
9 |
10 | The copyright notices in the Software and this entire statement, including
11 | the above license grant, this restriction and the following disclaimer,
12 | must be included in all copies of the Software, in whole or in part, and
13 | all derivative works of the Software, unless such copies or derivative
14 | works are solely in the form of machine-executable object code generated by
15 | a source language processor.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
20 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
21 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
22 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 | DEALINGS IN THE SOFTWARE.
24 |
--------------------------------------------------------------------------------
/samples/showindex/showindex.d:
--------------------------------------------------------------------------------
1 | module showindex;
2 |
3 | import git.c;
4 |
5 | import std.stdio;
6 | import std.string;
7 | import std.exception;
8 |
9 | void main(string[] args)
10 | {
11 | if (args.length < 2)
12 | {
13 | writeln("Must pass path to .git folder.");
14 | return;
15 | }
16 |
17 | size_t i, ecount;
18 | git_oid oid;
19 |
20 | char[41] _out = '\0';
21 |
22 | git_repository* repo;
23 | auto res = git_repository_open(&repo, toStringz(args[1]));
24 |
25 | git_index* index;
26 | git_repository_index(&index, repo);
27 | git_index_read(index);
28 |
29 | ecount = git_index_entrycount(index);
30 |
31 | for (i = 0; i < ecount; ++i)
32 | {
33 | const e = git_index_get_byindex(index, i);
34 |
35 | oid = e.oid;
36 | git_oid_fmt(_out.ptr, &oid);
37 |
38 | printf("File Path: %s\n", e.path);
39 | printf(" Blob SHA: %s\n", &_out);
40 | printf("File Size: %d\n", cast(int)e.file_size);
41 | printf(" Device: %d\n", cast(int)e.dev);
42 | printf(" Inode: %d\n", cast(int)e.ino);
43 | printf(" UID: %d\n", cast(int)e.uid);
44 | printf(" GID: %d\n", cast(int)e.gid);
45 | printf(" ctime: %d\n", cast(int)e.ctime.seconds);
46 | printf(" mtime: %d\n", cast(int)e.mtime.seconds);
47 | printf("\n");
48 | }
49 |
50 | git_index_free(index);
51 |
52 | git_repository_free(repo);
53 | }
54 |
--------------------------------------------------------------------------------
/todo.md:
--------------------------------------------------------------------------------
1 | ## things to do for the D wrapper library
2 |
3 | - Write a build script that generates docs in the docs folder
4 | - Create .ddoc file for the docs (grab some from H. S. Teoh)
5 | - Move build scripts to build folder
6 | - Create separate version structs for libgit2 and dlibgit
7 | - use https://github.com/libgit2/TestGitRepository for samples
8 | - assert or in blocks should be used to verify arguments (such as strings)
9 | before calling Git functions since Git itself does not check pointers for null.
10 | Passing null pointers to Git functions usually results in access violations.
11 | - make build script avoid using -unittest if test\repo dir is missing, and issue
12 | a warning that the user should update the submodules in order to test the library
13 | - Use checkout commands before testing isHeadDetached and isHeadOrphan to improve
14 | the sample code.
15 | - Replace static asserts in unittests with normal asserts and calls. We have to
16 | create several repositories with interesting state before the e.g. walker
17 | functions can operate on.
18 | - Add global hashFile function that redirects to git_odb_hashfile, it's referenced in
19 | GitRepo.hashFile which uses filtering.
20 | - Detab all files, but be careful about detabbing string literals which must embed tab characters.
21 |
22 | ## bugs to file to libgit2 (or pulls to make-
23 | - git_repository_discover dosc reference base_path instead of start_path
24 | - it also seems to mention that if 'acrossFS' is true lookup stops, but it should be if it's false
25 |
--------------------------------------------------------------------------------
/samples/build.d:
--------------------------------------------------------------------------------
1 | module build;
2 |
3 | import std.exception;
4 | import std.range;
5 | import std.file;
6 | import std.path;
7 | import std.process;
8 | import std.string;
9 | import std.stdio;
10 |
11 | version(Windows)
12 | {
13 | string libArg = r"bin\libgit2_implib.lib";
14 | string binPath = r"bin\";
15 | enum string exeExt = ".exe";
16 | }
17 | else
18 | {
19 | string libArg = "-Lbin/ -L-lgit2";
20 | string binPath = "bin/";
21 | enum string exeExt = "";
22 | }
23 |
24 | void main(string[] args)
25 | {
26 | args.popFront();
27 | if (args.empty)
28 | {
29 | writeln("Error: Pass a .d file to compile.");
30 | return;
31 | }
32 |
33 | string arg = args.front;
34 |
35 | string proj = arg.stripExtension.baseName;
36 | string outFile = format("%s%s%s", binPath, proj, exeExt);
37 |
38 | string path1 = buildPath(".".absolutePath, "src/git2").buildNormalizedPath;
39 | string path2 = buildPath(".".absolutePath, "../../src/git2").buildNormalizedPath;
40 |
41 | string dlibgitPath = path1.exists ? path1 : path2;
42 | dlibgitPath = buildPath(dlibgitPath, "../").buildNormalizedPath;
43 | enforce(dlibgitPath.exists);
44 |
45 | string basePath = buildPath(dlibgitPath, "../");
46 |
47 | libArg = buildPath(basePath, libArg).buildNormalizedPath;
48 | outFile = buildPath(basePath, outFile).buildNormalizedPath;
49 |
50 | string cmd = format("rdmd --force --build-only -m32 %s -I%s -of%s %s", libArg, dlibgitPath, outFile, arg);
51 | system(cmd);
52 | }
53 |
54 |
--------------------------------------------------------------------------------
/src/git/config.d:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright Andrej Mitrovic 2013.
3 | * Distributed under the Boost Software License, Version 1.0.
4 | * (See accompanying file LICENSE_1_0.txt or copy at
5 | * http://www.boost.org/LICENSE_1_0.txt)
6 | */
7 | module git.config;
8 |
9 | import deimos.git2.config;
10 |
11 | /**
12 | Priority level of a config file.
13 | These priority levels correspond to the natural escalation logic
14 | (from higher to lower) when searching for config entries in git.git.
15 |
16 | todo: fix up the docs here:
17 |
18 | git_config_open_default() and git_repository_config() honor those
19 | priority levels as well.
20 | */
21 | enum GitConfigLevel
22 | {
23 | /** System-wide configuration file; /etc/gitconfig on Linux systems. */
24 | system = GIT_CONFIG_LEVEL_SYSTEM,
25 |
26 | /** XDG compatible configuration file; typically ~/.config/git/config. */
27 | xdg = GIT_CONFIG_LEVEL_XDG,
28 |
29 | /**
30 | User-specific configuration file (also called Global configuration file),
31 | typically ~/.gitconfig.
32 | */
33 | global = GIT_CONFIG_LEVEL_GLOBAL,
34 |
35 | /** Repository specific configuration file - $WORK_DIR/.git/config on non-bare repos. */
36 | local = GIT_CONFIG_LEVEL_LOCAL,
37 |
38 | /** Application specific configuration file - freely defined by applications. */
39 | app = GIT_CONFIG_LEVEL_APP,
40 |
41 | /**
42 | Represents the highest level available config file (i.e. the most
43 | specific config file available that actually is loaded).
44 | */
45 | highest = GIT_CONFIG_HIGHEST_LEVEL,
46 | }
47 |
--------------------------------------------------------------------------------
/src/git/c/package.d:
--------------------------------------------------------------------------------
1 | module git.c;
2 |
3 | pragma(msg, "Deprecated import git.c used. Please import deimos.git2 instead.");
4 |
5 | public
6 | {
7 | import git.c.attr;
8 | import git.c.blob;
9 | import git.c.branch;
10 | import git.c.checkout;
11 | import git.c.clone;
12 | import git.c.commit;
13 | import git.c.common;
14 | import git.c.config;
15 | import git.c.cred_helpers;
16 | import git.c.diff;
17 | import git.c.errors;
18 | import git.c.graph;
19 | import git.c.ignore;
20 | import git.c.index;
21 | import git.c.indexer;
22 | import git.c.merge;
23 | import git.c.message;
24 | import git.c.net;
25 | import git.c.notes;
26 | import git.c.object_;
27 | import git.c.odb;
28 | import git.c.odb_backend;
29 | import git.c.oid;
30 | import git.c.pack;
31 | import git.c.push;
32 | import git.c.refdb;
33 | import git.c.reflog;
34 | import git.c.refs;
35 | import git.c.refspec;
36 | import git.c.remote;
37 | import git.c.repository;
38 | import git.c.reset;
39 | import git.c.revparse;
40 | import git.c.revwalk;
41 | import git.c.signature;
42 | import git.c.stash;
43 | import git.c.status;
44 | import git.c.strarray;
45 | import git.c.submodule;
46 | import git.c.tag;
47 | import git.c.threads;
48 | import git.c.trace;
49 | import git.c.transport;
50 | import git.c.tree;
51 | import git.c.types;
52 | import git.c.version_;
53 | import git.c.sys.commit;
54 | import git.c.sys.config;
55 | import git.c.sys.index;
56 | import git.c.sys.odb_backend;
57 | import git.c.sys.refdb_backend;
58 | import git.c.sys.refs;
59 | import git.c.sys.repository;
60 | }
61 |
--------------------------------------------------------------------------------
/samples/network/clone.d:
--------------------------------------------------------------------------------
1 | module clone;
2 |
3 | import git.c;
4 |
5 | import core.thread;
6 | import std.concurrency;
7 | import std.string;
8 | import std.stdio;
9 |
10 | import common;
11 |
12 | void clone_thread()
13 | {
14 | git_repository* repo = null;
15 |
16 | // Kick off the clone
17 | clone_data.ret = git_clone(&repo, toStringz(clone_data.url), toStringz(clone_data.path),
18 | &clone_data.fetch_stats, &clone_data.checkout_stats,
19 | &clone_data.opts);
20 |
21 | if (repo)
22 | git_repository_free(repo);
23 |
24 | clone_data.finished = 1;
25 | }
26 |
27 | int do_clone(git_repository* repo, int argc, string[] args)
28 | {
29 | // Validate args
30 | if (argc < 3)
31 | {
32 | writefln("USAGE: %s \n", args[0]);
33 | return -1;
34 | }
35 |
36 | // Data for background thread
37 | clone_data.url = args[1];
38 | clone_data.path = args[2];
39 | clone_data.opts.disable_filters = 1;
40 | writefln("Cloning '%s' to '%s'", clone_data.url, clone_data.path);
41 |
42 | // Create the worker thread
43 | spawn(&clone_thread);
44 |
45 | // Watch for progress information
46 | do {
47 | Thread.sleep(dur!("msecs")(100));
48 | writefln("Fetch %s/%s – Checkout %s/%s",
49 | clone_data.fetch_stats.processed, clone_data.fetch_stats.total,
50 | clone_data.checkout_stats.processed, clone_data.checkout_stats.total);
51 | } while (!clone_data.finished);
52 |
53 | writefln("Fetch %s/%s – Checkout %s/%s",
54 | clone_data.fetch_stats.processed, clone_data.fetch_stats.total,
55 | clone_data.checkout_stats.processed, clone_data.checkout_stats.total);
56 |
57 | return clone_data.ret;
58 | }
59 |
--------------------------------------------------------------------------------
/samples/merge/merge.d:
--------------------------------------------------------------------------------
1 | import std.file;
2 | import std.path;
3 |
4 | import git.blob;
5 | import git.checkout;
6 | import git.commit;
7 | import git.index;
8 | import git.merge;
9 | import git.oid;
10 | import git.repository;
11 | import git.signature;
12 | import git.tree;
13 | import git.types;
14 |
15 | pragma(lib, "git2");
16 |
17 | GitTree addDir(ref GitRepo repo, string path)
18 | {
19 | auto tb = createTreeBuilder();
20 | foreach (de; dirEntries(path, SpanMode.shallow))
21 | {
22 | GitOid oid = de.isDir ? repo.addDir(de.name).id : repo.createBlob(cast(ubyte[])de.name.read());
23 | tb.insert(de.baseName, oid, de.isDir ? GitFileModeType.tree : GitFileModeType.blob);
24 | }
25 | return repo.lookupTree(tb.write(repo));
26 | }
27 |
28 | void forceEmptyDirectory(string dir)
29 | {
30 | if (dir.exists)
31 | dir.rmdirRecurse();
32 | dir.mkdir();
33 | }
34 |
35 | void main()
36 | {
37 | enum repoPath = "test-repo";
38 | repoPath.forceEmptyDirectory();
39 | auto repo = initRepository(repoPath, OpenBare.no);
40 |
41 | enum dataPath = "test-data";
42 | dataPath.forceEmptyDirectory();
43 | write(dataPath ~ "/a", "a\nb\nc\nd\ne");
44 | auto baseTree = repo.addDir(dataPath);
45 |
46 | write(dataPath ~ "/a", "a\nb2\nc\nd\ne");
47 | auto branch1 = repo.addDir(dataPath);
48 |
49 | write(dataPath ~ "/a", "a\nb\nc\nd2\ne");
50 | auto branch2 = repo.addDir(dataPath);
51 |
52 | enum workPath = "test-work";
53 | workPath.forceEmptyDirectory();
54 | repo.setWorkPath(workPath);
55 |
56 | auto index = repo.mergeTrees(baseTree, branch1, branch2);
57 | enforce(!index.hasConflicts, "Conflict detected");
58 |
59 | auto oid = index.writeTree(repo);
60 | GitCheckoutOptions opts = {strategy : GitCheckoutStrategy.force};
61 | repo.checkout(repo.lookupTree(oid), opts);
62 |
63 | assert(readText(workPath ~ "/a") == "a\nb2\nc\nd2\ne");
64 | }
65 |
--------------------------------------------------------------------------------
/src/git/revparse.d:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright Sönke Ludwig 2014.
3 | * Distributed under the Boost Software License, Version 1.0.
4 | * (See accompanying file LICENSE_1_0.txt or copy at
5 | * http://www.boost.org/LICENSE_1_0.txt)
6 | */
7 | module git.revparse;
8 |
9 | import git.commit;
10 | import git.object_;
11 | import git.oid;
12 | import git.reference;
13 | import git.repository;
14 | import git.types;
15 | import git.util;
16 | import git.version_;
17 |
18 | import deimos.git2.revparse;
19 | import deimos.git2.errors;
20 | import deimos.git2.types;
21 |
22 | import std.conv : to;
23 | import std.string : toStringz;
24 | import std.typecons : Tuple, tuple;
25 |
26 |
27 | GitObject revparseSingle(GitRepo repo, string spec)
28 | {
29 | git_object* ret;
30 | require(git_revparse_single(&ret, repo.cHandle, spec.toStringz) == 0);
31 | return GitObject(repo, ret);
32 | }
33 |
34 | Tuple!(GitObject, GitReference) revparseExt(GitRepo repo, string spec)
35 | {
36 | git_object* obj;
37 | git_reference* ref_;
38 | require(git_revparse_ext(&obj, &ref_, repo.cHandle, spec.toStringz) == 0);
39 | return tuple(GitObject(repo, obj), GitReference(repo, ref_));
40 | }
41 |
42 | GitRevSpec revparse(GitRepo repo, string spec)
43 | {
44 | git_revspec dst;
45 | require(git_revparse(&dst, repo.cHandle, spec.toStringz) == 0);
46 | return GitRevSpec(repo, dst);
47 | }
48 |
49 | struct GitRevSpec {
50 | package this(GitRepo repo, git_revspec spec)
51 | {
52 | from = GitObject(repo, spec.from);
53 | to = GitObject(repo, spec.to);
54 | flags = cast(GitRevparseModeFlags)spec.flags;
55 | }
56 |
57 | GitObject from;
58 | GitObject to;
59 | GitRevparseModeFlags flags;
60 | }
61 |
62 | enum GitRevparseModeFlags {
63 | single = GIT_REVPARSE_SINGLE,
64 | range = GIT_REVPARSE_RANGE,
65 | mergeBase = GIT_REVPARSE_MERGE_BASE
66 | }
67 |
--------------------------------------------------------------------------------
/docs/config/all_modules.ddoc:
--------------------------------------------------------------------------------
1 | MODULES =
2 | $(MODULE git.all)
3 | $(MODULE git.package)
4 | $(MODULE git.version_)
5 | $(MODULE git.c.all)
6 | $(MODULE git.c.attr)
7 | $(MODULE git.c.blob)
8 | $(MODULE git.c.branch)
9 | $(MODULE git.c.checkout)
10 | $(MODULE git.c.clone)
11 | $(MODULE git.c.commit)
12 | $(MODULE git.c.common)
13 | $(MODULE git.c.config)
14 | $(MODULE git.c.cred_helpers)
15 | $(MODULE git.c.diff)
16 | $(MODULE git.c.errors)
17 | $(MODULE git.c.graph)
18 | $(MODULE git.c.ignore)
19 | $(MODULE git.c.index)
20 | $(MODULE git.c.indexer)
21 | $(MODULE git.c.merge)
22 | $(MODULE git.c.message)
23 | $(MODULE git.c.net)
24 | $(MODULE git.c.notes)
25 | $(MODULE git.c.object_)
26 | $(MODULE git.c.odb)
27 | $(MODULE git.c.odb_backend)
28 | $(MODULE git.c.oid)
29 | $(MODULE git.c.pack)
30 | $(MODULE git.c.package)
31 | $(MODULE git.c.push)
32 | $(MODULE git.c.refdb)
33 | $(MODULE git.c.reflog)
34 | $(MODULE git.c.refs)
35 | $(MODULE git.c.refspec)
36 | $(MODULE git.c.remote)
37 | $(MODULE git.c.repository)
38 | $(MODULE git.c.reset)
39 | $(MODULE git.c.revparse)
40 | $(MODULE git.c.revwalk)
41 | $(MODULE git.c.signature)
42 | $(MODULE git.c.stash)
43 | $(MODULE git.c.status)
44 | $(MODULE git.c.strarray)
45 | $(MODULE git.c.submodule)
46 | $(MODULE git.c.tag)
47 | $(MODULE git.c.threads)
48 | $(MODULE git.c.trace)
49 | $(MODULE git.c.transport)
50 | $(MODULE git.c.tree)
51 | $(MODULE git.c.types)
52 | $(MODULE git.c.util)
53 | $(MODULE git.c.version_)
54 | $(MODULE git.c.sys.commit)
55 | $(MODULE git.c.sys.config)
56 | $(MODULE git.c.sys.index)
57 | $(MODULE git.c.sys.odb_backend)
58 | $(MODULE git.c.sys.refdb_backend)
59 | $(MODULE git.c.sys.refs)
60 | $(MODULE git.c.sys.repository)
61 |
--------------------------------------------------------------------------------
/samples/network/ls_remote.d:
--------------------------------------------------------------------------------
1 | module ls_remote;
2 |
3 | import git.c;
4 |
5 | import std.algorithm;
6 | import std.stdio;
7 | import std.string;
8 |
9 | extern(C) int show_ref__cb(git_remote_head* head, void* payload)
10 | {
11 | char[GIT_OID_HEXSZ + 1] oid = '\0';
12 | git_oid_fmt(oid.ptr, &head.oid);
13 | printf("%s\t%s\n", oid.ptr, head.name);
14 | return 0;
15 | }
16 |
17 | int use_unnamed(git_repository* repo, const char* url)
18 | {
19 | git_remote* remote = null;
20 | int error;
21 |
22 | // Create an instance of a remote from the URL. The transport to use
23 | // is detected from the URL
24 | error = git_remote_create_inmemory(&remote, repo, null, url);
25 |
26 | if (error < 0)
27 | goto cleanup;
28 |
29 | // When connecting, the underlying code needs to know wether we
30 | // want to push or fetch
31 | error = git_remote_connect(remote, git_direction.GIT_DIRECTION_FETCH);
32 |
33 | if (error < 0)
34 | goto cleanup;
35 |
36 | // With git_remote_ls we can retrieve the advertised heads
37 | error = git_remote_ls(remote, &show_ref__cb, null);
38 |
39 | cleanup:
40 | git_remote_free(remote);
41 | return error;
42 | }
43 |
44 | int use_remote(git_repository* repo, const(char)* name)
45 | {
46 | git_remote* remote = null;
47 | int error;
48 |
49 | // Find the remote by name
50 | error = git_remote_load(&remote, repo, name);
51 |
52 | if (error < 0)
53 | goto cleanup;
54 |
55 | error = git_remote_connect(remote, git_direction.GIT_DIRECTION_FETCH);
56 |
57 | if (error < 0)
58 | goto cleanup;
59 |
60 | error = git_remote_ls(remote, &show_ref__cb, null);
61 |
62 | cleanup:
63 | git_remote_free(remote);
64 | return error;
65 | }
66 |
67 | // This gets called to do the work. The remote can be given either as
68 | // the name of a configured remote or an URL.
69 | int run_ls_remote(git_repository* repo, int argc, string[] argv)
70 | {
71 | if (argc < 2)
72 | {
73 | writeln("I need a remote.\n");
74 | return -1;
75 | }
76 |
77 | int error;
78 | int i;
79 |
80 | /* If there's a ':' in the name, assume it's a URL */
81 | if (argv[1].canFind(":"))
82 | {
83 | error = use_unnamed(repo, argv[1].toStringz);
84 | }
85 | else
86 | {
87 | error = use_remote(repo, argv[1].toStringz);
88 | }
89 |
90 | return error;
91 | }
92 |
--------------------------------------------------------------------------------
/src/git/signature.d:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright Sönke Ludwig 2014.
3 | * Distributed under the Boost Software License, Version 1.0.
4 | * (See accompanying file LICENSE_1_0.txt or copy at
5 | * http://www.boost.org/LICENSE_1_0.txt)
6 | */
7 | module git.signature;
8 |
9 | import git.commit;
10 | import git.oid;
11 | import git.repository;
12 | import git.tag;
13 | import git.types;
14 | import git.util;
15 | import git.version_;
16 |
17 | import deimos.git2.signature;
18 | import deimos.git2.types;
19 |
20 | import std.conv : to;
21 | import std.datetime;
22 | import std.string : toStringz;
23 |
24 | static if (targetLibGitVersion >= VersionInfo(0, 20, 0)) {
25 | GitSignature createDefaultSignature(GitRepo repo)
26 | {
27 | git_signature* ret;
28 | require(git_signature_default(&ret, repo.cHandle) == 0);
29 | return GitSignature(ret);
30 | }
31 | }
32 |
33 | GitSignature createSignature(string name, string email, SysTime time)
34 | {
35 | git_signature* ret;
36 | auto gittime = toGitTime(time);
37 | require(git_signature_new(&ret, name.toStringz, email.toStringz, gittime.time, gittime.offset) == 0);
38 | return GitSignature(ret);
39 | }
40 |
41 | GitSignature createSignature(string name, string email)
42 | {
43 | git_signature* ret;
44 | require(git_signature_now(&ret, name.toStringz, email.toStringz) == 0);
45 | return GitSignature(ret);
46 | }
47 |
48 | struct GitSignature {
49 | package this(git_signature* sig)
50 | {
51 | _commit = GitCommit.init;
52 | _tag = GitTag.init;
53 | _data = Data(sig);
54 | }
55 |
56 | package this(GitCommit owner, const(git_signature)* sig)
57 | {
58 | _commit = owner;
59 | _tag = GitTag.init;
60 | _sig = sig;
61 | }
62 |
63 | package this(GitTag owner, const(git_signature)* sig)
64 | {
65 | _commit = GitCommit.init;
66 | _tag = owner;
67 | _sig = sig;
68 | }
69 |
70 | @property SysTime time() const { return _sig.when.toSysTime(); }
71 | @property string name() const { return _sig.name.to!string; }
72 | @property string email() const { return _sig.email.to!string; }
73 | @property GitSignature dup() { return GitSignature(git_signature_dup(this.cHandle)); }
74 |
75 | package const(git_signature)* cHandle() const { return _sig ? _sig : _data._payload; }
76 |
77 | mixin RefCountedGitObject!(git_signature, git_signature_free, false);
78 |
79 | private:
80 | // Reference to the parent commit to keep it alive.
81 | GitCommit _commit;
82 | GitTag _tag;
83 | const(git_signature)* _sig;
84 | }
85 |
--------------------------------------------------------------------------------
/samples/network/index_pack.d:
--------------------------------------------------------------------------------
1 | module index_pack;
2 |
3 | import git.c;
4 |
5 | import std.stdio;
6 | import std.exception;
7 |
8 | // This could be run in the main loop while the application waits for
9 | // the indexing to finish in a worker thread
10 | int index_cb(const git_indexer_stats* stats, void* data)
11 | {
12 | writefln("\rProcessing %s of %s", stats.processed, stats.total);
13 | return 0;
14 | }
15 |
16 | int run_index_pack(git_repository* repo, int argc, string[] argv)
17 | {
18 | git_indexer_stream* idx;
19 | git_indexer_stats stats;
20 | int error;
21 | int fd;
22 | char[GIT_OID_HEXSZ + 1] hash = '\0';
23 | byte[512] buf;
24 |
25 | if (argc < 2)
26 | {
27 | writeln("I need a packfile\n");
28 | return -1;
29 | }
30 |
31 | if (git_indexer_stream_new(&idx, ".git") < 0)
32 | {
33 | writeln("bad idx");
34 | return -1;
35 | }
36 |
37 | scope(exit)
38 | git_indexer_stream_free(idx);
39 |
40 | File file = File(argv[1], "r");
41 |
42 | while (1)
43 | {
44 | byte[] read_bytes = file.rawRead(buf);
45 |
46 | enforce(git_indexer_stream_add(idx, read_bytes.ptr, read_bytes.length, &stats) >= 0);
47 | printf("\rIndexing %d of %d", stats.processed, stats.total);
48 |
49 | if (read_bytes.length < buf.length)
50 | break;
51 | }
52 |
53 | enforce(git_indexer_stream_finalize(idx, &stats) >= 0);
54 |
55 | writefln("\nIndexing %d of %d", stats.processed, stats.total);
56 |
57 | git_oid_fmt(hash.ptr, git_indexer_stream_hash(idx));
58 | writefln("Hash: %s\n", hash);
59 | return 0;
60 | }
61 |
62 | int index_pack_old(git_repository* repo, int argc, char** argv)
63 | {
64 | git_indexer* indexer;
65 | git_indexer_stats stats;
66 | int error;
67 | char[GIT_OID_HEXSZ + 1] hash;
68 |
69 | if (argc < 2)
70 | {
71 | writeln("I need a packfile\n");
72 | return -1;
73 | }
74 |
75 | // Create a new indexer
76 | error = git_indexer_new(&indexer, argv[1]);
77 |
78 | if (error < 0)
79 | return error;
80 |
81 | // Index the packfile. This function can take a very long time and
82 | // should be run in a worker thread.
83 | error = git_indexer_run(indexer, &stats);
84 |
85 | if (error < 0)
86 | return error;
87 |
88 | // Write the information out to an index file
89 | error = git_indexer_write(indexer);
90 |
91 | // Get the packfile's hash (which should become it's filename)
92 | git_oid_fmt(hash.ptr, git_indexer_hash(indexer));
93 | writeln(hash);
94 |
95 | git_indexer_free(indexer);
96 |
97 | return 0;
98 | }
99 |
--------------------------------------------------------------------------------
/src/git/revwalk.d:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright Sönke Ludwig 2014.
3 | * Distributed under the Boost Software License, Version 1.0.
4 | * (See accompanying file LICENSE_1_0.txt or copy at
5 | * http://www.boost.org/LICENSE_1_0.txt)
6 | */
7 | module git.revwalk;
8 |
9 | import git.commit;
10 | import git.oid;
11 | import git.repository;
12 | import git.types;
13 | import git.util;
14 | import git.version_;
15 |
16 | import deimos.git2.errors;
17 | import deimos.git2.revwalk;
18 | import deimos.git2.types;
19 |
20 | import std.conv : to;
21 | import std.string : toStringz;
22 |
23 | // TODO: range interface?
24 |
25 |
26 | GitRevWalk createRevWalk(GitRepo repo)
27 | {
28 | git_revwalk* ret;
29 | require(git_revwalk_new(&ret, repo.cHandle) == 0);
30 | return GitRevWalk(repo, ret);
31 | }
32 |
33 | enum GitSortFlags {
34 | none = GIT_SORT_NONE,
35 | topological = GIT_SORT_TOPOLOGICAL,
36 | time = GIT_SORT_TIME,
37 | reverse = GIT_SORT_REVERSE
38 | }
39 |
40 | struct GitRevWalk {
41 | package this(GitRepo repo, git_revwalk* revwalk)
42 | {
43 | _repo = repo;
44 | _data = Data(revwalk);
45 | }
46 |
47 | @property void sortMode(GitSortFlags mode) { git_revwalk_sorting(this.cHandle, mode); }
48 | @property inout(GitRepo) repository() inout { return _repo; }
49 |
50 | void push(GitOid oid) { require(git_revwalk_push(this.cHandle, &oid._get_oid()) == 0); }
51 | void pushGlob(string glob) { require(git_revwalk_push_glob(this.cHandle, glob.toStringz) == 0); }
52 | void pushHead() { require(git_revwalk_push_head(this.cHandle) == 0); }
53 | void pushRef(string refname) { require(git_revwalk_push_ref(this.cHandle, refname.toStringz) == 0); }
54 | void pushRange(string range) { require(git_revwalk_push_range(this.cHandle, range.toStringz) == 0); }
55 |
56 | void hide(GitOid commit_id) { require(git_revwalk_hide(this.cHandle, &commit_id._get_oid()) == 0); }
57 | void hideGlob(string glob) { require(git_revwalk_hide_glob(this.cHandle, glob.toStringz) == 0); }
58 | void hideHead() { require(git_revwalk_hide_head(this.cHandle) == 0); }
59 | void hideRef(string refname) { require(git_revwalk_hide_ref(this.cHandle, refname.toStringz) == 0); }
60 |
61 | void reset() { git_revwalk_reset(this.cHandle); }
62 |
63 | static if (targetLibGitVersion >= VersionInfo(0, 20, 0))
64 | void simplifyFirstParent() { git_revwalk_simplify_first_parent(this.cHandle); }
65 |
66 | bool getNext(ref GitOid dst)
67 | {
68 | auto ret = git_revwalk_next(&dst._get_oid(), this.cHandle);
69 | if (ret == GIT_ITEROVER) return false;
70 | require(ret == 0);
71 | return true;
72 | }
73 |
74 |
75 | mixin RefCountedGitObject!(git_revwalk, git_revwalk_free);
76 | private GitRepo _repo;
77 | }
78 |
--------------------------------------------------------------------------------
/src/git/object_.d:
--------------------------------------------------------------------------------
1 | module git.object_;
2 |
3 | import git.oid;
4 | import git.repository;
5 | import git.types;
6 | import git.util;
7 |
8 | import deimos.git2.object_;
9 | import deimos.git2.types;
10 |
11 | // Note: This file includes none of the original comments, as they might
12 | // be copyrightable material.
13 |
14 | ///
15 | struct GitObject
16 | {
17 | // Internal, see free-standing constructor functions below.
18 | package this(GitRepo repo, git_object* obj)
19 | {
20 | _repo = repo;
21 | _data = Data(obj);
22 | }
23 |
24 | ///
25 | @property GitOid id()
26 | {
27 | return GitOid(*git_object_id(_data._payload));
28 | }
29 |
30 | ///
31 | @property GitType type()
32 | {
33 | return cast(GitType)git_object_type(_data._payload);
34 | }
35 |
36 | ///
37 | @property inout(GitRepo) owner() inout { return _repo; }
38 |
39 | ///
40 | @property GitObject dup()
41 | {
42 | git_object* result;
43 | require(git_object_dup(&result, _data._payload) == 0);
44 | return GitObject(_repo, result);
45 | }
46 |
47 | ///
48 | @property GitObject peel(GitType targetType)
49 | {
50 | git_object* result;
51 | require(git_object_peel(&result, _data._payload, cast(git_otype)targetType) == 0);
52 | return GitObject(_repo, result);
53 | }
54 |
55 | mixin RefCountedGitObject!(git_object, git_object_free);
56 | // Reference to the parent repository to keep it alive.
57 | private GitRepo _repo;
58 | }
59 |
60 | ///
61 | GitObject lookupObject(GitRepo repo, GitOid oid, GitType type = GitType.any)
62 | {
63 | git_object* result;
64 | auto cOid = oid._get_oid;
65 | require(git_object_lookup(&result, repo.cHandle, &cOid, cast(git_otype)type) == 0);
66 | return GitObject(repo, result);
67 | }
68 |
69 | ///
70 | GitObject lookupObjectPrefix(GitRepo repo, GitOid oid, size_t prefixLen, GitType type = GitType.any)
71 | {
72 | git_object* result;
73 | auto cOid = oid._get_oid;
74 | require(git_object_lookup(&result, repo.cHandle, &cOid, cast(git_otype)type) == 0);
75 | return GitObject(repo, result);
76 | }
77 |
78 | ///
79 | GitObject lookupObject(GitRepo repo, in char[] hexString, GitType type = GitType.any)
80 | {
81 | auto oid = GitOid(hexString);
82 | if (hexString.length < GitOid.MaxHexSize)
83 | {
84 | return lookupObjectPrefix(repo, oid, hexString.length, type);
85 | }
86 | else
87 | {
88 | return lookupObject(repo, oid, type);
89 | }
90 | }
91 |
92 | deprecated("Please use lookupObject instead.") alias lookup = lookupObject;
93 | deprecated("Please use lookupObjectPrefix instead.") alias lookupByPrefix = lookupObjectPrefix;
94 |
95 | ///
96 | const(char)[] toString(GitType type)
97 | {
98 | return git_object_type2string(cast(git_otype)type).toSlice;
99 | }
100 |
101 | ///
102 | GitType toType(in char[] str)
103 | {
104 | return cast(GitType)git_object_string2type(str.gitStr);
105 | }
106 |
107 | ///
108 | bool isLoose(GitType type)
109 | {
110 | return git_object_typeisloose(cast(git_otype)type) != 0;
111 | }
112 |
113 | /+
114 | extern (C):
115 | size_t git_object__size(git_otype type);
116 | +/
117 |
--------------------------------------------------------------------------------
/src/git/blob.d:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright Sönke Ludwig 2014.
3 | * Distributed under the Boost Software License, Version 1.0.
4 | * (See accompanying file LICENSE_1_0.txt or copy at
5 | * http://www.boost.org/LICENSE_1_0.txt)
6 | */
7 | module git.blob;
8 |
9 | import git.commit;
10 | import git.object_;
11 | import git.oid;
12 | import git.repository;
13 | import git.types;
14 | import git.util;
15 | import git.version_;
16 |
17 | import deimos.git2.blob;
18 | import deimos.git2.errors;
19 | import deimos.git2.types;
20 |
21 | import std.conv : to;
22 | import std.exception : enforce;
23 | import std.string : toStringz;
24 |
25 |
26 | GitBlob lookupBlob(GitRepo repo, GitOid oid)
27 | {
28 | git_blob* ret;
29 | require(git_blob_lookup(&ret, repo.cHandle, &oid._get_oid()) == 0);
30 | return GitBlob(repo, ret);
31 | }
32 |
33 | GitBlob lookupBlobPrefix(GitRepo repo, GitOid oid, size_t oid_length)
34 | {
35 | git_blob* ret;
36 | require(git_blob_lookup_prefix(&ret, repo.cHandle, &oid._get_oid(), oid_length) == 0);
37 | return GitBlob(repo, ret);
38 | }
39 |
40 | GitOid createBlob(GitRepo repo, in ubyte[] buffer)
41 | {
42 | GitOid ret;
43 | require(git_blob_create_frombuffer(&ret._get_oid(), repo.cHandle, buffer.ptr, buffer.length) == 0);
44 | return ret;
45 | }
46 |
47 | /*GitOid createBlob(R)(GitRepo repo, R input_range)
48 | if (isInputRange!R)
49 | {
50 | alias git_blob_chunk_cb = int function(char *content, size_t max_length, void *payload);
51 | int git_blob_create_fromchunks(
52 | git_oid *id,
53 | git_repository *repo,
54 | const(char)* hintpath,
55 | git_blob_chunk_cb callback,
56 | void *payload);
57 |
58 | }*/
59 |
60 | GitOid createBlobFromWorkDir(GitRepo repo, string relative_path)
61 | {
62 | GitOid ret;
63 | require(git_blob_create_fromworkdir(&ret._get_oid(), repo.cHandle, relative_path.toStringz()) == 0);
64 | return ret;
65 | }
66 |
67 | GitOid createBlobFromDisk(GitRepo repo, string path)
68 | {
69 | GitOid ret;
70 | require(git_blob_create_fromdisk(&ret._get_oid(), repo.cHandle, path.toStringz()) == 0);
71 | return ret;
72 | }
73 |
74 |
75 | struct GitBlob {
76 | this(GitObject object)
77 | {
78 | enforce(object.type == GitType.blob, "GIT object is not a blob.");
79 | _object = object;
80 | }
81 |
82 | package this(GitRepo repo, git_blob* blob)
83 | {
84 | _object = GitObject(repo, cast(git_object*)blob);
85 | }
86 |
87 | @property GitRepo owner() { return _object.owner; }
88 | @property GitOid id() { return GitOid(*git_blob_id(this.cHandle)); }
89 |
90 | @property const(ubyte)[] rawContent()
91 | {
92 | auto ptr = git_blob_rawcontent(this.cHandle);
93 | auto length = git_blob_rawsize(this.cHandle);
94 | enforce(length <= size_t.max, "Blob too large to fit in memory.");
95 | return cast(const(ubyte)[])ptr[0 .. cast(size_t)length];
96 | }
97 |
98 | @property bool isBinary() { return requireBool(git_blob_is_binary(this.cHandle)); }
99 |
100 | /*ubyte[] getFilteredContent()
101 | {
102 | int git_blob_filtered_content(git_buf *out_, git_blob *blob, const(char)* as_path, int check_for_binary_data);
103 | }*/
104 |
105 | package @property inout(git_blob)* cHandle() inout { return cast(inout(git_blob)*)_object.cHandle; }
106 |
107 | private GitObject _object;
108 | }
109 |
--------------------------------------------------------------------------------
/src/git/version_.d:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright Andrej Mitrovic 2013.
3 | * Distributed under the Boost Software License, Version 1.0.
4 | * (See accompanying file LICENSE_1_0.txt or copy at
5 | * http://www.boost.org/LICENSE_1_0.txt)
6 | */
7 | module git.version_;
8 |
9 | import std.exception;
10 | import std.string;
11 |
12 | import deimos.git2.common;
13 | import deimos.git2.version_;
14 |
15 | import git.common;
16 |
17 | /**
18 | Contains version information.
19 | */
20 | struct VersionInfo
21 | {
22 | ///
23 | this(int major, int minor, int revision)
24 | {
25 | this.major = major;
26 | this.minor = minor;
27 | this.revision = revision;
28 | this.text = format("%s.%s.%s", major, minor, revision);
29 | }
30 |
31 | ///
32 | this(int major, int minor, int revision, string text)
33 | {
34 | this.major = major;
35 | this.minor = minor;
36 | this.revision = revision;
37 | this.text = text;
38 | }
39 |
40 | /// Major version, e.g. 0.19.1 -> 0
41 | int major;
42 |
43 | /// Minor version, e.g. 0.19.1 -> 19
44 | int minor;
45 |
46 | /// Revision version, e.g. 0.19.1 -> 1
47 | int revision;
48 |
49 | /// Text representation of version, e.g. "0.19.1"
50 | string text;
51 |
52 | string toString()
53 | {
54 | return format("v%s", text);
55 | }
56 |
57 | int opCmp(in VersionInfo other)
58 | const {
59 | if (this.major != other.major) return this.major - other.major;
60 | if (this.minor != other.minor) return this.minor - other.minor;
61 | if (this.revision != other.revision) return this.revision - other.revision;
62 | return 0;
63 | }
64 | }
65 |
66 | /**
67 | Target version this binding is based on.
68 | */
69 | enum targetLibGitVersion = VersionInfo(LIBGIT2_VER_MAJOR, LIBGIT2_VER_MINOR, LIBGIT2_VER_REVISION, LIBGIT2_VERSION);
70 |
71 | /**
72 | The current version of dlibgit.
73 | */
74 | enum dlibgitVersion = VersionInfo(0, 50, 0);
75 |
76 |
77 | static assert(targetLibGitVersion == VersionInfo(0, 19, 0) || targetLibGitVersion == VersionInfo(0, 20, 0));
78 |
79 | /**
80 | Return the runtime version of the libgit2 library
81 | that has been linked with.
82 | */
83 | VersionInfo getLibGitVersion()
84 | {
85 | int major;
86 | int minor;
87 | int revision;
88 | git_libgit2_version(&major, &minor, &revision);
89 |
90 | return VersionInfo(major, minor, revision);
91 | }
92 |
93 | shared static this()
94 | {
95 | verifyCompatibleLibgit();
96 | }
97 |
98 | /**
99 | Verify at runtime that the loaded version of libgit is the
100 | one supported by this version of dlibgit, and that it
101 | has features which are required by dlibgit.
102 | */
103 | void verifyCompatibleLibgit()
104 | {
105 | auto libgitVersion = getLibGitVersion();
106 | enforce(libgitVersion == targetLibGitVersion,
107 | format("Error: dlibgit (%s) requires libgit2 (%s).\nCurrently loaded libgit2 version is (%s).",
108 | dlibgitVersion, targetLibGitVersion, libgitVersion));
109 |
110 | auto features = getLibGitFeatures();
111 | enforce(features.usesSSL, "Error: dlibgit requires libgit2 compiled with SSL support.");
112 | }
113 |
--------------------------------------------------------------------------------
/samples/network/main.d:
--------------------------------------------------------------------------------
1 | module main;
2 |
3 | import git.c;
4 |
5 | import std.zlib;
6 | import core.thread;
7 | import std.array;
8 | import std.algorithm;
9 | import std.concurrency;
10 | import std.conv;
11 | import std.file;
12 | import std.stdio;
13 | import std.string;
14 | import std.range;
15 | import std.exception;
16 | import std.path;
17 |
18 | import common;
19 | import fetch;
20 | import clone;
21 | import ls_remote;
22 | import index_pack;
23 |
24 | struct Command
25 | {
26 | string name;
27 | git_cb fn;
28 | }
29 |
30 | Command[] commands =
31 | [
32 | {"ls-remote", &run_ls_remote},
33 | {"fetch", &run_fetch},
34 | {"clone", &do_clone},
35 | {"index-pack", &run_index_pack},
36 | { null, null}
37 | ];
38 |
39 | int run_command(git_cb fn, int argc, string[] args)
40 | {
41 | int error;
42 | git_repository *repo;
43 |
44 | // Before running the actual command, create an instance of the local
45 | // repository and pass it to the function.
46 | error = git_repository_open(&repo, ".git");
47 | if (error < 0)
48 | repo = null;
49 |
50 | // Run the command. If something goes wrong, print the error message to stderr
51 | error = fn(repo, argc, args);
52 | if (error < 0)
53 | {
54 | if (giterr_last() == null)
55 | writeln("Error without message");
56 | else
57 | printf("Bad news:\n %s\n", giterr_last().message);
58 | }
59 |
60 | if (repo)
61 | git_repository_free(repo);
62 |
63 | return !!error;
64 | }
65 |
66 | int main(string[] args)
67 | {
68 | int i;
69 |
70 | if (args.length < 2)
71 | {
72 | writefln("usage: %s [repo]\n", args[0]);
73 | return 1;
74 | }
75 |
76 | for (i = 0; commands[i].name != null; ++i)
77 | {
78 | if (args[1] == commands[i].name)
79 | {
80 | args.popFront();
81 | return run_command(commands[i].fn, args.length, args);
82 | }
83 | }
84 |
85 | writeln("Command not found: %s\n", args[1]);
86 | return 0;
87 | }
88 |
89 | /+
90 | enum Search : SpanMode
91 | {
92 | deep = SpanMode.depth
93 | ,wide = SpanMode.breadth
94 | ,flat = SpanMode.shallow
95 | }
96 |
97 | string[] fileList(string root, string ext, Search search = Search.flat)
98 | {
99 | string[] result;
100 |
101 | if (!exists(root))
102 | {
103 | writefln("Warning: %s dir not found.", root);
104 | return null;
105 | }
106 |
107 | foreach (string entry; dirEntries(root, cast(SpanMode)search))
108 | {
109 | if (entry.isFile && entry.extension == ext)
110 | result ~= entry;
111 | }
112 |
113 | return result;
114 | }
115 |
116 | void main(string[] args)
117 | {
118 | if (args.length < 2)
119 | {
120 | writeln("Error: Pass the path to a git objects directory.");
121 | return;
122 | }
123 |
124 | foreach (file; fileList(args[1], "", Search.deep))
125 | {
126 | byte[] bytes = cast(byte[])std.file.read(file);
127 | char[] text = cast(char[])uncompress(bytes);
128 |
129 | if (text.startsWith("commit"))
130 | {
131 | sizediff_t nulByte = text.countUntil(0);
132 | if (nulByte != -1)
133 | {
134 | writefln("-- %s --\n%s", text[0 .. nulByte], text[nulByte+1 .. $]);
135 | }
136 | }
137 | }
138 | } +/
139 |
--------------------------------------------------------------------------------
/samples/network/fetch.d:
--------------------------------------------------------------------------------
1 | module fetch;
2 |
3 | import git.c;
4 |
5 | import core.thread;
6 | import std.concurrency;
7 | import std.string;
8 | import std.stdio;
9 |
10 | import common;
11 |
12 | void download()
13 | {
14 | // Connect to the remote end specifying that we want to fetch
15 | // information from it.
16 | if (git_remote_connect(fetch_data.remote, GIT_DIR_FETCH) < 0)
17 | {
18 | fetch_data.ret = -1;
19 | goto exit;
20 | }
21 |
22 | // Download the packfile and index it. This function updates the
23 | //~ // amount of received data and the indexer stats which lets you
24 | //~ // inform the user about progress.
25 | if (git_remote_download(fetch_data.remote, fetch_data.bytes, fetch_data.stats) < 0)
26 | {
27 | fetch_data.ret = -1;
28 | goto exit;
29 | }
30 |
31 | fetch_data.ret = 0;
32 |
33 | exit:
34 | fetch_data.finished = 1;
35 | }
36 |
37 | int update_cb(const(char)* refname, const git_oid* a, const git_oid* b)
38 | {
39 | const(char)* action;
40 | char[GIT_OID_HEXSZ + 1] a_str = '\0';
41 | char[GIT_OID_HEXSZ + 1] b_str = '\0';
42 |
43 | git_oid_fmt(b_str.ptr, b);
44 | b_str[GIT_OID_HEXSZ] = '\0';
45 |
46 | if (git_oid_iszero(a))
47 | {
48 | printf("[new] %.20s %s\n", b_str, refname);
49 | }
50 | else
51 | {
52 | git_oid_fmt(a_str.ptr, a);
53 | a_str[GIT_OID_HEXSZ] = '\0';
54 | printf("[updated] %.10s..%.10s %s\n", a_str, b_str, refname);
55 | }
56 |
57 | return 0;
58 | }
59 |
60 | int run_fetch(git_repository* repo, int argc, string[] argv)
61 | {
62 | git_remote* remote;
63 | git_off_t bytes = 0;
64 | git_indexer_stats stats;
65 |
66 | // Figure out whether it's a named remote or a URL
67 | writefln("Fetching %s\n", argv[1]);
68 |
69 | if (git_remote_load(&remote, repo, argv[1].toStringz) < 0)
70 | {
71 | if (git_remote_new(&remote, repo, null, argv[1].toStringz, null) < 0)
72 | return -1;
73 | }
74 |
75 | // Set up the information for the background worker thread
76 | fetch_data.remote = remote;
77 | fetch_data.bytes = &bytes;
78 | fetch_data.stats = &stats;
79 | fetch_data.ret = 0;
80 | fetch_data.finished = 0;
81 |
82 | spawn(&download);
83 |
84 | // Loop while the worker thread is still running. Here we show processed
85 | // and total objects in the pack and the amount of received
86 | // data. Most frontends will probably want to show a percentage and
87 | // the download rate.
88 | do
89 | {
90 | Thread.sleep(dur!("msecs")(100));
91 | writefln("\rReceived %s/%s objects in %s bytes", stats.processed, stats.total, bytes);
92 | }
93 | while (!fetch_data.finished);
94 |
95 | writefln("\rReceived %s/%s objects in %s bytes", stats.processed, stats.total, bytes);
96 |
97 | // Disconnect the underlying connection to prevent from idling.
98 | git_remote_disconnect(remote);
99 |
100 | // Update the references in the remote's namespace to point to the
101 | // right commits. This may be needed even if there was no packfile
102 | // to download, which can happen e.g. when the branches have been
103 | // changed but all the neede objects are available locally.
104 | if (git_remote_update_tips(remote) < 0)
105 | return -1;
106 |
107 | git_remote_free(remote);
108 |
109 | return 0;
110 |
111 | on_error:
112 | git_remote_free(remote);
113 | return -1;
114 | }
115 |
--------------------------------------------------------------------------------
/src/git/types.d:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright Andrej Mitrovic 2013.
3 | * Distributed under the Boost Software License, Version 1.0.
4 | * (See accompanying file LICENSE_1_0.txt or copy at
5 | * http://www.boost.org/LICENSE_1_0.txt)
6 | */
7 | module git.types;
8 |
9 | import std.array;
10 | import std.conv;
11 | import std.exception;
12 | import std.string;
13 |
14 | import deimos.git2.common;
15 | import deimos.git2.errors;
16 | import deimos.git2.types;
17 | import deimos.git2.util;
18 |
19 | import git.exception;
20 | import git.version_;
21 |
22 | /** Basic type (loose or packed) of any Git object. */
23 | enum GitType
24 | {
25 | /// Object can be any of the following types.
26 | any = GIT_OBJ_ANY,
27 |
28 | /// Object is invalid.
29 | bad = GIT_OBJ_BAD,
30 |
31 | /// Reserved for future use.
32 | ext1 = GIT_OBJ__EXT1,
33 |
34 | /// A commit object.
35 | commit = GIT_OBJ_COMMIT,
36 |
37 | /// A tree (directory listing) object.
38 | tree = GIT_OBJ_TREE,
39 |
40 | /// A file revision object.
41 | blob = GIT_OBJ_BLOB,
42 |
43 | /// An annotated tag object.
44 | tag = GIT_OBJ_TAG,
45 |
46 | /// Reserved for future use.
47 | ext2 = GIT_OBJ__EXT2,
48 |
49 | /// A delta, base is given by an offset.
50 | ofs_delta = GIT_OBJ_OFS_DELTA,
51 |
52 | /// A delta, base is given by object id.
53 | ref_delta = GIT_OBJ_REF_DELTA
54 | }
55 |
56 | /** Basic type of any Git reference. */
57 | enum GitRefType
58 | {
59 | /** Invalid reference. */
60 | invalid = GIT_REF_INVALID,
61 |
62 | /** A reference which points at an object id. */
63 | oid = GIT_REF_OID,
64 |
65 | /** A reference which points at another reference. */
66 | symbolic = GIT_REF_SYMBOLIC,
67 |
68 | list_all = GIT_REF_LISTALL,
69 | }
70 |
71 | /** Basic type of any Git branch. */
72 | enum GitBranchType
73 | {
74 | local = GIT_BRANCH_LOCAL,
75 | remote = GIT_BRANCH_REMOTE,
76 | }
77 |
78 | /** Valid modes for index and tree entries. */
79 | enum GitFileModeType
80 | {
81 | new_ = GIT_FILEMODE_NEW,
82 | tree = GIT_FILEMODE_TREE,
83 | blob = GIT_FILEMODE_BLOB,
84 | blob_exe = GIT_FILEMODE_BLOB_EXECUTABLE,
85 | link = GIT_FILEMODE_LINK,
86 | commit = GIT_FILEMODE_COMMIT,
87 | }
88 |
89 | /// The return type of walker callbacks.
90 | enum ContinueWalk
91 | {
92 | /// Stop walk
93 | no,
94 |
95 | /// Continue walk
96 | yes
97 | }
98 |
99 | /// The return type of walker callbacks.
100 | enum ContinueWalkSkip
101 | {
102 | /// Stop walk
103 | no,
104 |
105 | /// Continue walk
106 | yes,
107 |
108 | /// Skip the current sub tree
109 | skip
110 | }
111 |
112 | /**
113 | * Callback for transfer progress information during remote operations (cloning,
114 | * fetching).
115 | *
116 | * Generally called in-line with network operations, take care not to degrade
117 | * performance.
118 | */
119 | struct GitTransferProgress
120 | {
121 | package this(const(git_transfer_progress)* p)
122 | {
123 | this.tupleof = (*p).tupleof;
124 | }
125 |
126 | uint totalObjects;
127 | uint indexedObjects;
128 | uint receivedObjects;
129 | static if (targetLibGitVersion == VersionInfo(0, 20, 0)) {
130 | uint local_objects;
131 | uint total_deltas;
132 | uint indexed_deltas;
133 | }
134 | size_t receivedBytes;
135 | }
136 |
137 | /// ditto
138 | alias TransferCallbackDelegate = void delegate(const ref GitTransferProgress stats);
139 |
--------------------------------------------------------------------------------
/docs/assets/js/README.md:
--------------------------------------------------------------------------------
1 | ## 2.0 BOOTSTRAP JS PHILOSOPHY
2 | These are the high-level design rules which guide the development of Bootstrap's plugin apis.
3 |
4 | ---
5 |
6 | ### DATA-ATTRIBUTE API
7 |
8 | We believe you should be able to use all plugins provided by Bootstrap purely through the markup API without writing a single line of javascript.
9 |
10 | We acknowledge that this isn't always the most performant and sometimes it may be desirable to turn this functionality off altogether. Therefore, as of 2.0 we provide the ability to disable the data attribute API by unbinding all events on the body namespaced with `'data-api'`. This looks like this:
11 |
12 | $('body').off('.data-api')
13 |
14 | To target a specific plugin, just include the plugins name as a namespace along with the data-api namespace like this:
15 |
16 | $('body').off('.alert.data-api')
17 |
18 | ---
19 |
20 | ### PROGRAMATIC API
21 |
22 | We also believe you should be able to use all plugins provided by Bootstrap purely through the JS API.
23 |
24 | All public APIs should be single, chainable methods, and return the collection acted upon.
25 |
26 | $(".btn.danger").button("toggle").addClass("fat")
27 |
28 | All methods should accept an optional options object, a string which targets a particular method, or null which initiates the default behavior:
29 |
30 | $("#myModal").modal() // initialized with defaults
31 | $("#myModal").modal({ keyboard: false }) // initialized with now keyboard
32 | $("#myModal").modal('show') // initializes and invokes show immediately afterqwe2
33 |
34 | ---
35 |
36 | ### OPTIONS
37 |
38 | Options should be sparse and add universal value. We should pick the right defaults.
39 |
40 | All plugins should have a default object which can be modified to effect all instance's default options. The defaults object should be available via `$.fn.plugin.defaults`.
41 |
42 | $.fn.modal.defaults = { … }
43 |
44 | An options definition should take the following form:
45 |
46 | *noun*: *adjective* - describes or modifies a quality of an instance
47 |
48 | examples:
49 |
50 | backdrop: true
51 | keyboard: false
52 | placement: 'top'
53 |
54 | ---
55 |
56 | ### EVENTS
57 |
58 | All events should have an infinitive and past participle form. The infinitive is fired just before an action takes place, the past participle on completion of the action.
59 |
60 | show | shown
61 | hide | hidden
62 |
63 | ---
64 |
65 | ### CONSTRUCTORS
66 |
67 | Each plugin should expose it's raw constructor on a `Constructor` property -- accessed in the following way:
68 |
69 |
70 | $.fn.popover.Constructor
71 |
72 | ---
73 |
74 | ### DATA ACCESSOR
75 |
76 | Each plugin stores a copy of the invoked class on an object. This class instance can be accessed directly through jQuery's data API like this:
77 |
78 | $('[rel=popover]').data('popover') instanceof $.fn.popover.Constructor
79 |
80 | ---
81 |
82 | ### DATA ATTRIBUTES
83 |
84 | Data attributes should take the following form:
85 |
86 | - data-{{verb}}={{plugin}} - defines main interaction
87 | - data-target || href^=# - defined on "control" element (if element controls an element other than self)
88 | - data-{{noun}} - defines class instance options
89 |
90 | examples:
91 |
92 | // control other targets
93 | data-toggle="modal" data-target="#foo"
94 | data-toggle="collapse" data-target="#foo" data-parent="#bar"
95 |
96 | // defined on element they control
97 | data-spy="scroll"
98 |
99 | data-dismiss="modal"
100 | data-dismiss="alert"
101 |
102 | data-toggle="dropdown"
103 |
104 | data-toggle="button"
105 | data-toggle="buttons-checkbox"
106 | data-toggle="buttons-radio"
--------------------------------------------------------------------------------
/src/git/trace.d:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright Andrej Mitrovic 2013.
3 | * Distributed under the Boost Software License, Version 1.0.
4 | * (See accompanying file LICENSE_1_0.txt or copy at
5 | * http://www.boost.org/LICENSE_1_0.txt)
6 | */
7 | module git.trace;
8 |
9 | import std.conv;
10 |
11 | import deimos.git2.trace;
12 |
13 | import git.exception;
14 | import git.util;
15 |
16 | /**
17 | Available tracing levels. When tracing is set to a particular level,
18 | callers will be provided tracing at the given level and all lower levels.
19 | */
20 | enum TraceLevel
21 | {
22 | /** No tracing will be performed. */
23 | none = GIT_TRACE_NONE,
24 |
25 | /** Severe errors that may impact the program's execution. */
26 | fatal = GIT_TRACE_FATAL,
27 |
28 | /** Errors that do not impact the program's execution. */
29 | error = GIT_TRACE_ERROR,
30 |
31 | /** Warnings that suggest abnormal data. */
32 | warn = GIT_TRACE_WARN,
33 |
34 | /** Informational messages about program execution. */
35 | info = GIT_TRACE_INFO,
36 |
37 | /** Detailed data that allows for debugging. */
38 | debug_ = GIT_TRACE_DEBUG,
39 |
40 | /** Exceptionally detailed debugging data. */
41 | trace = GIT_TRACE_TRACE
42 | }
43 |
44 | /** The trace callback function and delegate types. */
45 | alias TraceFunction = void function(TraceLevel level, in char[] msg);
46 |
47 | /// ditto
48 | alias TraceDelegate = void delegate(TraceLevel level, in char[] msg);
49 |
50 | /**
51 | Sets the git system tracing configuration to the specified level with the
52 | specified callback. When system events occur at a level equal to, or
53 | lower than, the given level they will be reported to the given callback.
54 |
55 | $(BLUE Note:) If libgit2 is not built with tracing support calling this
56 | function will throw a $(D GitException).
57 |
58 | Make sure $(B -DGIT_TRACE) is set when building libgit2
59 | to enable tracing support, or look at the libgit2 build instructions.
60 | */
61 | void setGitTracer(TraceLevel level, TraceFunction callback)
62 | {
63 | setGitTracerImpl(level, callback);
64 | }
65 |
66 | /// ditto
67 | void setGitTracer(TraceLevel level, scope TraceDelegate callback)
68 | {
69 | setGitTracerImpl(level, callback);
70 | }
71 |
72 | /// test callback function
73 | unittest
74 | {
75 | static void tracer(TraceLevel level, in char[] msg)
76 | {
77 | import std.stdio;
78 | stderr.writefln("Level(%s): %s", level, msg);
79 | }
80 |
81 | try
82 | {
83 | setGitTracer(TraceLevel.trace, &tracer);
84 | }
85 | catch (GitException exc)
86 | {
87 | assert(exc.msg == _noTraceMsg, exc.msg);
88 | }
89 | }
90 |
91 | /// test callback delegate
92 | unittest
93 | {
94 | struct S
95 | {
96 | size_t line = 1;
97 |
98 | void tracer(TraceLevel level, in char[] msg)
99 | {
100 | import std.stdio;
101 | stderr.writefln("Level(%s): Line %s - %s", line++, level, msg);
102 | }
103 | }
104 |
105 | S s;
106 |
107 | try
108 | {
109 | setGitTracer(TraceLevel.trace, &s.tracer);
110 | }
111 | catch (GitException exc)
112 | {
113 | assert(exc.msg == _noTraceMsg, exc.msg);
114 | }
115 | }
116 |
117 | version(unittest)
118 | {
119 | enum _noTraceMsg = "Git error (GITERR_INVALID): This version of libgit2 was not built with tracing..";
120 | }
121 |
122 | private void setGitTracerImpl(Callback)(TraceLevel level, Callback callback)
123 | if (is(Callback == TraceFunction) || is(Callback == TraceDelegate))
124 | {
125 | struct Tracer
126 | {
127 | extern(C) void tracer(git_trace_level_t level, const(char)* msg)
128 | {
129 | callback(cast(TraceLevel)level, to!(const(char)[])(msg));
130 | }
131 |
132 | private:
133 | /// The currently active callback
134 | static Callback callback;
135 | }
136 |
137 | Tracer.callback = callback;
138 | require(git_trace_set(cast(git_trace_level_t)level, &Tracer.tracer) == 0);
139 | }
140 |
--------------------------------------------------------------------------------
/src/git/clone.d:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright David Nadlinger 2014.
3 | * Distributed under the Boost Software License, Version 1.0.
4 | * (See accompanying file LICENSE_1_0.txt or copy at
5 | * http://www.boost.org/LICENSE_1_0.txt)
6 | */
7 | module git.clone;
8 |
9 | import git.checkout;
10 | import git.credentials;
11 | import git.remote;
12 | import git.repository;
13 | import git.transport;
14 | import git.types;
15 | import git.util;
16 | import git.version_;
17 |
18 | import deimos.git2.clone;
19 | import deimos.git2.remote;
20 | import deimos.git2.transport;
21 | import deimos.git2.types;
22 |
23 | ///
24 | struct GitCloneOptions
25 | {
26 | uint version_ = git_clone_options.init.version_;
27 |
28 | GitCheckoutOptions checkoutOptions;
29 |
30 | bool cloneBare;
31 |
32 | static if (targetLibGitVersion == VersionInfo(0, 19, 0)) TransferCallbackDelegate fetchProgessCallback;
33 |
34 | string remoteName;
35 | static if (targetLibGitVersion == VersionInfo(0, 19, 0)) {
36 | string pushURL;
37 | string fetchSpec;
38 | string pushSpec;
39 |
40 | GitCredAcquireDelegate credAcquireCallback;
41 |
42 | GitTransportFlags transportFlags;
43 | // GitTransport transport; // TODO: translate
44 | // GitRemoteCallback[] remoteCallbacks; // TODO: implement translation
45 | GitRemoteAutotagOption remoteAutotag;
46 | }
47 | string checkoutBranch;
48 | }
49 |
50 |
51 | static if (targetLibGitVersion == VersionInfo(0, 19, 0)) {
52 | extern(C) nothrow int cFetchProgessCallback(
53 | const(git_transfer_progress)* stats,
54 | void* payload)
55 | {
56 | auto dg = (cast(GitCloneOptions*)payload).fetchProgessCallback;
57 | if (dg) {
58 | try {
59 | auto tp = GitTransferProgress(stats);
60 | dg(tp);
61 | } catch (Exception e) {
62 | return -1;
63 | }
64 | }
65 | return 0;
66 | }
67 |
68 | extern(C) int cCredAcquireCallback(
69 | git_cred** cred,
70 | const(char)* url,
71 | const(char)* username_from_url,
72 | uint allowed_types,
73 | void* payload)
74 | {
75 | auto dg = (cast(GitCloneOptions*)payload).credAcquireCallback;
76 | if (dg)
77 | {
78 | auto dCred = dg(toSlice(url), toSlice(username_from_url), allowed_types);
79 | // FIXME: cred will probably be immediately freed.
80 | *cred = dCred.cHandle;
81 | return 0;
82 | }
83 |
84 | // FIXME: Use real error code here.
85 | return 1;
86 | }
87 | }
88 |
89 | GitRepo cloneRepo(in char[] url, in char[] localPath, GitCloneOptions options = GitCloneOptions.init)
90 | {
91 | git_clone_options cOpts;
92 | with (options)
93 | {
94 | cOpts.version_ = version_;
95 | checkoutOptions.toCCheckoutOpts(cOpts.checkout_opts);
96 | cOpts.bare = cloneBare;
97 | static if (targetLibGitVersion == VersionInfo(0, 19, 0)) {
98 | if (fetchProgessCallback)
99 | {
100 | cOpts.fetch_progress_cb = &cFetchProgessCallback;
101 | cOpts.fetch_progress_payload = &cOpts;
102 | }
103 | }
104 | cOpts.remote_name = remoteName.gitStr;
105 | static if (targetLibGitVersion == VersionInfo(0, 19, 0)) {
106 | cOpts.pushurl = pushURL.gitStr;
107 | cOpts.fetch_spec = fetchSpec.gitStr;
108 | cOpts.push_spec = pushSpec.gitStr;
109 | if (credAcquireCallback)
110 | {
111 | cOpts.cred_acquire_cb = &cCredAcquireCallback;
112 | cOpts.cred_acquire_payload = &cOpts;
113 | }
114 | cOpts.transport_flags = transportFlags;
115 | // cOpts.transport = // TODO: Translate.
116 | cOpts.remote_autotag = cast(git_remote_autotag_option_t)remoteAutotag;
117 | }
118 | cOpts.checkout_branch = checkoutBranch.gitStr;
119 | }
120 |
121 | git_repository* repo;
122 | auto errc = git_clone(&repo, url.gitStr, localPath.gitStr, &cOpts);
123 | require(errc == 0);
124 | return GitRepo(repo);
125 | }
126 |
--------------------------------------------------------------------------------
/src/git/commit.d:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright Sönke Ludwig 2014.
3 | * Distributed under the Boost Software License, Version 1.0.
4 | * (See accompanying file LICENSE_1_0.txt or copy at
5 | * http://www.boost.org/LICENSE_1_0.txt)
6 | */
7 | module git.commit;
8 |
9 | import git.object_;
10 | import git.oid;
11 | import git.repository;
12 | import git.signature;
13 | import git.tree;
14 | import git.types;
15 | import git.util;
16 | import git.version_;
17 |
18 | import deimos.git2.commit;
19 | import deimos.git2.types;
20 |
21 | import std.conv : to;
22 | import std.string : toStringz;
23 | import std.datetime;
24 |
25 |
26 | GitCommit lookupCommit(GitRepo repo, GitOid oid)
27 | {
28 | git_commit* ret;
29 | require(git_commit_lookup(&ret, repo.cHandle, &oid._get_oid()) == 0);
30 | return GitCommit(repo, ret);
31 | }
32 |
33 | GitCommit lookupCommitPrefix(GitRepo repo, GitOid oid, size_t oid_length)
34 | {
35 | git_commit* ret;
36 | require(git_commit_lookup_prefix(&ret, repo.cHandle, &oid._get_oid(), oid_length) == 0);
37 | return GitCommit(repo, ret);
38 | }
39 |
40 | GitOid createCommit(GitRepo repo, string update_ref, GitSignature author, GitSignature committer, string message, GitTree tree, const(GitCommit)[] parents...)
41 | {
42 | GitOid ret;
43 | assert(parents.length < int.max, "Number of parents may not exceed int.max");
44 | auto cparents = new const(git_commit)*[parents.length];
45 | foreach (i, ref cp; cparents) cp = parents[i].cHandle;
46 | require(git_commit_create(&ret._get_oid(), repo.cHandle,
47 | update_ref ? update_ref.toStringz : null, author.cHandle, committer.cHandle,
48 | null, message.toStringz, tree.cHandle, cast(int)cparents.length, cparents.ptr) == 0);
49 | return ret;
50 | }
51 |
52 |
53 | struct GitCommit {
54 | this(GitObject obj)
55 | {
56 | enforce(obj.type == GitType.commit, "GIT object is not a commit.");
57 | _object = obj;
58 | }
59 |
60 | package this(GitRepo repo, git_commit* commit)
61 | {
62 | _object = GitObject(repo, cast(git_object*)commit);
63 | }
64 |
65 | @property GitOid id() { return GitOid(*git_commit_id(this.cHandle)); }
66 | @property GitRepo owner() { return _object.owner; }
67 | @property string messageEncoding() { return git_commit_message_encoding(this.cHandle).to!string; }
68 | @property string message() { return git_commit_message(this.cHandle).to!string; }
69 | static if (targetLibGitVersion >= VersionInfo(0, 20, 0))
70 | @property string rawMessage() { return git_commit_message_raw(this.cHandle).to!string; }
71 |
72 | @property SysTime commitTime()
73 | {
74 | git_time tm;
75 | tm.time = git_commit_time(this.cHandle);
76 | tm.offset = git_commit_time_offset(this.cHandle);
77 | return tm.toSysTime();
78 | }
79 |
80 | @property GitSignature committer() { return GitSignature(this, git_commit_committer(this.cHandle)); }
81 | @property GitSignature author() { return GitSignature(this, git_commit_author(this.cHandle)); }
82 | static if (targetLibGitVersion >= VersionInfo(0, 20, 0))
83 | @property string rawHeader() { return git_commit_raw_header(this.cHandle).to!string; }
84 |
85 | @property GitTree tree()
86 | {
87 | git_tree* ret;
88 | require(git_commit_tree(&ret, this.cHandle) == 0);
89 | return GitTree(this.owner, ret);
90 | }
91 | @property GitOid treeId() { return GitOid(*git_commit_tree_id(this.cHandle)); }
92 |
93 | @property uint parentCount() { return git_commit_parentcount(this.cHandle); }
94 |
95 | @property GitOid[] parentOids()
96 | {
97 | auto ret = new GitOid[parentCount];
98 | foreach (i; 0 .. cast(uint)ret.length) ret[i] = getParentOid(i);
99 | return ret;
100 | }
101 |
102 | @property GitCommit[] parents()
103 | {
104 | auto ret = new GitCommit[parentCount];
105 | foreach (i; 0 .. cast(uint)ret.length) ret[i] = getParent(i);
106 | return ret;
107 | }
108 |
109 | GitCommit getParent(uint index)
110 | {
111 | git_commit* ret;
112 | require(git_commit_parent(&ret, this.cHandle, index) == 0);
113 | return GitCommit(this.owner, ret);
114 | }
115 |
116 | GitOid getParentOid(uint index)
117 | {
118 | return GitOid(*git_commit_parent_id(this.cHandle, index));
119 | }
120 |
121 | GitCommit getNthGenAncestor(uint n)
122 | {
123 | git_commit* ret;
124 | require(git_commit_nth_gen_ancestor(&ret, this.cHandle, n) == 0);
125 | return GitCommit(this.owner, ret);
126 | }
127 |
128 | package @property inout(git_commit)* cHandle() inout { return cast(inout(git_commit)*)_object.cHandle; }
129 |
130 | private GitObject _object;
131 | }
--------------------------------------------------------------------------------
/src/git/util.d:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright Andrej Mitrovic 2013, David Nadlinger 2014.
3 | * Distributed under the Boost Software License, Version 1.0.
4 | * (See accompanying file LICENSE_1_0.txt or copy at
5 | * http://www.boost.org/LICENSE_1_0.txt)
6 | */
7 | module git.util;
8 |
9 | /**
10 | Contains utility functions for this package.
11 | */
12 |
13 | import std.array;
14 | import std.conv;
15 | import std.datetime;
16 | import std.exception;
17 | import std.string;
18 |
19 | import deimos.git2.errors;
20 | import deimos.git2.types : git_time;
21 |
22 | import git.exception;
23 |
24 | /**
25 | Require the result to be either 1 or 0. If it is, return the boolean value,
26 | otherwise throw a GitException.
27 | */
28 | package bool requireBool(int result, string file = __FILE__, size_t line = __LINE__)
29 | {
30 | require(result == 0 || result == 1);
31 | return result == 1;
32 | }
33 |
34 | /**
35 | Call this function when an error code is returned from a git function.
36 | It will retrieve the last error and throw a GitException.
37 |
38 | $(RED Note:) assert or in blocks should be used to verify arguments (such as strings)
39 | before calling Git functions since Git itself does not check pointers for null.
40 | Passing null pointers to Git functions usually results in access violations.
41 | */
42 | package void require(bool state, Exception next = null, string file = __FILE__, size_t line = __LINE__)
43 | {
44 | if (state)
45 | return;
46 |
47 | const(git_error)* gitError = giterr_last();
48 |
49 | enforce(gitError !is null,
50 | "Error: No Git error thrown, error condition check is likely invalid.");
51 |
52 | const msg = format("Git error (%s): %s.", cast(git_error_t)gitError.klass, to!string(gitError.message));
53 |
54 | giterr_clear();
55 | throw new GitException(msg, file, line, next);
56 | }
57 |
58 | ///
59 | unittest
60 | {
61 | import deimos.git2.oid;
62 | git_oid oid;
63 | assertThrown!GitException(require(git_oid_fromstr(&oid, "foobar") == 0));
64 | }
65 |
66 | /** Return a posix-native path, replacing backslashes with forward slashes. */
67 | string toPosixPath(string input)
68 | {
69 | return input.replace(`\`, `/`);
70 | }
71 |
72 | ///
73 | unittest
74 | {
75 | assert(`foo/bar\doo`.toPosixPath == r"foo/bar/doo");
76 | }
77 |
78 | alias toSlice = to!(const(char)[]);
79 |
80 | SysTime toSysTime(git_time gtime)
81 | {
82 | import core.stdc.time;
83 | auto ctime = unixTimeToStdTime(cast(time_t)gtime.time);
84 | auto ctimeoff = gtime.offset.minutes();
85 | return SysTime(ctime, new immutable SimpleTimeZone(ctimeoff));
86 | }
87 |
88 | git_time toGitTime(SysTime time)
89 | {
90 | git_time ret;
91 | ret.time = stdTimeToUnixTime(time.stdTime);
92 | ret.offset = cast(int)((time.timezone.utcToTZ(time.stdTime) - time.stdTime) / (10_000_000*60));
93 | return ret;
94 | }
95 |
96 | // TODO: unit tests for time functions!
97 |
98 |
99 | /**
100 | Converts the passed char slice to a C string, returning the null pointer for
101 | empty strings.
102 |
103 | libgit2 generally only switches to the default for optional string
104 | parameters if they are null, vs. just the empty string.
105 | */
106 | const(char)* gitStr(const(char)[] s)
107 | {
108 | import std.string : toStringz;
109 | return s.length ? s.toStringz : null;
110 | }
111 |
112 | mixin template RefCountedGitObject(T, alias free_function, bool define_chandle = true)
113 | {
114 | public:
115 | bool opCast(T)() const if (is(T == bool)) { return cHandle !is null; }
116 |
117 | package:
118 | static if (define_chandle) {
119 | @property inout(T)* cHandle() inout { return _data._payload; }
120 | }
121 |
122 | private:
123 | struct Payload
124 | {
125 | this(T* payload)
126 | {
127 | _payload = payload;
128 | }
129 |
130 | ~this()
131 | {
132 | if (_payload !is null)
133 | {
134 | free_function(_payload);
135 | _payload = null;
136 | }
137 | }
138 |
139 | /// Should never perform copy
140 | @disable this(this);
141 |
142 | /// Should never perform assign
143 | @disable void opAssign(typeof(this));
144 |
145 | T* _payload;
146 | }
147 |
148 | import std.typecons : RefCounted, RefCountedAutoInitialize;
149 | alias RefCounted!(Payload, RefCountedAutoInitialize.no) Data;
150 | Data _data;
151 | }
152 |
--------------------------------------------------------------------------------
/src/git/branch.d:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright Sönke Ludwig 2014.
3 | * Distributed under the Boost Software License, Version 1.0.
4 | * (See accompanying file LICENSE_1_0.txt or copy at
5 | * http://www.boost.org/LICENSE_1_0.txt)
6 | */
7 | module git.branch;
8 |
9 | import git.commit;
10 | import git.oid;
11 | import git.reference;
12 | import git.repository;
13 | import git.types;
14 | import git.util;
15 | import git.version_;
16 |
17 | import deimos.git2.branch;
18 | import deimos.git2.errors;
19 | import deimos.git2.types;
20 |
21 | import std.conv : to;
22 | import std.string : toStringz;
23 |
24 |
25 | GitBranch createBranch(GitRepo repo, string name, GitCommit target, bool force)
26 | {
27 | git_reference* ret;
28 | require(git_branch_create(&ret, repo.cHandle, name.toStringz, target.cHandle, force) == 0);
29 | return GitBranch(GitReference(repo, ret));
30 | }
31 |
32 | GitBranch lookupBranch(GitRepo repo, string name, GitBranchType type)
33 | {
34 | git_reference* ret;
35 | require(git_branch_lookup(&ret, repo.cHandle, name.toStringz(), cast(git_branch_t)type) == 0);
36 | return GitBranch(GitReference(repo, ret));
37 | }
38 |
39 | void deleteBranch(GitBranch branch)
40 | {
41 | require(git_branch_delete(branch.cHandle) == 0);
42 | }
43 |
44 | void iterateBranches(GitRepo repo, GitBranchType types, scope BranchIterationDelegate del)
45 | {
46 | static if (targetLibGitVersion == VersionInfo(0, 19, 0)) {
47 | static struct CTX { BranchIterationDelegate del; GitRepo repo; Exception e; }
48 | static extern(C) nothrow int callback(const(char)* name, git_branch_t type, void* payload) {
49 | auto ctx = cast(CTX*)payload;
50 | try {
51 | auto gtp = cast(GitBranchType)type;
52 | if (ctx.del(lookupBranch(ctx.repo, name.to!string, gtp), gtp) == ContinueWalk.no)
53 | return 1;
54 | } catch (Exception e) {
55 | ctx.e = e;
56 | return -1;
57 | }
58 | return 0;
59 | }
60 |
61 | auto ctx = CTX(del, repo);
62 | auto ret = git_branch_foreach(repo.cHandle, cast(git_branch_t)types, &callback, &ctx);
63 | if (ret == GIT_EUSER) {
64 | if (ctx.e) throw ctx.e;
65 | else return;
66 | }
67 | require(ret == 0);
68 | } else {
69 | git_branch_iterator* it;
70 | require(git_branch_iterator_new(&it, repo.cHandle, cast(git_branch_t)types) == 0);
71 | scope (exit) git_branch_iterator_free(it);
72 | while (true) {
73 | git_reference* br;
74 | git_branch_t brtp;
75 | auto ret = git_branch_next(&br, &brtp, it);
76 | if (ret == GIT_ITEROVER) break;
77 | require(ret == 0);
78 | if (del(GitBranch(GitReference(repo, br)), cast(GitBranchType)brtp) == ContinueWalk.no)
79 | break;
80 | }
81 | }
82 | }
83 |
84 |
85 | alias BranchIterationDelegate = ContinueWalk delegate(GitBranch branch, GitBranchType type);
86 |
87 |
88 | struct GitBranch {
89 | protected this(GitReference ref_)
90 | {
91 | _ref = ref_;
92 | }
93 |
94 | @property inout(GitReference) reference() inout { return _ref; }
95 |
96 | @property string name()
97 | {
98 | const(char)* ret;
99 | require(git_branch_name(&ret, this.cHandle) == 0);
100 | return ret.to!string();
101 | }
102 |
103 | @property GitBranch upstream()
104 | {
105 | git_reference* ret;
106 | require(git_branch_upstream(&ret, this.cHandle) == 0);
107 | return GitBranch(GitReference(_ref.owner, ret));
108 | }
109 |
110 | @property string upstreamName()
111 | {
112 | const(char)* branch_name;
113 | require(git_branch_name(&branch_name, this.cHandle) == 0);
114 | auto len = git_branch_upstream_name(null, 0, _ref.owner.cHandle, branch_name);
115 | require(len > 0);
116 | auto dst = new char[len];
117 | require(git_branch_upstream_name(dst.ptr, dst.length, _ref.owner.cHandle, branch_name) == len);
118 | return cast(immutable)dst[0 .. $-1]; // skip trailing 0
119 | }
120 |
121 | @property void upstreamName(string name)
122 | {
123 | require(git_branch_set_upstream(_ref.cHandle, name.toStringz()) == 0);
124 | }
125 |
126 | @property bool isHead() { return requireBool(git_branch_is_head(_ref.cHandle)); }
127 |
128 | @property string remoteName()
129 | {
130 | const(char)* branch_name;
131 | require(git_branch_name(&branch_name, this.cHandle) == 0);
132 | auto len = git_branch_remote_name(null, 0, _ref.owner.cHandle, branch_name);
133 | require(len > 0);
134 | auto dst = new char[len];
135 | require(git_branch_remote_name(dst.ptr, dst.length, _ref.owner.cHandle, branch_name) == len);
136 | return cast(immutable)dst[0 .. $-1]; // skip trailing 0
137 | }
138 |
139 | GitBranch move(string new_name, bool force)
140 | {
141 | git_reference* dst;
142 | require(git_branch_move(&dst, _ref.cHandle, new_name.toStringz(), force) == 0);
143 | return GitBranch(GitReference(_ref.owner, dst));
144 | }
145 |
146 | alias reference this;
147 |
148 | private:
149 | GitReference _ref;
150 | }
151 |
--------------------------------------------------------------------------------
/src/git/tag.d:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright Sönke Ludwig 2014.
3 | * Distributed under the Boost Software License, Version 1.0.
4 | * (See accompanying file LICENSE_1_0.txt or copy at
5 | * http://www.boost.org/LICENSE_1_0.txt)
6 | */
7 | module git.tag;
8 |
9 | import git.commit;
10 | import git.object_;
11 | import git.oid;
12 | import git.repository;
13 | import git.signature;
14 | import git.types;
15 | import git.util;
16 | import git.version_;
17 |
18 | import deimos.git2.oid;
19 | import deimos.git2.tag;
20 | import deimos.git2.errors;
21 | import deimos.git2.strarray;
22 | import deimos.git2.types;
23 |
24 | import std.conv : to;
25 | import std.exception : enforce;
26 | import std.string : toStringz;
27 |
28 |
29 | GitTag lookupTag(GitRepo repo, GitOid oid)
30 | {
31 | git_tag* dst;
32 | require(git_tag_lookup(&dst, repo.cHandle, &oid._get_oid()) == 0);
33 | return GitTag(repo, dst);
34 | }
35 |
36 | GitTag lookupTag(GitRepo repo, GitOid oid, size_t oid_length)
37 | {
38 | git_tag* dst;
39 | require(git_tag_lookup_prefix(&dst, repo.cHandle, &oid._get_oid(), oid_length) == 0);
40 | return GitTag(repo, dst);
41 | }
42 |
43 | GitOid createTag(GitRepo repo, string tag_name, in GitObject target, in GitSignature tagger, string message, bool force)
44 | {
45 | GitOid dst;
46 | require(git_tag_create(&dst._get_oid(), repo.cHandle, tag_name.toStringz, target.cHandle, tagger.cHandle, message.toStringz(), force) == 0);
47 | return dst;
48 | }
49 |
50 | GitOid createTagAnnotation(GitRepo repo, string tag_name, in GitObject target, in GitSignature tagger, string message)
51 | {
52 | GitOid dst;
53 | require(git_tag_annotation_create(&dst._get_oid(), repo.cHandle, tag_name.toStringz, target.cHandle, tagger.cHandle, message.toStringz()) == 0);
54 | return dst;
55 | }
56 |
57 | GitOid createTagFromBuffer(GitRepo repo, string buffer, bool force)
58 | {
59 | GitOid dst;
60 | require(git_tag_create_frombuffer(&dst._get_oid(), repo.cHandle, buffer.toStringz, force) == 0);
61 | return dst;
62 | }
63 |
64 | GitOid createTagLightweight(GitRepo repo, string tag_name, in GitObject target, bool force)
65 | {
66 | GitOid dst;
67 | require(git_tag_create_lightweight(&dst._get_oid(), repo.cHandle, tag_name.toStringz, target.cHandle, force) == 0);
68 | return dst;
69 | }
70 |
71 | void deleteTag(GitRepo repo, string tag_name)
72 | {
73 | require(git_tag_delete(repo.cHandle, tag_name.toStringz) == 0);
74 | }
75 |
76 | void iterateTags(GitRepo repo, scope ContinueWalk delegate(string name, GitOid oid) del)
77 | {
78 | static struct CTX { ContinueWalk delegate(string name, GitOid oid) del; Exception e; }
79 |
80 | static extern(C) nothrow int callback(const(char)* name, git_oid *oid, void *payload)
81 | {
82 | auto ctx = cast(CTX*)payload;
83 | try {
84 | if (ctx.del(name.to!string, GitOid(*oid)) != ContinueWalk.yes)
85 | return 1;
86 | } catch (Exception e) {
87 | ctx.e = e;
88 | return -1;
89 | }
90 | return 0;
91 | }
92 |
93 | auto ctx = CTX(del);
94 | auto ret = git_tag_foreach(repo.cHandle, &callback, &ctx);
95 | if (ctx.e) throw ctx.e;
96 | require(ret == 0);
97 | }
98 |
99 | string[] listTags(GitRepo repo)
100 | {
101 | git_strarray arr;
102 | require(git_tag_list(&arr, repo.cHandle) == 0);
103 | git_strarray_free(&arr);
104 | auto ret = new string[arr.count];
105 | foreach (i; 0 .. arr.count)
106 | ret[i] = arr.strings[i].to!string;
107 | return ret;
108 | }
109 |
110 | string[] listMatchingTags(GitRepo repo, string pattern)
111 | {
112 | git_strarray arr;
113 | require(git_tag_list_match(&arr, pattern.toStringz, repo.cHandle) == 0);
114 | git_strarray_free(&arr);
115 | auto ret = new string[arr.count];
116 | foreach (i; 0 .. arr.count)
117 | ret[i] = arr.strings[i].to!string;
118 | return ret;
119 | }
120 |
121 |
122 | struct GitTag {
123 | this(GitObject obj)
124 | {
125 | enforce(obj.type == GitType.tag, "GIT object is not a tag.");
126 | _object = obj;
127 | }
128 |
129 | package this(GitRepo repo, git_tag* tag)
130 | {
131 | _object = GitObject(repo, cast(git_object*)tag);
132 | }
133 |
134 | @property inout(GitRepo) owner() inout { return _object.owner; }
135 | @property GitOid id() const { return GitOid(*git_tag_id(this.cHandle)); }
136 | @property string name() { return git_tag_name(this.cHandle).to!string; }
137 | @property GitObject target()
138 | {
139 | git_object* dst;
140 | require(git_tag_target(&dst, this.cHandle) == 0);
141 | return GitObject(this.owner, dst);
142 | }
143 | @property GitOid targetID() const { return GitOid(*git_tag_target_id(this.cHandle)); }
144 | @property GitType targetType() const { return cast(GitType)git_tag_target_type(this.cHandle); }
145 | @property GitSignature tagger() { return GitSignature(this, git_tag_tagger(this.cHandle)); }
146 | @property string message() const { return git_tag_message(this.cHandle).to!string; }
147 |
148 | GitObject peel()
149 | {
150 | git_object* dst;
151 | require(git_tag_peel(&dst, this.cHandle) == 0);
152 | return GitObject(this.owner, dst);
153 | }
154 |
155 | package @property inout(git_tag)* cHandle() inout { return cast(inout(git_tag)*)_object.cHandle; }
156 |
157 | private GitObject _object;
158 | }
159 |
--------------------------------------------------------------------------------
/docs/assets/js/application.js:
--------------------------------------------------------------------------------
1 | // NOTICE!! DO NOT USE ANY OF THIS JAVASCRIPT
2 | // IT'S ALL JUST JUNK FOR OUR DOCS!
3 | // ++++++++++++++++++++++++++++++++++++++++++
4 |
5 | !function ($) {
6 |
7 | $(function(){
8 |
9 | // Disable certain links in docs
10 | $('section [href^=#]').click(function (e) {
11 | e.preventDefault()
12 | })
13 |
14 | // make code pretty
15 | window.prettyPrint && prettyPrint()
16 |
17 | // add-ons
18 | $('.add-on :checkbox').on('click', function () {
19 | var $this = $(this)
20 | , method = $this.attr('checked') ? 'addClass' : 'removeClass'
21 | $(this).parents('.add-on')[method]('active')
22 | })
23 |
24 | // position static twipsies for components page
25 | if ($(".twipsies a").length) {
26 | $(window).on('load resize', function () {
27 | $(".twipsies a").each(function () {
28 | $(this)
29 | .tooltip({
30 | placement: $(this).attr('title')
31 | , trigger: 'manual'
32 | })
33 | .tooltip('show')
34 | })
35 | })
36 | }
37 |
38 | // add tipsies to grid for scaffolding
39 | if ($('#grid-system').length) {
40 | $('#grid-system').tooltip({
41 | selector: '.show-grid > div'
42 | , title: function () { return $(this).width() + 'px' }
43 | })
44 | }
45 |
46 | // fix sub nav on scroll
47 | var $win = $(window)
48 | , $nav = $('.subnav')
49 | , navTop = $('.subnav').length && $('.subnav').offset().top - 40
50 | , isFixed = 0
51 |
52 | processScroll()
53 |
54 | $win.on('scroll', processScroll)
55 |
56 | function processScroll() {
57 | var i, scrollTop = $win.scrollTop()
58 | if (scrollTop >= navTop && !isFixed) {
59 | isFixed = 1
60 | $nav.addClass('subnav-fixed')
61 | } else if (scrollTop <= navTop && isFixed) {
62 | isFixed = 0
63 | $nav.removeClass('subnav-fixed')
64 | }
65 | }
66 |
67 | // tooltip demo
68 | $('.tooltip-demo.well').tooltip({
69 | selector: "a[rel=tooltip]"
70 | })
71 |
72 | $('.tooltip-test').tooltip()
73 | $('.popover-test').popover()
74 |
75 | // popover demo
76 | $("a[rel=popover]")
77 | .popover()
78 | .click(function(e) {
79 | e.preventDefault()
80 | })
81 |
82 | // button state demo
83 | $('#fat-btn')
84 | .click(function () {
85 | var btn = $(this)
86 | btn.button('loading')
87 | setTimeout(function () {
88 | btn.button('reset')
89 | }, 3000)
90 | })
91 |
92 | // carousel demo
93 | $('#myCarousel').carousel()
94 |
95 | // javascript build logic
96 | var inputsComponent = $("#components.download input")
97 | , inputsPlugin = $("#plugins.download input")
98 | , inputsVariables = $("#variables.download input")
99 |
100 | // toggle all plugin checkboxes
101 | $('#components.download .toggle-all').on('click', function (e) {
102 | e.preventDefault()
103 | inputsComponent.attr('checked', !inputsComponent.is(':checked'))
104 | })
105 |
106 | $('#plugins.download .toggle-all').on('click', function (e) {
107 | e.preventDefault()
108 | inputsPlugin.attr('checked', !inputsPlugin.is(':checked'))
109 | })
110 |
111 | $('#variables.download .toggle-all').on('click', function (e) {
112 | e.preventDefault()
113 | inputsVariables.val('')
114 | })
115 |
116 | // request built javascript
117 | $('.download-btn').on('click', function () {
118 |
119 | var css = $("#components.download input:checked")
120 | .map(function () { return this.value })
121 | .toArray()
122 | , js = $("#plugins.download input:checked")
123 | .map(function () { return this.value })
124 | .toArray()
125 | , vars = {}
126 | , img = ['glyphicons-halflings.png', 'glyphicons-halflings-white.png']
127 |
128 | $("#variables.download input")
129 | .each(function () {
130 | $(this).val() && (vars[ $(this).prev().text() ] = $(this).val())
131 | })
132 |
133 | $.ajax({
134 | type: 'POST'
135 | , url: 'http://bootstrap.herokuapp.com'
136 | , dataType: 'jsonpi'
137 | , params: {
138 | js: js
139 | , css: css
140 | , vars: vars
141 | , img: img
142 | }
143 | })
144 | })
145 |
146 | })
147 |
148 | // Modified from the original jsonpi https://github.com/benvinegar/jquery-jsonpi
149 | $.ajaxTransport('jsonpi', function(opts, originalOptions, jqXHR) {
150 | var url = opts.url;
151 |
152 | return {
153 | send: function(_, completeCallback) {
154 | var name = 'jQuery_iframe_' + jQuery.now()
155 | , iframe, form
156 |
157 | iframe = $('