Commit Graph

189 Commits

Author SHA1 Message Date
Ben Straub
dcfdb977d0 Relicense examples under CC0 2013-11-01 10:51:12 -07:00
Vicent Martí
567649f2ad Merge pull request #1916 from libgit2/simplify-examples
Fix examples to make the important stuff more obvious
2013-11-01 09:38:34 -07:00
Vicent Martí
ac5e507cec Merge pull request #1918 from libgit2/cmn/indexer-naming
indexer: remove the stream infix
2013-11-01 09:31:52 -07:00
Ben Straub
4f62d55968 Fix typos 2013-11-01 05:39:21 -07:00
Carlos Martín Nieto
c44820c616 A few formatting changes for rocco
I'm not too happy about manually inserting < and > but those get
output as html tags otherwise.
2013-11-01 09:08:22 +01:00
Russell Belfer
76120863a7 Update examples/README.md 2013-10-31 14:48:41 -07:00
Ben Straub
85c6730ce8 Format comments for use with docco 2013-10-31 14:35:32 -07:00
Linquize
864e72719c Use gmtime() instead of gmtime_t()
The latter is not available on Windows
2013-10-31 21:03:28 +08:00
Ben Straub
dbdb22b330 Clean up showindex sample 2013-10-30 13:20:08 -07:00
Ben Straub
b9d02460f1 Reorganize rev-parse example 2013-10-30 13:07:58 -07:00
Ben Straub
784b3abbd5 rev-list.c example: use common utils, reorganize 2013-10-30 12:34:03 -07:00
Ben Straub
9d83d368fc cat-file.c example: deploy helpers, reorg 2013-10-30 07:21:36 -07:00
Ben Straub
dbfd283327 add.c: proper frontmatter 2013-10-30 07:21:12 -07:00
Carlos Martín Nieto
a6154f2183 indexer: remove the stream infix
It was there to keep it apart from the one which read in from a file on
disk. This other indexer does not exist anymore, so there is no need for
anything other than git_indexer to refer to it.

While here, rename _add() function to _append() and _finalize() to
_commit(). The former change is cosmetic, while the latter avoids
talking about "finalizing", which OO languages use to mean something
completely different.
2013-10-30 15:00:05 +01:00
Ben Straub
7cc3c9bf00 init.c example: deploy more helpers 2013-10-30 06:09:08 -07:00
Ben Straub
e568bedf52 add.c example: deploy helpers, reorg 2013-10-30 06:08:54 -07:00
Ben Straub
a8422f9202 init example: deploy helpers, reorg 2013-10-30 05:38:12 -07:00
Russell Belfer
66902d4773 Extract common example helpers and reorg examples
This reorganizes a few of the examples so that the main function
comes first with the argument parsing extracted into a helper
that can come at the end of the file (so the example focuses more
on the use of libgit2 instead of command line support).  This also
creates a shared examples/common.[ch] so that useful helper funcs
can be shared across examples instead of repeated.
2013-10-29 18:30:49 -07:00
Vicent Martí
5c50f22a93 Merge pull request #1891 from libgit2/cmn/fix-thin-packs
Add support for thin packs
2013-10-28 09:25:44 -07:00
Carlos Martín Nieto
ab46b1d8eb indexer: include the delta stats
The user is unable to derive the number of deltas in the pack, as that
would require them to capture the stats exactly in the moment between
download and final processing, which is abstracted away in the fetch.

Capture these numbers for the user and expose them in the progress
struct. The clone and fetch examples now also present this information
to the user.
2013-10-23 15:08:18 +02:00
Carlos Martín Nieto
ebbd48f00e examples: show used local objects in fetch
Show how many local objects were used to fix the thin pack in our fetch
example.
2013-10-23 14:22:44 +02:00
Russell Belfer
3b5f795446 Create git_diff_line and extend git_diff_hunk
Instead of having functions with so very many parameters to pass
hunk and line data, this takes the existing git_diff_hunk struct
and extends it with more hunk data, plus adds a git_diff_line.
Those structs are used to pass back hunk and line data instead of
the old APIs that took tons of parameters.

Some work that was previously only being done for git_diff_patch
creation (scanning the diff content for exact line counts) is now
done for all callbacks, but the performance difference should not
be noticable.
2013-10-21 13:42:42 -07:00
Russell Belfer
10672e3e45 Diff API cleanup
This lays groundwork for separating formatting options from diff
creation options.  This groups the formatting flags separately
from the diff list creation flags and reorders the options.  This
also tweaks some APIs to further separate code that uses patches
from code that just looks at git_diffs.
2013-10-15 15:10:07 -07:00
Russell Belfer
3ff1d12373 Rename diff objects and split patch.h
This makes no functional change to diff but renames a couple of
the objects and splits the new git_patch (formerly git_diff_patch)
into a new header file.
2013-10-11 14:51:54 -07:00
Carlos Martín Nieto
0b33fca03e indexer: fix thin packs
When given an ODB from which to read objects, the indexer will attempt
to inject the missing bases at the end of the pack and update the
header and trailer to reflect the new contents.
2013-10-04 15:26:41 +02:00
Carlos Martín Nieto
0e0cf78773 clone: put the callbacks struct directly in the clone options
There's no need for this to be a pointer to somewhere else.
2013-10-02 14:04:44 +02:00
Carlos Martín Nieto
e3c131c544 remote: move the credentials callback to the struct
Move this one as well, letting us have a single way of setting the
callbacks for the remote, and removing fields from the clone options.
2013-10-02 06:41:42 +02:00
Carlos Martín Nieto
d31402a3fc remote: put the _download() callback with the others
The text progress and update_tips callbacks are already part of the
struct, which was meant to unify the callback setup, but the download
one was left out.
2013-10-02 06:41:42 +02:00
Russell Belfer
37f9e40939 Some tests with ident and crlf filters
Fixed the filter order to match core Git, too.

This test demonstrates an interesting behavior of core Git (which
is totally reasonable and which libgit2 matches, although mostly
by coincidence).  If you use the ident filter and commit a file
with a garbage ident in it, like '$Id: this is just garbage$' and
then immediately do a 'git checkout-index' with the new file, Git
will not consider the file out of date and will not overwrite the
file with an updated $Id$.  Libgit2 has the same behavior.  If you
remove the file and then do a checkout-index, it will be replaced
with a filtered version that has injected the OID correctly.
2013-09-17 09:31:46 -07:00
Carlos Martín Nieto
605da51a2c No such thing as an orphan branch
Unfortunately git-core uses the term "unborn branch" and "orphan
branch" interchangeably. However, "orphan" is only really there for
the checkout command, which has the `--orphan` option so it doesn't
actually create the branch.

Branches never have parents, so the distinction of a branch with no
parents is odd to begin with. Crucially, the error messages deal with
unborn branches, so let's use that.
2013-09-17 09:50:30 +02:00
Russell Belfer
0c52b204c5 Make work if built with threading enabled 2013-09-09 11:07:17 -07:00
Krzysztof Adamski
b2395a8267 Only use callbacks when -n or -v in add example. 2013-09-09 11:01:31 -07:00
Krzysztof Adamski
04fd266584 Move statement after declarations in add example. 2013-09-09 11:01:31 -07:00
Krzysztof Adamski
9a0e42c673 Remove unnececery arguments priting in add example. 2013-09-09 11:01:30 -07:00
Krzysztof Adamski
813937ce4e Better usage info in add example. 2013-09-09 11:01:30 -07:00
Krzysztof Adamski
24d2322096 Add -u option to add example. 2013-09-09 11:01:30 -07:00
Krzysztof Adamski
e8fa14d3a3 Supported options information in add example. 2013-09-09 11:01:30 -07:00
Krzysztof Adamski
62020aa8f9 Adding add example. 2013-09-09 11:01:30 -07:00
Russell Belfer
60ee53dfce Split examples CMakeLists.txt
Also, this converts the examples/CMakeLists.txt from explicitly
listing to just globbing for all the individual C files.
2013-09-03 15:20:16 -07:00
Krzysztof Adamski
255836ddac Adding credentials callback to ls-remote and fetch too. 2013-09-01 19:00:16 +02:00
Krzysztof Adamski
d6d523486c Removing unneeded code duplication in ls-remote.c 2013-09-01 19:00:16 +02:00
Russell Belfer
0ea41445f4 Improve isolation of new test from user environs 2013-08-16 15:04:15 -07:00
Russell Belfer
944c1589c2 Add example like "git init" 2013-08-16 15:04:15 -07:00
Brendan Macmillan
c3ae047361 Fix -n bug; default to all ancestors 2013-07-27 05:34:49 +10:00
Russell Belfer
bc6f0839eb Add a bunch more features to log example 2013-07-10 20:50:32 +02:00
Russell Belfer
a8b5f116bc Fix example/log.c pathspec handling of merges
This fixes the way the example log program decides if a merge
commit should be shown when a pathspec is given.  Also makes it
easier to use the pathspec API to just check "does a tree match
anything in the pathspec" without allocating a match list.
2013-07-10 20:50:32 +02:00
Russell Belfer
733c4f3aca more examples/log.c bug fixing 2013-07-10 20:50:32 +02:00
Russell Belfer
5a169711fa fix bug with order args and no revision 2013-07-10 20:50:32 +02:00
Russell Belfer
2b3bd8ecd8 Fix example/log.c minor diffs with git log 2013-07-10 20:50:32 +02:00
Russell Belfer
f44c4fa108 Add basic commit formatting to log output 2013-07-10 20:50:32 +02:00