Commit Graph

5254 Commits

Author SHA1 Message Date
Russell Belfer
9f1b2c5cb7 Merge pull request #1668 from csware/WC_ERR_INVALID_CHARS
Do not redefine WC_ERR_INVALID_CHARS
2013-06-22 17:22:03 -07:00
Russell Belfer
8294e8cfff Constrain mkdir calls to avoid extra mkdirs
This updates the calls that make the subdirectories for objects
to use a base directory above which git_futils_mkdir won't walk
any higher.  This prevents attempts to mkdir all the way up to
the root of the filesystem.

Also, this moves the objects_dir into the loose backend structure
and removes the separate allocation, plus does some preformatting
of the objects_dir value to guarantee a trailing slash, etc.
2013-06-22 17:15:31 -07:00
Sven Strickroth
a7ea40955e Do not redefine WC_ERR_INVALID_CHARS
WC_ERR_INVALID_CHARS might be already defined by the Windows SDK.

Signed-off-by: Sven Strickroth <email@cs-ware.de>
2013-06-23 01:25:34 +02:00
Vicent Martí
5d669f0a96 Merge pull request #1665 from arrbee/checkout-target-directory
Add target directory to checkout options
2013-06-21 14:29:21 -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
6a15e8d23a Loosen ensure_not_bare rules in checkout
With the new target directory option to checkout, the non-bareness
of the repository should be checked much later in the parameter
validation process - actually that check was already in place, but
I was doing it redundantly in the checkout APIs.

This removes the now unnecessary early check for bare repos.  It
also adds some other parameter validation and makes it so that
implied parameters can actually be passed as NULL (i.e. if you
pass a git_index, you don't have to pass the git_repository - we
can get it from index).
2013-06-21 12:26:36 -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
Vicent Martí
00197c34d6 Merge pull request #1664 from arrbee/checkout-deleted-with-fix
Checkout should not recreate deleted files - with fix
2013-06-21 11:41:40 -07:00
Russell Belfer
36fd9e3065 Fix checkout of modified file when missing from wd
This fixes the checkout case when a file is modified between the
baseline and the target and yet missing in the working directory.
The logic for that case appears to have been wrong.

This also adds a useful checkout notify callback to the checkout
test helpers that will count notifications and also has a debug
mode to visualize what checkout thinks that it's doing.
2013-06-21 11:20:54 -07:00
Edward Thomson
dacce80b12 test asserting checkout should not recreate deleted files 2013-06-20 19:08:58 -05:00
Vicent Martí
f2d110f168 Merge pull request #1662 from arrbee/examples-like-git
Command line status example (with bug fixes)
2013-06-20 15:27:25 -07:00
Russell Belfer
94ef2a353c Add test for fixed diff bug
Add test for bug fixed in 852ded9698
Sorry, I wrote that bug fix and forgot to check in a test at the
same time.  Here is one that fails on the old version of the code
and now works.
2013-06-20 15:15:10 -07:00
Russell Belfer
9280855787 Fix comment and copyright in example 2013-06-20 15:10:42 -07:00
Russell Belfer
f18f772a8e Add example implementation of long format status 2013-06-20 14:27:14 -07:00
Russell Belfer
22b6b82f2c Add status flags to force output sort order
Files in status will, be default, be sorted according to the case
insensitivity of the filesystem that we're running on.  However,
in some cases, this is not desirable.  Even on case insensitive
file systems, 'git status' at the command line will generally use
a case sensitive sort (like 'ls').  Some GUIs prefer to display a
list of file case insensitively even on case-sensitive platforms.

This adds two new flags: GIT_STATUS_OPT_SORT_CASE_SENSITIVELY
and GIT_STATUS_OPT_SORT_CASE_INSENSITIVELY that will override the
default sort order of the status output and give the user control.
This includes tests for exercising these new options and makes
the examples/status.c program emulate core Git and always use a
case sensitive sort.
2013-06-20 12:16:06 -07:00
Russell Belfer
cf300bb9e5 Initial implementation of status example 2013-06-20 11:39:31 -07:00
Russell Belfer
852ded9698 Fix bug in diff untracked dir scan
When scanning untracked directories looking for non-ignored files
there was a bug where an empty directory would generate a false
error.
2013-06-20 11:37:58 -07:00
Vicent Martí
8b2fa181b2 Merge pull request #1661 from arrbee/index-add-all
Index operations using globs
2013-06-19 16:18:30 -07:00
Russell Belfer
7863523a1b Add tests and fix use of freed memory
This adds some tests for updating the index and having it remove
items to make sure that the iteration over the index still works
even as earlier items are removed.

In testing with valgrind, this found a path that would use the
path string from the index entry after it had been freed.  The
bug fix is simply to copy the path of the index entry before
doing any actual index manipulation.
2013-06-19 15:54:19 -07:00
Russell Belfer
f30fff45a7 Add index pathspec-based operations
This adds three new public APIs for manipulating the index:

1. `git_index_add_all` is similar to `git add -A` and will add
   files in the working directory that match a pathspec to the
   index while honoring ignores, etc.
2. `git_index_remove_all` removes files from the index that match
   a pathspec.
3. `git_index_update_all` updates entries in the index based on
   the current contents of the working directory, either added
   the new information or removing the entry from the index.
2013-06-19 15:27:25 -07:00
Russell Belfer
85b8b18b6a Add fn to check pathspec for ignored files
Command line Git sometimes generates an error message if given a
pathspec that contains an exact match to an ignored file (provided
--force isn't also given).  This adds an internal function that
makes it easy to check it that has happened.  Right now, I'm not
creating a public API for this because that would get a little
more complicated with a need for callbacks for all invalid paths.
2013-06-19 15:22:48 -07:00
Russell Belfer
e91f9a8f28 Add higher level pathspec API
Right now, setting up a pathspec to be parsed and processed
requires several data structures and a couple of API calls.  This
adds a new high level data structure that contains all the items
that you'll need and high-level APIs that do all of the setup and
all of the teardown.  This will make it easier to use pathspecs
in various places with less repeated code.
2013-06-19 15:20:59 -07:00
Vicent Martí
5144850cb7 Merge pull request #1660 from trast/tr/fix-zlib-configuration
CMakeLists: fix zlib linker setup
2013-06-19 06:42:22 -07:00
Thomas Rast
c41281ad3a CMakeLists: fix zlib linker setup
b53671a (Search for zlib unconditional, 2012-12-18) changed things
around to always (even on windows, that's what the subject refers to)
call FIND_PACKAGE(ZLIB).

However, it did not correctly handle the case where ZLIB_LIBRARY is
cached, either by the user setting it manually or by an earlier
search.  In that case, the IF(ZLIB_FOUND) would not trigger (that
variable is not cached) and we'd instead use the built-in version.

000e689 (CMake: don't try to use bundled zlib when the system's path
is in the cache, 2013-05-12) tried to fix that, but it actually made
the problem worse: now with ZLIB_LIBRARY cached, _neither_ of the
blocks would execute, resulting in a linker error for me when trying
to build such a doubly-configured setup.

To fix the issue, we just trust CMake to do the right thing.  If
ZLIB_LIBRARY is set (either from user or cache) then the find_library
in FindZLIB.cmake will use that instead of searching again.  So we can
unconditionally (for real this time) call FIND_PACKAGE(ZLIB), and just
check its result.
2013-06-19 14:02:11 +02:00
Vicent Martí
84ba4944bc Merge pull request #1659 from arrbee/rename-cycle-fixes
Diff rename detection cycle fixes
2013-06-18 16:42:35 -07:00
Russell Belfer
e4acc3ba19 Fix rename looped reference issues
This makes the diff rename tracking code more careful about the
order in which it processes renames and more thorough in updating
the mapping of correct renames when an earlier rename update
alters the index of a later matched pair.
2013-06-18 16:14:35 -07:00
Edward Thomson
3b334075c9 test illustrating tri-cyclic rename failure 2013-06-18 09:39:10 -07:00
Edward Thomson
f0f2ff9cac test failure when renames produce similar similarities 2013-06-18 09:39:10 -07:00
Vicent Martí
ffb762fed9 Merge pull request #1657 from arrbee/diff-blob-as-path
Add "as_path" parameters to blob and buffer diff APIs
2013-06-18 04:30:25 -07:00
Russell Belfer
74ded02457 Add "as_path" parameters to blob and buffer diffs
This adds parameters to the four functions that allow for blob-to-
blob and blob-to-buffer differencing (either via callbacks or by
making a git_diff_patch object).  These parameters let you say
that filename we should pretend the blob has while doing the diff.
If you pass NULL, there should be no change from the existing
behavior, which is to skip using attributes for file type checks
and just look at content.  With the parameters, you can plug into
the new diff driver functionality and get binary or non-binary
behavior, plus function context regular expressions, etc.

This commit also fixes things so that the git_diff_delta that is
generated by these functions will actually be populated with the
data that we know about the blobs (or buffers) so you can use it
appropriately.  It also fixes a bug in generating patches from
the git_diff_patch objects created via these functions.

Lastly, there is one other behavior change that may matter.  If
there is no difference between the two blobs, these functions no
longer generate any diff callbacks / patches unless you have
passed in GIT_DIFF_INCLUDE_UNMODIFIED.  This is pretty natural,
but could potentially change the behavior of existing usage.
2013-06-17 17:03:34 -07:00
Russell Belfer
c09810eedf Merge pull request #1651 from arrbee/status_indexed_updates
Status indexed updates
2013-06-17 10:46:15 -07:00
Russell Belfer
f418334760 Update clar to latest version 2013-06-17 10:23:53 -07:00
Russell Belfer
de0555a347 Fix memory leaks in diff rename tests
This fixes a couple objects I forgot to free, and also updates
the valgrind suppressions file on the Mac to cover a few more
cases that had crept in.
2013-06-17 10:03:50 -07:00
Russell Belfer
f3b5bc835a Add test of rename with no changes
A tree to index rename with no changes was getting erased by
the iteration routine (if the routine actually loaded the data
for the unmodified file).  This invokes the code path that was
previously messing up the diff and iterates twice to make sure
that the iteration process itself doesn't modify the data.
2013-06-17 10:03:50 -07:00
Russell Belfer
a1683f28ce More tests and bug fixes for status with rename
This changes the behavior of the status RENAMED flags so that they
will be combined with the MODIFIED flags if appropriate.  If a file
is modified in the index and also renamed, then the status code
will have both the GIT_STATUS_INDEX_MODIFIED and INDEX_RENAMED bits
set.  If it is renamed but the OID has not changed, then just the
GIT_STATUS_INDEX_RENAMED bit will be set.  Similarly, the flags
GIT_STATUS_WT_MODIFIED and GIT_STATUS_WT_RENAMED can both be set
independently of one another.

This fixes a serious bug where the check for unmodified files that
was done at data load time could end up erasing the RENAMED state
of a file that was renamed with no changes.

Lastly, this contains a bunch of new tests for status with renames,
including tests where the only rename changes are case changes.
The expected results of these tests have to vary by whether the
platform uses a case sensitive filesystem or not, so the expected
data covers those platform differences separately.
2013-06-17 10:03:49 -07:00
Russell Belfer
fb03a22318 Test has to work on case sensitive systems 2013-06-17 10:03:49 -07:00
Russell Belfer
eefef642c8 Always do tree to index diffs case sensitively
Trees are always case sensitive.  The index is always case
preserving and will be case sensitive when it is turned into a
tree.  Therefore the tree and the index can and should always
be compared to one another case sensitively.

This will restore the index to case insensitive order after the
diff has been generated.

Consider this a short-term fix.  The long term fix is to have the
index always stored both case sensitively and case insensitively
(at least on platforms that sometimes require case insensitivity).
2013-06-17 10:03:49 -07:00
Russell Belfer
6ea999bb88 Make index_insert keep existing case
In a case insensitive index, if you attempt to add a file from
disk with a different case pattern, the old case pattern in the
index should be preserved.

This fixes that (and a couple of minor warnings).
2013-06-17 10:03:49 -07:00
Edward Thomson
1540b19990 some simple case-sensitive index tests 2013-06-17 10:03:49 -07:00
Russell Belfer
351888cf3d Improve case handling in git_diff__paired_foreach
This commit reinstates some changes to git_diff__paired_foreach
that were discarded during the rebase (because the diff_output.c
file had gone away), and also adjusts the case insensitively
logic slightly to hopefully deal with either mismatched icase
diffs and other case insensitivity scenarios.
2013-06-17 10:03:49 -07:00
Russell Belfer
a3e8dbb40b Be more careful about the path with diffs
This makes diff more careful about picking the canonical path
when generating a delta so that it won't accidentally pick up a
case-mismatched path on a case-insensitive file system.  This
should make sure we use the "most accurate" case correct version
of the path (i.e. from the tree if possible, or the index if
need be).
2013-06-17 10:03:49 -07:00
Russell Belfer
3a68d7f002 Fix broken status EXCLUDE_SUBMODULES logic
The exclude submodules flag was not doing the right thing, in
that a file with no diff between the head and the index and just
a delete in the workdir could be excluded if submodules were
excluded.
2013-06-17 10:03:49 -07:00
Russell Belfer
4e28e638ea Clarify some docs and minor reordering
This simplifies some documentation and hopefully makes a couple
of things easier to read.  Also, this rearrages the order in this
branch so that the overall diff against the trunk will hopefully
be a bit cleaner.
2013-06-17 10:03:48 -07:00
Russell Belfer
c9b18018fd Fix some warnings 2013-06-17 10:03:48 -07:00
Edward Thomson
e3b4a47c1e git__strcasesort_cmp: strcasecmp sorting rules but requires strict equality 2013-06-17 10:03:15 -07:00
Edward Thomson
dfe8c8df37 handle renames in status computation 2013-06-17 10:03:15 -07:00
Edward Thomson
1ee2ef87ec status access by index, providing more details to callers 2013-06-17 10:03:14 -07:00
Vicent Marti
09c2f91c15 branch: More obvious semantics in foreach 2013-06-17 18:48:02 +02:00
Vicent Martí
bd2319c839 Merge pull request #1655 from yorah/fix/ref-memleak
ref: free the last ref when cancelling git_branch_foreach()
2013-06-17 09:38:04 -07:00
yorah
2ad7a4dc92 ref: free the last ref when cancelling git_branch_foreach()
Also fixed an assert typo on nulltoken's HEAD
2013-06-17 18:29:05 +02:00