Commit Graph

982 Commits

Author SHA1 Message Date
Daniel Rodríguez Troitiño
f8bd730cd9 Fix documentation of git_branch_delete.
The reference should be freed by the user, not the library.
2013-05-26 17:29:00 +02:00
Russell Belfer
d20b044961 Clarify GIT_DIFF_INCLUDE_UNTRACKED_CONTENT option
This improves the docs for GIT_DIFF_INCLUDE_UNTRACKED_CONTENT as
well as the other flags related to UNTRACKED items in diff, plus
it makes that flag now automatically turn on
GIT_DIFF_INCLUDE_UNTRACKED which seems like a reasonable dwim type
of change.
2013-05-24 10:37:40 -07:00
Russell Belfer
16adc9fade Typedef git_config_level_t and use it everywhere
The GIT_CONFIG_LEVEL constants actually work well as an enum
because they are mutually exclusive, so this adds a typedef to
the enum and uses that everywhere that one of these constants are
expected, instead of the old code that typically used an unsigned
int.
2013-05-24 10:35:58 -07:00
Russell Belfer
2e62e7c23c Docs for git_libgit2_opts and cache disable tweak
This adds docs for the cache control options to git_libgit2_opts
and also tweaks the cache code so that if the cache is disabled,
then the next time we attempt to insert something into the cache
in question, we will actually clear any old cached objects.
2013-05-24 10:33:41 -07:00
Russell Belfer
0f1f9833cf Add typedefs on some public enums
Apparently this makes things easier to bind in some languages.
2013-05-24 10:32:07 -07:00
Vicent Martí
26ab6284b2 Merge pull request #1593 from ethomson/conflict_iterator
introduce git_conflict_iterator
2013-05-24 03:30:35 -07:00
Vicent Martí
f7ceef06eb Merge pull request #1592 from ethomson/merge_setup
merge setup
2013-05-24 03:24:27 -07:00
Vicent Martí
4811c1500b Merge pull request #1603 from ben/shallow
Shallow-clone detection
2013-05-24 01:14:52 -07:00
Vicent Martí
30caf0cf29 Merge pull request #1595 from arrbee/even-more-rename-fixes
Even more rename detection fixes
2013-05-24 01:13:48 -07:00
Ben Straub
93d8f77fed Improve test failure output 2013-05-23 15:35:50 -07:00
Russell Belfer
67db583dab More diff rename tests; better split swap handling
This adds a couple more tests of different rename scenarios.

Also, this fixes a problem with the case where you have two
"split" deltas and the left half of one matches the right half of
the other.  That case was already being handled, but in the wrong
order in a way that could result in bad output.  Also, if the swap
also happened to put the other two halves into the correct place
(i.e. two files exchanged places with each other), then the second
delta was left with the SPLIT flag set when it really should be
cleared.
2013-05-23 15:06:07 -07:00
Russell Belfer
a21cbb12db Significant rename detection rewrite
This flips rename detection around so instead of creating a
forward mapping from deltas to possible rename targets, instead
it creates a reverse mapping, looking at possible targets and
trying to find a source that they could have been renamed or
copied from.  This is important because each output can only
have a single source, but a given source could map to multiple
outputs (in the form of COPIED records).

Additionally, this makes a couple of tweaks to the public rename
detection APIs, mostly renaming a couple of options that control
the behavior to make more sense and to be more like core Git.

I walked through the tests looking at the exact results and
updated the expectations based on what I saw.  The new code is
different from the old because it cannot give some nonsense
results (like A was renamed to both B and C) which were part of
the outputs previously.
2013-05-22 10:37:12 -07:00
Ben Straub
6828bf26e9 Merge pull request #1594 from nulltoken/topic/tag_annotation
tag: Introduce git_tag_annotation_create()
2013-05-21 10:49:36 -07:00
nulltoken
b81cc1d63b tag: Introduce git_tag_annotation_create() 2013-05-21 19:32:59 +02:00
Ben Straub
e167ec1897 Merge pull request #1597 from zodiac/patch-1
define "long name" in git_reference_name_to_id
2013-05-21 08:09:17 -07:00
Carlos Martín Nieto
fc74343ff4 refs: export the glob iterator 2013-05-21 16:51:50 +02:00
Li Xuanji
e069478edc define "long name" in git_reference_name_to_id 2013-05-21 21:35:58 +08:00
Russell Belfer
9be5be47fb More git_diff_find_similar improvements
- Add new GIT_DIFF_FIND_EXACT_MATCH_ONLY flag to do similarity
  matching without using the similarity metric (i.e. only compare
  the SHA).
- Clean up the similarity measurement code to more rigorously
  distinguish between files that are not similar and files that
  are not comparable (previously, a 0 could either mean that the
  files could not be compared or that they were totally different)
- When splitting a MODIFIED file into a DELETE/ADD pair, actually
  make a DELETED/UNTRACKED pair if the right side of the diff is
  from the working directory.  This prevents an odd mix of ADDED
  and UNTRACKED files on workdir diffs.
2013-05-20 13:37:21 -07:00
Russell Belfer
d958e37a48 Fix issues with git_diff_find_similar
There are a number of bugs in the rename code that only were
obvious when I started testing it against large old repos with
more complex patterns.  (The code to do that testing is not ready
to merge with libgit2, but I do plan to add more thorough tests.)

This contains a significant number of changes and also tweaks the
public API slightly to make emulating core git easier.

Most notably, this separates the GIT_DIFF_FIND_AND_BREAK_REWRITES
flag into FIND_REWRITES (which adds a self-similarity score to
every modified file) and BREAK_REWRITES (which splits the modified
deltas into add/remove pairs in the diff list).  When you do a raw
output of core git, rewrites show up as M090 or such, not at A and
D output, so I wanted to be able to emulate that.

Publicly, this also changes the flags to be uint16_t since we
don't need values out of that range.

Internally, this contains significant changes from a number of
small bug fixes (like using the wrong side of the diff to decide
if the object could be found in the ODB vs the workdir) to larger
issues about which files can and should be compared and how the
various edge cases of similarity scores should be treated.

Honestly, I don't think this is the last update that will have to
be made to this code, but I think this moves us closer to correct
behavior and I tried to document the code so it would be easier
to follow..
2013-05-17 17:21:45 -07:00
Russell Belfer
aadfa85b0a Add git_diff_print_raw printing helper
Makes it easier to emulate the --raw option
2013-05-17 16:41:15 -07:00
Russell Belfer
660d59caa9 Add git_oid_nfmt - a flexible OID formatter
I frequently want to the the first N digits of an OID formatted
as a string and I'd like it to be efficient.  This function makes
that easy and I could rewrite the OID formatters in terms of it.
2013-05-17 16:40:00 -07:00
Edward Thomson
0e0108f73f introduce git_conflict_iterator 2013-05-17 16:10:48 -05:00
Edward Thomson
9c06b25054 merge setup 2013-05-17 08:26:24 -05:00
nulltoken
e841c533d7 revparse: Introduce git_revparse_ext()
Expose a way to retrieve, along with the target git_object, the reference
pointed at by some revparse expression (`@{<-n>}` or
`<branchname>@{upstream}` syntax).
2013-05-16 21:43:24 +02:00
Vicent Martí
e3107e0ee1 Merge pull request #1558 from bmorganpa/ssh_transport
SSH Transport
2013-05-16 11:35:02 -07:00
Russell Belfer
58206c9ae7 Add cat-file example and increase const use in API
This adds an example implementation that emulates git cat-file.
It is a convenient and relatively simple example of getting data
out of a repository.

Implementing this also revealed that there are a number of APIs
that are still not using const pointers to objects that really
ought to be.  The main cause of this is that `git_vector_bsearch`
may need to call `git_vector_sort` before doing the search, so a
const pointer to the vector is not allowed.  However, for tree
objects, with a little care, we can ensure that the vector of
tree entries is always sorted and allow lookups to take a const
pointer.  Also, the missing const in commit objects just looks
like an oversight.
2013-05-16 10:38:27 -07:00
Russell Belfer
89251b283b Update index.h docs
Move the git_index_entry to the very top, since it provides the
main structure that needs to be understood by the reader, then
move the bitmasks for the flags and the flags_extended under that
since they are details for looking at particular fields of the
structure.
2013-05-15 16:25:11 -07:00
Russell Belfer
96c01991c1 Remove entry dup/free functions and fix comments
This removes the functions to duplicate and free copies of a
git_index_entry and updates the comments to explain that you
should just use the public definition of the struct as needed.
2013-05-15 16:13:04 -07:00
Russell Belfer
797dfb28fe Add APIs to dup and free git_index_entrys
This adds git_index_entry_dup to make a copy of an existing entry
and git_index_entry_free to release the memory of the copy.  It
also updates the documentation for git_index_get_bypath and
git_index_get_byindex to make it clear that the returned structure
should *not* be modified.
2013-05-15 16:11:31 -07:00
Russell Belfer
487884a930 Improve docs for git_index_entry flag masks
The constants for extracting data from git_index_entry flags and
flags_extended are not named in a way that makes it easy to know
where to use each one.  This improves the docs for the flags (and
slightly reorganizes them), so it should be more obvious.
2013-05-15 16:11:31 -07:00
Vicent Martí
7159620044 Merge pull request #1588 from arrbee/fixes-for-checkout-and-diff
Bug fixes for checkout and diff
2013-05-15 15:47:46 -07:00
Russell Belfer
dcb0f7c061 Fix checkout of submodules with no .gitmodules
It is possible for there to be a submodule in a repository with
no .gitmodules file (for example, if the user forgot to commit
the .gitmodules file).  In this case, core Git will just create
an empty directory as a placeholder for the submodule but
otherwise ignore it.  We were generating an error and stopping
the checkout.  This makes our behavior match that of core git.
2013-05-15 14:54:02 -07:00
nulltoken
1fed6b07f0 Fix trailing whitespaces 2013-05-15 22:41:30 +02:00
Linquize
0cb16fe924 Unify whitespaces to tabs 2013-05-15 20:26:55 +08:00
Edward Thomson
b6cc559a78 Merge pull request #1385 from carlosmn/refs-iter
Introduce a refs iterator
2013-05-11 02:42:49 -07:00
Carlos Martín Nieto
c58cac12c2 Introduce a glob-filtering iterator
If the backend doesn't provide support for it, the matching is done in
refdb on top of a normal iterator.
2013-05-11 11:20:38 +02:00
Carlos Martín Nieto
2b562c3a1e refs: remove the OID/SYMBOLIC filtering
Nobody should ever be using anything other than ALL at this level, so
remove the option altogether.

As part of this, git_reference_foreach_glob is now implemented in the
frontend using an iterator. Backends will later regain the ability of
doing the glob filtering in the backend.
2013-05-11 11:20:38 +02:00
Carlos Martín Nieto
4def7035ca refs: introduce an iterator
This allows us to get a list of reference names in a loop instead of callbacks.
2013-05-11 11:20:37 +02:00
Brad Morgan
89ea0e5181 Removed ifdef 2013-05-10 09:40:14 -04:00
Brad Morgan
b4d81a00bf Moved libssh2 sign callback into typedef 2013-05-09 17:40:21 -04:00
Russell Belfer
3d1c9f612d Fix git_repository_message docs
This clarifies the docs for git_repository_message and also adds
to the tests to explicitly check NUL termination of data when the
output buffer is smaller than the message size.  There is a minor
behavior change so that a non-NULL output buffer will always be
NUL terminated (at length zero) if an error occurs.
2013-05-09 06:45:06 -07:00
Vicent Martí
503dd0f3c4 Merge pull request #1560 from carlosmn/ref-dwim
Expose git_reference_dwim
2013-05-09 05:43:25 -07:00
Vicent Martí
af795759a7 Merge pull request #1552 from carlosmn/config-helpers
Config helpers for global/xdg config files
2013-05-07 15:09:11 -07:00
Carlos Martín Nieto
98d633cccf Expose git_reference_dwim
Extract this function out of the rev-parse code to be able to DWIM a
reference instead of its target.
2013-05-07 23:34:48 +02:00
Carlos Martín Nieto
5d8318875f config: convenience function to open global/xdg
The rules for which one to open is a bit silly, so let's make it
easier for our users.
2013-05-07 21:42:56 +02:00
Brad Morgan
4ca3d6d28f Added ifdef 2013-05-07 14:37:15 -04:00
Brad Morgan
00e43380a0 Merge remote-tracking branch 'origin/development' into ssh_transport 2013-05-07 14:30:35 -04:00
Brad Morgan
574b86b722 Fixed compilation issues when libssh2 is missing 2013-05-07 13:56:34 -04:00
Brad Morgan
c36565c0ee Added SSH public key authentication 2013-05-07 13:45:31 -04:00
Vicent Martí
33665410d6 Merge pull request #1556 from arrbee/diff-patch-fixes
Diff patch bug fixes
2013-05-07 08:00:44 -07:00