Commit Graph

40 Commits

Author SHA1 Message Date
Mohammed Bilal
e579e0f707 New upstream version 1.4.3+dfsg.1 2022-05-05 10:45:21 +00:00
Utkarsh Gupta
22a2d3d5ef New upstream version 1.1.0+dfsg.1 2020-12-07 04:06:37 +05:30
Jongmin Kim
ac3d33df5d New upstream version 0.28.1+dfsg.1 2019-05-12 00:29:21 +09:00
Patrick Steinhardt
5c2a8361d7 examples: diff: parse correct types for line-diffopts 2016-10-10 09:04:42 +02:00
Carlos Martín Nieto
799e22ea0c Rename git_threads_ to git_libgit2_
This describes their purpose better, as we now initialize ssl and some
other global stuff in there. Calling the init function is not something
which has been optional for a while now.
2014-11-08 23:46:39 +01: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
Sun He
6246de93b6 Merge completed: resolve the conflict with the upstream 2014-03-06 11:16:36 +08: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
Russell Belfer
d88399922f Fix warnings and code style issues 2014-02-27 14:01:16 -08: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
6cb831bd56 Replace copyright topmatter in example files 2013-11-02 05:33:26 -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
Ben Straub
85c6730ce8 Format comments for use with docco 2013-10-31 14:35:32 -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
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
Russell Belfer
5c8f37a397 Extend diff example
Add --raw output format and (some) options to invoke rename/copy
detection on the diff.
2013-05-17 17:33:03 -07:00
Russell Belfer
8d78400142 Make examples/diff.c compile vs threadsafe library 2013-05-16 10:43:10 -07:00
Ben Straub
201566539f Clean up minor details 2013-04-15 13:29:40 -07:00
Ben Straub
299a224be1 Change git_revparse to output git_object pointers
This will probably prevent many lookup/free
operations in calling code.
2013-04-15 12:00:04 -07:00
Ben Straub
1aa21fe3b8 Deprecate git_revparse_single and _rangelike 2013-04-09 05:07:04 +04:00
Russell Belfer
7bd53bf385 Simplify diff example using revparse
When the examples/diff.c was written, there was not yet a revparse
API.  Now we can use it to make command line parsing way better
with less code.  Yay!
2013-03-02 13:52:38 -08:00
Sebastian Bauer
75a0a80029 Don't clear the opt instance in the diff example.
The version field is overwritten otherwise. The opt instance is
already initialized properly.
2013-01-23 07:47:40 +01:00
Russell Belfer
56c72b759c Fix diff constructor name order confusion
The diff constructor functions had some confusing names, where the
"old" side of the diff was coming after the "new" side.  This
reverses the order in the function name to make it less confusing.

Specifically...

* git_diff_index_to_tree becomes git_diff_tree_to_index
* git_diff_workdir_to_index becomes git_diff_index_to_workdir
* git_diff_workdir_to_tree becomes git_diff_tree_to_workdir
2012-12-17 11:00:53 -08:00
Ben Straub
2f8d30becb Deploy GIT_DIFF_OPTIONS_INIT 2012-11-30 13:12:14 -08:00
Russell Belfer
793c438559 Update diff callback param order
This makes the diff functions that take callbacks both take
the payload parameter after the callback function pointers and
pass the payload as the last argument to the callback function
instead of the first.  This should make them consistent with
other callbacks across the API.
2012-11-27 13:18:28 -08:00
Ben Straub
bac695b58c Examples: fix reference names 2012-11-27 13:18:28 -08:00
Russell Belfer
bbe6dbec81 Add explicit git_index ptr to diff and checkout
A number of diff APIs and the `git_checkout_index` API take a
`git_repository` object an operate on the index.  This updates
them to take a `git_index` pointer explicitly and only fall back
on the `git_repository` index if the index input is NULL.  This
makes it easier to operate on a temporary index.
2012-11-14 23:29:48 -08:00
Russell Belfer
b90500f03d Improve docs, examples, warnings
This improves docs in some of the public header files, cleans
up and improves some of the example code, and fixes a couple
of pedantic warnings in places.
2012-11-01 14:08:30 -07:00
Russell Belfer
145e696b49 Minor fixes, cleanups, and clarifications
There are three actual changes in this commit:

1. When the trailing newline of a file is removed in a diff, the
   change will now be reported with `GIT_DIFF_LINE_DEL_EOFNL` passed
   to the callback.  Previously, the `ADD_EOFNL` constant was given
   which was just an error in my understanding of when the various
   circumstances arose.  `GIT_DIFF_LINE_ADD_EOFNL` is deprecated and
   should never be generated.  A new newline is simply an `ADD`.
2. Rewrote the `diff_delta__merge_like_cgit` function that contains
   the core logic of the `git_diff_merge` implementation.  The new
   version doesn't actually have significantly different behavior,
   but the logic should be much more obvious, I think.
3. Fixed a bug in `git_diff_merge` where it freed a string pool
   while some of the string data was still in use.  This led to
   `git_diff_print_patch` accessing memory that had been freed.

The rest of this commit contains improved documentation in `diff.h`
to make the behavior and the equivalencies with core git clearer,
and a bunch of new tests to cover the various cases, oh and a minor
simplification of `examples/diff.c`.
2012-06-08 12:11:13 -07:00
Russell Belfer
706a9974a2 Basic setup for profiling
This fixes the examples so they will build and adds a PROFILE
option to the CMakeFile that enabled gprof info on non-Windows
2012-05-17 13:05:17 -07:00
schu
288c8a2575 examples/diff: update example code
Signed-off-by: schu <schu-github@schulog.org>
2012-03-13 16:51:16 +01:00
Russell Belfer
74fa4bfae3 Update diff to use iterators
This is a major reorganization of the diff code.  This changes
the diff functions to use the iterators for traversing the
content.  This allowed a lot of code to be simplified.  Also,
this moved the functions relating to outputting a diff into a
new file (diff_output.c).

This includes a number of other changes - adding utility
functions, extending iterators, etc. plus more tests for the
diff code.  This also takes the example diff.c program much
further in terms of emulating git-diff command line options.
2012-03-02 15:49:29 -08:00
Russell Belfer
a2e895be82 Continue implementation of git-diff
* Implemented git_diff_index_to_tree
* Reworked git_diff_options structure to handle more options
* Made most of the options in git_diff_options actually work
* Reorganized code a bit to remove some redundancy
* Added option parsing to examples/diff.c to test most options
2012-03-02 15:49:29 -08:00
Russell Belfer
3a4375901a Clean up diff implementation for review
This fixes several bugs, updates tests and docs, eliminates the
FILE* assumption in favor of printing callbacks for the diff patch
formatter helpers, and adds a "diff" example function that can
perform a diff from the command line.
2012-03-02 15:49:28 -08:00