Commit Graph

4856 Commits

Author SHA1 Message Date
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
Vicent Martí
87a56fe015 Merge pull request #1604 from arrbee/config-file-checks
Extend checking for config with no files
2013-05-24 00:44:50 -07:00
Ben Straub
6f0b8142e6 Stop leaking memory 2013-05-23 17:28:52 -07:00
Russell Belfer
0700ca1a74 More config code checks and cleanups 2013-05-23 16:11:53 -07:00
Russell Belfer
3b32b6d3cc More tests of config with various absent files
Plus a bit of extra paranoia to ensure config object has valid
contents.
2013-05-23 15:57:52 -07:00
Russell Belfer
49f70f2c37 Fill out diff rename test coverage
This extends the rename tests to make sure that every rename
scenario in the inner loop of git_diff_find_similar is actually
exercised.  Also, fixes an incorrect assert that was in one of
the clauses that was not previously being exercised.
2013-05-23 15:48:06 -07:00
Ben Straub
93d8f77fed Improve test failure output 2013-05-23 15:35:50 -07:00
Russell Belfer
f38cea97c3 Move core.abbrev lookup out of diff print loop
This moves the GIT_CVAR_ABBREV lookup out of the loop.  Also, this
fixes git_diff_print_raw to actually use that constant instead of
hardcoding 7 characters.
2013-05-23 15:21:43 -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
c68b09dc7a Fix dereference of freed delta
I was accidentally using a value that I had just freed.  This
moves the clearing of the delta internal flags into a better place.
2013-05-23 11:52:34 -07:00
Ben Straub
9c941ccfaf Merge pull request #1599 from nulltoken/topic/windows_resources
Update windows resources to match the dll name
2013-05-23 08:52:24 -07:00
Ben Straub
c4085fbf1d Merge pull request #1601 from Merovius/bugfix_shorten
Bugfix: Return NULL in push_leaf, when trie is full
2013-05-23 07:31:05 -07:00
Axel Wagner
06c070b5bb Add testcase for #1600 2013-05-23 09:43:56 +02: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
Axel Wagner
52f537e9c5 Bugfix: Return NULL in push_leaf, when trie is full
os->full was set 1, but the overflowed idx_leaf was still used to index
into os->nodes a little later. Returning NULL fixes that.
2013-05-22 02:04:12 +02:00
nulltoken
095bfd7487 cmake: Update Windows resources to reflect the optional vendor string
Make InternalName and OriginalFilename resources reflect the name of the compiled binary.
2013-05-22 00:15:13 +02:00
nulltoken
ccf1a2ba5f cmake: Fix indentation 2013-05-22 00:15:12 +02: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
Edward Thomson
60750fc43e Merge pull request #1596 from grimreaper/development
Initialize loose_deleted before it is used for a check later on.
2013-05-20 13:53:00 -07:00
Russell Belfer
4742148d54 Add more diff rename detection tests
This adds a bunch more rename detection tests including checks
vs the working directory, the new exact match options, some more
whitespace variants, etc.

This also adds a git_futils_writebuffer helper function and uses
it in checkout.  This is mainly added because I wanted an easy
way to write out a git_buf to disk inside my test code.
2013-05-20 13:41:39 -07: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
Eitan Adler
038c1654d9 Initialize loose_deleted before it is used for a check later on. 2013-05-19 01:41:18 -04: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
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
0293450e21 Fix delta compare to use correct pathname
The delta cmp function needs to choose the correct path for
ordering when a delta is ADDED, RENAMED, or COPIED.
2013-05-17 16:57:49 -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
9c06b25054 merge setup 2013-05-17 08:26:24 -05:00
Russell Belfer
5b3d52ce37 Merge pull request #1568 from nulltoken/topic/revparse_ext
Introduce git_revparse_ext()
2013-05-16 13:13:28 -07:00
nulltoken
f672cd2a09 revparse: Make revparse_ext() return git_reference from names as well 2013-05-16 21:43:31 +02: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
nulltoken
dcaa898d82 revparse: Simplify temporary reference freeing 2013-05-16 21:20:08 +02:00
Vicent Martí
e3107e0ee1 Merge pull request #1558 from bmorganpa/ssh_transport
SSH Transport
2013-05-16 11:35:02 -07:00
Vicent Martí
c2d282cfd8 Merge pull request #1590 from arrbee/examples-like-git
Add cat-file to examples (with some public API improvements)
2013-05-16 11:10:42 -07:00
Vicent Martí
18e37db935 Merge pull request #1591 from arrbee/reorder-reuc-read-for-safety
Ensure reuc vector is always valid
2013-05-16 11:10:13 -07:00
Russell Belfer
57908bb3a3 Ensure reuc vector is always valid
In theory, if there was a problem reading the REUC data, the
read_reuc() routine could have left uninitialized and invalid
data in the git_index vector.  This moves the line that inserts a
new entry into the vector down to the bottom of the routine so we
know all the content is already valid.  Also, per @linquize, this
uses calloc to ensure no uninitialized data.
2013-05-16 11:03:55 -07:00
Russell Belfer
4a782c82ef Merge pull request #1574 from linquize/calloc
Use calloc() for safety
2013-05-16 11:02:30 -07:00
Russell Belfer
8d78400142 Make examples/diff.c compile vs threadsafe library 2013-05-16 10:43:10 -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
Linquize
7026ad893b calloc() to initialize memory 2013-05-16 21:11:38 +08:00
Vicent Martí
12f831fa15 Merge pull request #1586 from jamill/fetch_fix
Fetch should not fail when remote HEAD reference is not present locally
2013-05-16 04:41:05 -07:00
Vicent Martí
54e489c21e Merge pull request #1579 from arrbee/index-entry-dup-and-free
Index entry dup and free
2013-05-15 16:35:47 -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