Commit Graph

35 Commits

Author SHA1 Message Date
Russell Belfer
c97d407d9c Fix tests of file modes
This fixes an issue checking file modes in the tests that
initialize a repo from a template directory when a symlink is
used in the template.  Also, this updates some other places where
we are examining file modes to use the new macros.
2013-09-05 11:45:29 -07:00
Russell Belfer
27061b151a Fix some newer GCC compiler warnings 2013-09-05 10:25:16 -07:00
Russell Belfer
780f3e540f Make tests take umask into account
It seems that libgit2 is correctly applying the umask when
initializing a repository from a template and when creating new
directories during checkout, but the test suite is not accounting
for possible variations due to the umask.  This updates that so
that the test suite will work regardless of the umask.
2013-09-04 16:23:00 -07:00
nulltoken
d90390c162 test: Fix memory leak 2013-06-29 13:38:27 +02:00
Russell Belfer
f3f4c6b5be Fix checkout tests on Windows 2013-06-24 11:56:35 -07:00
Russell Belfer
d4f98ba4f1 Addition checkout target directory tests
This adds additonal tests of the checkout target directory option
including using it to dump data from bare repos.
2013-06-21 12:29:03 -07:00
Russell Belfer
9094ae5a3c Add target directory to checkout
This adds the ability for checkout to write to a target directory
instead of having to use the working directory of the repository.
This makes it easier to do exports of repository data and the like.

This is similar to, but not quite the same as, the --prefix option
to `git checkout-index` (this will always be treated as a directory
name, not just as a simple text prefix).

As part of this, the workdir iterator was extended to take the
path to the working directory as a parameter and fallback on the
git_repository_workdir result only if it's not specified.

Fixes #1332
2013-06-21 11:55:13 -07:00
Russell Belfer
114f5a6c41 Reorganize diff and add basic diff driver
This is a significant reorganization of the diff code to break it
into a set of more clearly distinct files and to document the new
organization.  Hopefully this will make the diff code easier to
understand and to extend.

This adds a new `git_diff_driver` object that looks of diff driver
information from the attributes and the config so that things like
function content in diff headers can be provided.  The full driver
spec is not implemented in the commit - this is focused on the
reorganization of the code and putting the driver hooks in place.

This also removes a few #includes from src/repository.h that were
overbroad, but as a result required extra #includes in a variety
of places since including src/repository.h no longer results in
pulling in the whole world.
2013-06-10 10:10:39 -07:00
Russell Belfer
050ab9950d Fix up checkout file contents checks
This fixes of the file contents checks in checkout to give
slightly better error messages by directly calling the underlying
clar assertions so the file and line number of the top level call
can be reported correctly, and renames the helpers to not start
with "test_" since that is kind of reserved by clar.

This also enables some of the CRLF tests on all platforms that
were previously Windows only (by pushing a check of the native
line endings into the test body).
2013-03-25 14:13:53 -07:00
Russell Belfer
1098cfaeca Test fixes and cleanup
This fixes some places where the new tests were leaving the test
area in a bad state or were freeing data they should not free.
It also removes code that is extraneous to the core issue and
fixes an invalid SHA being looked up in one of the tests (which
was failing, but for the wrong reason).
2013-03-25 14:03:16 -07:00
Sven Strickroth
b8acb775e2 Added some tests for issue #1397
Signed-off-by: Sven Strickroth <email@cs-ware.de>
2013-03-25 14:03:16 -07:00
Russell Belfer
1323c6d180 Add cl_repo_set_bool and cleanup tests
This adds a helper function for the cases where you want to
quickly set a single boolean config value for a repository.
This allowed me to remove a lot of code.
2013-03-22 14:27:56 -07:00
Vicent Martí
ddcb28a41f Merge pull request #1239 from ethomson/index_remove
add an index_remove_bypath that removes conflicts
2013-01-17 16:56:57 -08:00
nulltoken
2a3b3e0324 checkout: Teach checkout to cope with orphaned Head
Fix #1236
2013-01-13 10:25:54 +01:00
Edward Thomson
25743bd7c5 add an index_remove_bypath that removes conflicts, renamed add_from_workdir to match 2013-01-12 13:47:56 -06:00
Russell Belfer
2f0895393d Actually fix win32 checkout test
It turns out that using REMOVE_UNTRACKED with checkout for this
particular test was causing the .gitattributes file to be removed
and so we do have to allow for the CRs in the created file...
2013-01-04 17:17:37 -08:00
Russell Belfer
bebdbcd442 Fix crlf issue with checkout tests
Move some checkout utility functions into a shared file and fix
some crlf filtering issues when verifying file contents.
2013-01-04 16:56:21 -08:00
Russell Belfer
817d625161 Fix checkout of index-only dirs and prefixed paths
There are a couple of checkout bugs fixed here.  One is with
untracked working directory entries that are prefixes of tree
entries but not in a meaningful way (i.e. "read" is a prefix of
"readme.txt" but doesn't interfere in any way).  The second bug
is actually a redo of 07edfa0fc640f85f95507c3101e77accd7d2bf0d
where directory entries in the index that are not in the diff
were not being removed correctly.  That fix remedied one case
but broke another.
2013-01-04 15:47:44 -08:00
Russell Belfer
7e5c8a5b41 More checkout improvements
This flips checkout back to be driven off the changes between
the baseline and the target trees.  This reinstates the complex
code for tracking the contents of the working directory, but
overall, I think the resulting logic is easier to follow.
2013-01-04 15:47:42 -08:00
Russell Belfer
cf20803170 Rework checkout internals (again)
I've tried to map out the detailed behaviors of checkout and make
sure that we're handling the various cases correctly, along with
providing options to allow us to emulate "git checkout" and "git
checkout-index" with the various flags.  I've thrown away flags
in the checkout API that seemed like clutter and added some new
ones.  Also, I've converted the conflict callback to a general
notification callback so we can emulate "git checkout" output and
display "dirty" files.

As of this commit, the new behavior is not working 100% but some
of that is probably baked into tests that are not testing the
right thing.  This is a decent snapshot point, I think, along the
way to getting the update done.
2013-01-04 15:47:42 -08:00
Ben Straub
0ab3a2ab2c Deploy GIT_INIT_STRUCTURE 2012-11-30 20:34:50 -08:00
Ben Straub
b81aa2f1de Deploy GIT_CHECKOUT_OPTS_INIT 2012-11-30 13:12:14 -08:00
Ben Straub
2508cc66eb Rename ref and reflog apis for consistency 2012-11-27 13:17:45 -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
ad9a921b92 Rework checkout with new strategy options
This is a major reworking of checkout strategy options.  The
checkout code is now sensitive to the contents of the HEAD tree
and the new options allow you to update the working tree so that
it will match the index content only when it previously matched
the contents of the HEAD.  This allows you to, for example, to
distinguish between removing files that are in the HEAD but not
in the index, vs just removing all untracked files.

Because of various corner cases that arise, etc., this required
some additional capabilities in rmdir and other utility functions.

This includes the beginnings of an implementation of code to read
a partial tree into the index based on a pathspec, but that is
not enabled because of the possibility of creating conflicting
index entries.
2012-11-09 13:52:07 -08:00
Russell Belfer
32def5af9a Fix checkout behavior when its hands are tied
So, @nulltoken created a failing test case for checkout that
proved to be particularly daunting.  If checkout is given only
a very limited strategy mask (e.g. just GIT_CHECKOUT_CREATE_MISSING)
then it is possible for typechange/rename modifications to leave it
unable to complete the request.  That's okay, but the existing code
did not have enough information not to generate an error (at least
for tree/blob conflicts).

This led me to a significant reorganization of the code to handle
the failing case, but it has three benefits:

1. The test case is handled correctly (I think)
2. The new code should actually be much faster than the old code
   since I decided to make checkout aware of diff list internals.
3. The progress value accuracy is hugely increased since I added
   a fourth pass which calculates exactly what work needs to be
   done before doing anything.
2012-11-09 13:52:06 -08:00
Ben Straub
1fc375e6ef Fix Windows build
Pedantic ordering of GIT_UNUSED vs. variable declarations.
2012-10-25 09:02:55 -07:00
Ben Straub
9c05c17b7a Checkout progress now reports completed/total steps 2012-10-19 20:05:18 -07:00
Ben Straub
25e8b20169 Fix broken tests 2012-10-19 19:36:23 -07:00
nulltoken
0ae81fc479 index: remove read_tree() progress indicator
git_index_read_tree() was exposing a parameter to provide the user with
a progress indicator. Unfortunately, due to the recursive nature of the
tree walk, the maximum number of items to process was unknown. Thus,
the indicator was only counting processed entries, without providing
any information how the number of remaining items.
2012-10-19 19:36:22 -07:00
Ben Straub
2c8bbb27d9 Convert checkout_index to use progress callback 2012-10-19 19:34:15 -07:00
nulltoken
9e592583fc checkout: add notification callback for skipped files 2012-09-21 08:08:29 +02:00
nulltoken
397837197d checkout: Mimic git_diff_options storage of paths 2012-09-17 20:27:28 +02:00
nulltoken
c214fa1caf checkout: segregate checkout strategies 2012-09-17 10:48:30 +02:00
nulltoken
020cda99c2 checkout: separate tree from index related tests 2012-09-17 10:48:29 +02:00