summaryrefslogtreecommitdiff
path: root/examples/diff.c
Commit message (Collapse)AuthorAgeFilesLines
* examples: diff: parse correct types for line-diffoptsPatrick Steinhardt2016-10-101-3/+3
|
* Rename git_threads_ to git_libgit2_Carlos Martín Nieto2014-11-081-2/+2
| | | | | | 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.
* Use git_diff_get_stats in example/diff + refactorRussell Belfer2014-04-221-66/+37
| | | | | | | | | | | | | | | | | | | | | 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.
* Some doc and examples/diff.c changesRussell Belfer2014-04-221-65/+86
| | | | | | | | | | | | | | 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.
* Merge completed: resolve the conflict with the upstreamSun He2014-03-061-0/+4
|\
| * examples/diff: Add minimal, patience diff options.Brian Gesiak2014-03-051-0/+4
| | | | | | | | | | | | | | - 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.
* | fix the output format of diffSun He2014-03-051-2/+2
| |
* | Add the --shortstat flag to examples/diff.cSun He2014-03-051-1/+51
|/
* Fix warnings and code style issuesRussell Belfer2014-02-271-7/+11
|
* replace 'out' with 'patch',replace the literal tabs with '\t'.rocky-luo2014-02-091-6/+6
|
* add example for diff with --numstatrocky-luo2014-02-081-8/+38
|
* Replace copyright topmatter in example filesBen Straub2013-11-021-3/+10
|
* A few formatting changes for roccoCarlos Martín Nieto2013-11-011-5/+6
| | | | | I'm not too happy about manually inserting < and > but those get output as html tags otherwise.
* Format comments for use with doccoBen Straub2013-10-311-16/+17
|
* Extract common example helpers and reorg examplesRussell Belfer2013-10-291-191/+183
| | | | | | | | | 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.
* Create git_diff_line and extend git_diff_hunkRussell Belfer2013-10-211-12/+16
| | | | | | | | | | | | | 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.
* Diff API cleanupRussell Belfer2013-10-151-21/+8
| | | | | | | | 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.
* Rename diff objects and split patch.hRussell Belfer2013-10-111-5/+5
| | | | | | 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.
* Extend diff exampleRussell Belfer2013-05-171-6/+44
| | | | | Add --raw output format and (some) options to invoke rename/copy detection on the diff.
* Make examples/diff.c compile vs threadsafe libraryRussell Belfer2013-05-161-2/+8
|
* Clean up minor detailsBen Straub2013-04-151-1/+1
|
* Change git_revparse to output git_object pointersBen Straub2013-04-151-4/+2
| | | | This will probably prevent many lookup/free operations in calling code.
* Deprecate git_revparse_single and _rangelikeBen Straub2013-04-091-1/+3
|
* Simplify diff example using revparseRussell Belfer2013-03-021-20/+1
| | | | | | 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!
* Don't clear the opt instance in the diff example.Sebastian Bauer2013-01-231-2/+0
| | | | | The version field is overwritten otherwise. The opt instance is already initialized properly.
* Fix diff constructor name order confusionRussell Belfer2012-12-171-7/+7
| | | | | | | | | | | | 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
* Deploy GIT_DIFF_OPTIONS_INITBen Straub2012-11-301-1/+1
|
* Update diff callback param orderRussell Belfer2012-11-271-4/+4
| | | | | | | | 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.
* Examples: fix reference namesBen Straub2012-11-271-1/+1
|
* Add explicit git_index ptr to diff and checkoutRussell Belfer2012-11-141-6/+6
| | | | | | | | 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.
* Improve docs, examples, warningsRussell Belfer2012-11-011-10/+14
| | | | | | 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.
* Minor fixes, cleanups, and clarificationsRussell Belfer2012-06-081-3/+1
| | | | | | | | | | | | | | | | | | | | | | | 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`.
* Basic setup for profilingRussell Belfer2012-05-171-1/+7
| | | | | This fixes the examples so they will build and adds a PROFILE option to the CMakeFile that enabled gprof info on non-Windows
* examples/diff: update example codeschu2012-03-131-2/+2
| | | | Signed-off-by: schu <schu-github@schulog.org>
* Update diff to use iteratorsRussell Belfer2012-03-021-10/+33
| | | | | | | | | | | | | 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.
* Continue implementation of git-diffRussell Belfer2012-03-021-20/+97
| | | | | | | | * 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
* Clean up diff implementation for reviewRussell Belfer2012-03-021-0/+134
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.