Commit Graph

310 Commits

Author SHA1 Message Date
Eoin Coffey
33bf1b1ab0 examples/log.c: invert filtering impl and conditional 2014-05-28 09:40:08 -06:00
Eoin Coffey
26cce32133 Add support for --grep 2014-05-23 12:59:19 -06:00
Eoin Coffey
161e6dc1ca Add --committer option, and break out helper function 2014-05-23 12:27:16 -06:00
Eoin Coffey
97fc71ab3b Add support for --author flag in example log implementation 2014-05-22 17:22:45 -06:00
Edward Thomson
ead9c591ef Include windows.h on win32 for Sleep 2014-05-21 17:25:00 -07:00
Jeff King
56ec2256f2 examples: add a basic for-each-ref example
This is quite close to running "git for-each-ref" except:

  1. It does not take any formatting or selection options at
     all.

  2. The output is not sorted.

I wrote it to look at debugging some issues with ref
iteration, but there's no reason it can't live on as an
example command.
2014-05-08 15:49:38 -04:00
Linquize
d0420fc681 Make examples/status.c compile on Windows 2014-05-01 22:39:35 +08:00
Vicent Marti
8443ed6c1d Merge pull request #2284 from jacquesg/push-progress-callback
Fire progress and update tips callbacks also for pushes.
2014-04-25 02:10:19 -07:00
Russell Belfer
8d09efa24e Use git_diff_get_stats in example/diff + refactor
This takes the `--stat` and related example options in the example
diff.c program and converts them to use the `git_diff_get_stats`
API which nicely formats stats for you.

I went to add bar-graph scaling to the stats formatter and noticed
that the `git_diff_stats` structure was holding on to all of the
`git_patch` objects.  Unfortunately, each of these objects keeps
the full text of the diff in memory, so this is very expensive.  I
ended up modifying `git_diff_stats` to keep just the data that it
needs to keep and allowed it to release the patches.  Then, I added
width scaling to the output on top of that.

In making the diff example program match 'git diff' output, I ended
up removing an newline from the sumamry output which I then had to
compensate for in the email formatting to match the expectations.

Lastly, I went through and refactored the tests to use a couple of
helper functions and reduce the overall amount of code there.
2014-04-22 12:33:27 -07:00
Russell Belfer
12e422a056 Some doc and examples/diff.c changes
I was playing with "git diff-index" and wanted to be able to
emulate that behavior a little more closely with the diff example.

Also, I wanted to play with running `git_diff_tree_to_workdir`
directly even though core Git doesn't exactly have the equivalent,
so I added a command line option for that and tweaked some other
things in the example code.

This changes a minor output thing in that the "raw" print helper
function will no longer add ellipses (...) if the OID is not
actually abbreviated.
2014-04-22 09:17:29 -07:00
Jacques Germishuys
48e60ae75e Don't redefine the same callback types, their signatures may change 2014-04-21 11:28:49 +02:00
Russell Belfer
d543d59cf0 Add some funny options for debugging status
This allows you to use a --repeat option to run status over and
over and see how the output changes as you make local directory
changes without reopening the git_repository object each time.

Also, adds a flag to explicitly list the submodules before status.
2014-04-01 09:45:20 -07:00
Vicent Marti
a2d18a0219 Merge pull request #2228 from mekishizufu/example_short_id
Use git_object_short_id in examples
2014-04-01 13:47:52 +02:00
Vicent Marti
9325460a93 Merge pull request #2206 from libgit2/cmn/inmemory-swap-order
Rename in-memory remote to anonymous and swap url and fetch order
2014-04-01 13:47:44 +02:00
Carlos Martín Nieto
fd536d29c1 remote: rename inmemory to anonymous and swap url and fetch order
The order in this function is the opposite to what
create_with_fetchspec() has, so change this one, as url-then-refspec is
what git does.

As we need to break compilation and the swap doesn't do that, let's take
this opportunity to rename in-memory remotes to anonymous as that's
really what sets them apart.
2014-04-01 13:38:04 +02:00
Jiri Pospisil
6ad59ef1d4 examples: Use git_object_short_id 2014-04-01 12:16:40 +02:00
Russell Belfer
a15c7802c8 Make submodules externally refcounted
`git_submodule` objects were already refcounted internally in case
the submodule name was different from the path at which it was
stored.  This makes that refcounting externally used as well, so
`git_submodule_lookup` and `git_submodule_add_setup` return an
object that requires a `git_submodule_free` when done.
2014-03-25 09:14:48 -07:00
Vicent Marti
041cd4a23f Merge pull request #2028 from libgit2/options-names
Rename options structures
2014-03-07 19:02:58 +01:00
Russell Belfer
5a6de908f6 Merge pull request #2153 from mekishizufu/tag_example
Add a tag example
2014-03-07 09:13:43 -08:00
Ben Straub
6affd71f33 git_checkout_opts -> git_checkout_options 2014-03-06 09:44:51 -08:00
Sun He
6246de93b6 Merge completed: resolve the conflict with the upstream 2014-03-06 11:16:36 +08:00
Jiri Pospisil
feebe6150f Move all variable declarations to the top of the block 2014-03-05 20:31:15 +01:00
Jiri Pospisil
a53b858417 Add tag example 2014-03-05 20:31:15 +01:00
Sun He
8384a50a21 fix the output format of diff 2014-03-05 20:33:20 +08:00
Sun He
45d2e8dc46 Add the --shortstat flag to examples/diff.c 2014-03-05 20:13:34 +08:00
Brian Gesiak
0d3c8a9d92 examples/diff: Add minimal, patience diff options.
- Add minimal, patience diff options to diff example. libgit2
  `diff_xdiff.git_xdiff_init` already supports these flags, so
  no additional change is necessary.
- Remove minimal and patience flag addition from project list.
2014-03-05 13:06:31 +09:00
Miha Ravšelj
b43f35fde2 - examples CMakeLists.txt reverted to previous state 2014-03-03 14:59:50 +01:00
Miha
6874cafd84 cmake examples change so that general.c is off by default 2014-03-03 12:08:17 +01:00
Miha
0330469f6d - general.c reverted to original( before pr state ) 2014-03-03 11:42:25 +01:00
Miha
b5212858f1 Merge remote-tracking branch 'remotes/upstream/development' into development 2014-03-03 11:40:22 +01:00
Russell Belfer
d88399922f Fix warnings and code style issues 2014-02-27 14:01:16 -08:00
Miha
300f44125a - BUGFIX #2133 (@fourplusone) in smart_protocol.c
- added MSVC cmake definitions to disable warnings
- general.c is rewritten so it is ansi-c compatible and compiles ok on microsoft windows
- some MSVC reported warning fixes
2014-02-25 11:56:11 +01:00
Juan Rubén
899bd19a62 Document enumerator and rewording 2014-02-24 21:20:57 +01:00
Juan Rubén
c7c833947e Add option to limit blame to first parent 2014-02-23 23:26:12 +01:00
rocky-luo
8086b78be0 replace 'out' with 'patch',replace the literal tabs with '\t'. 2014-02-09 21:08:42 +08:00
rocky-luo
4f5a3f400b add example for diff with --numstat 2014-02-08 20:10:19 +08:00
Ben Straub
5c8be32559 Fix a few references to changed function signatures 2014-02-05 13:32:45 -08:00
Vicent Marti
93954245e0 Merge pull request #2075 from libgit2/cmn/leftover-oid
Leftover OID -> ID changes
2014-01-27 09:39:36 -08:00
Vicent Marti
c90ea3de78 Merge pull request #2078 from linquize/msvc
MSVC doesn't like modern code neither
2014-01-27 09:34:52 -08:00
Linquize
1664aaaa26 Make blame example compile on MSVC 2014-01-27 22:41:05 +08:00
Linquize
fbc5661ebf MSVC doesn't like modern code neither 2014-01-27 20:52:57 +08:00
Carlos Martín Nieto
d541170c77 index: rename an entry's id to 'id'
This was not converted when we converted the rest, so do it now.
2014-01-25 08:15:44 +01:00
Ben Straub
83e1efbf46 Update files that reference tests-clar 2013-11-14 14:10:32 -08:00
Linquize
fb190bbbd0 Fix warnings 2013-11-12 19:46:25 +08:00
Vicent Martí
6414fd338d Merge pull request #1956 from libgit2/cmn/fetch-default-head
Remote revamp (director's cut)
2013-11-11 06:47:15 -08:00
Carlos Martín Nieto
359dce726d remote: make _ls return the list directly
The callback-based method of listing remote references dates back to the
beginning of the network code's lifetime, when we didn't know any
better.

We need to keep the list around for update_tips() after disconnect() so
let's make use of this to simply give the user a pointer to the array so
they can write straightforward code instead of having to go through a
callback.
2013-11-11 15:35:51 +01:00
Edward Thomson
ad62f2eedc update example to new packfile creation signature 2013-11-07 12:00:43 -06:00
Ben Straub
b47949254e blame sample: usage comment 2013-11-04 15:54:11 -08:00
Ben Straub
ea8ce3d17e Fix warnings 2013-11-04 15:50:33 -08:00
Ben Straub
e6b85be7cf Reorganize and doc-commentify blame sample. 2013-11-04 15:48:35 -08:00
Ben Straub
b7bb086b1c Standardize layout of blame sample 2013-11-04 15:25:26 -08:00
Russell Belfer
fb6b0e019e Merge pull request #1317 from libgit2/blame
Blame Canada
2013-11-04 10:44:59 -08:00
Vicent Martí
a605bbd9b4 Merge pull request #1934 from libgit2/relicense-examples
Relicense examples under CC0
2013-11-04 10:14:22 -08:00
Vicent Martí
5a0b88036f Merge pull request #1929 from libgit2/rb/misc-diff-fixes
Fix some observed problems with incorrect diffs
2013-11-04 08:05:55 -08:00
Carlos Martín Nieto
becb13c0f0 examples: doc update
Update the explanation to reflect our use of git_status_list_new() and
make the breaks in rocco more meaningful.

Clarify why GIT_STATUS_CURRENT and index_to_workdir don't always imply
each other. Fixes #1740.
2013-11-03 16:20:24 +01:00
Ben Straub
6cb831bd56 Replace copyright topmatter in example files 2013-11-02 05:33:26 -07:00
Ben Straub
dcfdb977d0 Relicense examples under CC0 2013-11-01 10:51:12 -07:00
Russell Belfer
4bf630b6ba Make diff and status perform soft index reload
This changes `git_index_read` to have two modes - a hard index
reload that always resets the index to match the on-disk data
(which was the old behavior) and a soft index reload that uses
the timestamp / file size information and only replaces the index
data if the file on disk has been modified.

This then updates the git_status code to do a soft reload unless
the new GIT_STATUS_OPT_NO_REFRESH flag is passed in.

This also changes the behavior of the git_diff functions that use
the index so that when an index is not explicitly passed in (i.e.
when the functions call git_repository_index for you), they will
also do a soft reload for you.

This intentionally breaks the file signature of git_index_read
because there has been some confusion about the behavior previously
and it seems like all existing uses of the API should probably be
examined to select the desired behavior.
2013-11-01 10:20:51 -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
Ben Straub
42c8f8f807 Merge remote-tracking branch 'libgit2/development' into blame 2013-10-28 11:04:58 -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
Ben Straub
607fe73370 Fix post-line-range iteration 2013-10-10 14:30:31 -07:00
Ben Straub
c1ca2b67e1 Include signatures in blame hunks 2013-10-10 14:30:05 -07:00
Ben Straub
ebd67243d5 Only show lines that had blame run on them 2013-10-10 13:56:45 -07:00
Ben Straub
d2e7532f62 Be more flexible with argument order and format 2013-10-10 13:56:28 -07:00
Ben Straub
0a23d2058d Ignore more built examples 2013-10-09 16:18:32 -07:00
Ben Straub
43a07b860b Simplify loading blob 2013-10-09 16:16:43 -07:00
Ben Straub
2ccc84d2ef Allow null bytes in blob 2013-10-09 16:07:36 -07:00
Ben Straub
cb45dafaf8 Initialize threading, fix broken strncmp 2013-10-09 16:07:17 -07:00
Ben Straub
370d1d166e Un-remove init example 2013-10-09 14:41:44 -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
Ben Straub
fc1f7d4f15 Merge branch 'development' into blame
Conflicts:
	include/git2.h
2013-10-03 06:20:20 -07: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
Ben Straub
de8fe729ef Fix typo 2013-09-29 10:46:41 -07:00
Ben Straub
41dd999d12 Merge branch 'development' into blame 2013-09-25 14:47:32 -07: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