Commit Graph

89 Commits

Author SHA1 Message Date
Pirate Praveen
c25aa7cd82 New upstream version 1.3.0+dfsg.1 2021-12-10 16:42:08 +05:30
Utkarsh Gupta
22a2d3d5ef New upstream version 1.1.0+dfsg.1 2020-12-07 04:06:37 +05:30
Jongmin Kim
ac3d33df5d New upstream version 0.28.1+dfsg.1 2019-05-12 00:29:21 +09:00
David Catmull
19874e2934 Minor comment fix 2017-02-16 08:40:49 -07:00
David Turner
5625d86b99 index: support index v4
Support reading and writing index v4.  Index v4 uses a very simple
compression scheme for pathnames, but is otherwise similar to index v3.

Signed-off-by: David Turner <dturner@twitter.com>
2016-08-10 14:19:30 -04:00
Edward Thomson
21515f228b index: also try conflict mode when inserting
When we do not trust the on-disk mode, we use the mode of an existing
index entry.  This allows us to preserve executable bits on platforms
that do not honor them on the filesystem.

If there is no stage 0 index entry, also look at conflicts to attempt
to answer this question:  prefer the data from the 'ours' side, then
the 'theirs' side before falling back to the common ancestor.
2015-09-30 09:06:09 -04:00
Leo Yang
c097f7173d New API: git_index_find_prefix
Find the first index entry matching a prefix.
2015-09-04 12:24:36 -04:00
Carlos Martín Nieto
5e947c91d4 index: use the checksum to check whether it's been modified
We currently use a timetamp to check whether an index file has been
modified since we last read it, but this is racy. If two updates happen
in the same second and we read after the first one, we won't detect the
second one.

Instead read the SHA-1 checksum of the file, which are its last 20 bytes which
gives us a sure-fire way to detect whether the file has changed since we
last read it.

As we're now keeping track of it, expose an accessor to this data.
2015-06-19 22:05:08 +02:00
Edward Thomson
9f545b9d71 introduce git_index_entry_is_conflict
It's not always obvious the mapping between stage level and
conflict-ness.  More importantly, this can lead otherwise sane
people to write constructs like `if (!git_index_entry_stage(entry))`,
which (while technically correct) is unreadable.

Provide a nice method to help avoid such messy thinking.
2015-05-28 09:47:31 -04:00
Edward Thomson
ecd60a56eb conflicts: when adding conflicts, remove staged
When adding a conflict for some path, remove the staged entry.
Otherwise, an illegal index (with both stage 0 and high-stage
entries) would result.
2015-05-28 09:43:49 -04:00
Carlos Martín Nieto
ca29427979 index: make the entries have more accurate sizes
While we are confident about the size of an int in architectures we're
likely to care about, the index format is defined by the exact size of
the fields. Use the definitions which show the exact width of the entry
fields.

As part of that, bring back 32-bit time and size fields, which currently
are 64 bits wide and can bring a false sense of security in how much
data they really store. Document that these fields are not to be taken
as authoritative.
2015-05-12 11:43:27 +02:00
Pierre-Olivier Latour
807566d554 Entry argument passed to git_index_add_frombuffer() should be const 2015-04-03 18:59:11 -07:00
Damien PROFETA
a275fbc0f7 Add API to add a memory buffer to an index
git_index_add_frombuffer enables now to store a memory buffer in the odb
and to store an entry in the index directly if the index is attached to a
repository.
2015-02-25 10:24:13 +01:00
Carlos Martín Nieto
a295bd2dc4 doc: add documentation to all the public structs and enums
This makes them show up in the reference, even if the text itself isn't
the most descriptive.

These have been found with

    grep -Przon '\n\ntypedef struct.*?\{' -- include
    grep -Przon '\n\ntypedef enum.*?\{' -- include
2014-12-06 03:44:40 +01:00
Carlos Martín Nieto
dedfc7346b index: split GIT_IDXENTRY into two flag enums
The documentation has shown this as a single enum for a long time. These
should in fact be two enums. One with the bits for the flags and another
with the bits for the extended flags.
2014-06-03 16:05:36 +02:00
Carlos Martín Nieto
11e2665e50 Formatting fixes for the docs
These are some issues I found while playing around with the new parser
for docurium.
2014-06-03 16:05:35 +02:00
Russell Belfer
0fc8e1f6bd Lay groundwork for updating stat cache in diff
This reorganized the diff OID calculation to make it easier to
correctly update the stat cache during a diff once the flags to
do so are enabled.

This includes marking the path of a git_index_entry as const so
we can make a "fake" git_index_entry with a "const char *" path
and not get warnings.  I was a little surprised at how unobtrusive
this change was, but I think it's probably a good thing.
2014-05-02 09:21:33 -07:00
Russell Belfer
aba6b5edbd Fix leak in git_index_conflict_cleanup
I introduced a leak into conflict cleanup by removing items from
inside the git_vector_remove_matching call.  This simplifies the
code to just use one common way for the two conflict cleanup APIs.

When an index has an active snapshot, removing an item can cause
an error (inserting into the deferred deletion vector), so I made
the git_index_conflict_cleanup API return an error code.  I felt
like this wasn't so bad since it is just like the other APIs.

I fixed up a couple of comments while I was changing the header.
2014-04-17 14:43:46 -07:00
Russell Belfer
3dbee45656 Some index internals refactoring
Again, laying groundwork for some index iterator changes, this
contains a bunch of code refactorings for index internals that
should make it easier down the line to add locking around index
modifications.  Also this removes the redundant prefix_position
function and fixes some potential memory leaks.
2014-04-17 14:43:45 -07:00
Jacques Germishuys
3b4ba27870 Const correctness! 2014-04-03 16:06:31 +02:00
Rob Rix
ddc66e27b6 Give the correct name for the function in the doc.
Per @carlosmn, git_index_add is now named git_index_add_bypath.
2014-04-02 08:02:43 -04:00
Rob Rix
bb439de039 Correct a stale reference to GIT_EBAREINDEX 2014-04-01 16:37:19 -04:00
Russell Belfer
72556cc63b Address PR comments
* Make GIT_INLINE an internal definition so it cannot be used in
  public headers
* Fix language in CONTRIBUTING
* Make index caps API use signed instead of unsigned values
2014-02-20 14:27:10 -08:00
Carlos Martín Nieto
d541170c77 index: rename an entry's id to 'id'
This was not converted when we converted the rest, so do it now.
2014-01-25 08:15:44 +01:00
Russell Belfer
373cf6a932 Update docs for new callback return value behavior 2013-12-11 10:57:50 -08:00
Russell Belfer
8e5a8ef86f Convert git_index_read to have a "force" flag
This is a little more intuitive than the turned-around option that
I originally wrote.
2013-11-01 10:20:51 -07:00
Russell Belfer
4bf630b6ba Make diff and status perform soft index reload
This changes `git_index_read` to have two modes - a hard index
reload that always resets the index to match the on-disk data
(which was the old behavior) and a soft index reload that uses
the timestamp / file size information and only replaces the index
data if the file on disk has been modified.

This then updates the git_status code to do a soft reload unless
the new GIT_STATUS_OPT_NO_REFRESH flag is passed in.

This also changes the behavior of the git_diff functions that use
the index so that when an index is not explicitly passed in (i.e.
when the functions call git_repository_index for you), they will
also do a soft reload for you.

This intentionally breaks the file signature of git_index_read
because there has been some confusion about the behavior previously
and it seems like all existing uses of the API should probably be
examined to select the desired behavior.
2013-11-01 10:20:51 -07:00
nulltoken
6445ae994c index: Enhance documentation 2013-10-04 13:49:26 +02:00
Russell Belfer
1ca3e49f88 Clean up newly introduced warnings
The attempt to "clean up warnings" seems to have introduced some
new warnings on compliant compilers.  This fixes those in a way
that I suspect will also be okay for the non-compliant compilers.

Also this fixes what appears to be an extra semicolon in the
repo initialization template dir handling (and as part of that
fix, handles the case where an error occurs correctly).
2013-09-23 21:41:43 -07:00
Linquize
66566516ce Fix warning 2013-09-19 23:14:06 +08:00
Russell Belfer
41f1f9d732 Add API to get path to index file 2013-07-10 12:14:13 -07:00
Russell Belfer
d2ce27dd49 Add public API for pathspec matching
This adds a new public API for compiling pathspecs and matching
them against the working directory, the index, or a tree from the
repository.  This also reworks the pathspec internals to allow the
sharing of code between the existing internal usage of pathspec
matching and the new external API.

While this is working and the new API is ready for discussion, I
think there is still an incorrect behavior in which patterns are
always matched against the full path of an entry without taking
the subdirectories into account (so "s*" will match "subdir/file"
even though it wouldn't with core Git).  Further enhancements are
coming, but this was a good place to take a functional snapshot.
2013-07-10 20:50:31 +02:00
Andreas Linde
e196716457 Fixed most documentation header bugs
Fixed a few header @param and @return typos with the help of -Wdocumentation in Xcode.

The following warnings have not been fixed:
common.h:213 - Not sure how the documentation format is for '...'
notes.h:102 - Correct @param name but empty text
notes.h:111 - Correct @param name but empty text
pack.h:140 - @return missing text
pack.h:148 - @return missing text
2013-06-24 15:33:41 +02: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
Edward Thomson
0e0108f73f introduce git_conflict_iterator 2013-05-17 16:10:48 -05: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
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
Edward Thomson
75d1c8c664 move NAME and REUC extensions to sys/ 2013-04-30 17:33:11 -05:00
Edward Thomson
0462fba538 renames! 2013-04-30 16:01:11 -05:00
Edward Thomson
bec65a5e99 merge! 2013-04-30 15:31:31 -05:00
Edward Thomson
5bddabcca5 clear REUC on checkout 2013-03-04 18:10:57 -06:00
nulltoken
3f0ed118d1 index: Enhance documentation 2013-02-05 15:47:16 +01:00
Philip Kelley
11d9f6b304 Vector improvements and their fallout 2013-01-27 14:17:07 -05: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
Edward Thomson
359fc2d241 update copyrights 2013-01-08 17:31:27 -06:00
Russell Belfer
7fc0043582 Add index API to remove all files in a directory
This adds the git_index_remove_directory API plus tests.
2013-01-04 15:47:44 -08:00
Russell Belfer
a8122b5d4a Fix warnings on Win64 build 2012-11-27 13:18:29 -08:00