1. 25 Jul, 2011 5 commits
    • index: rework index entry initialization routine · 76159921
      index_init_entry() renamed to index_entry_init(). Now it allocates entry
      on its own.
      
      git_index_add() and git_index_append() reworked accordingly.
      
      This commit fixes warning:
      
      /home/kas/git/public/libgit2/src/index.c: In function ‘index_init_entry’:
      /home/kas/git/public/libgit2/src/index.c:452:14: warning: assignment discards ‘const’ qualifier from pointer target type [enabled by default]
      
      Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
      Kirill A. Shutemov committed
    • index: rework index_insert() · f939d39b
      Now index_insert() takes copy of index entry, not coping it by itself.
      
      Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
      Kirill A. Shutemov committed
    • index: introduce index_entry_free() · b2dd6815
      Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
      Kirill A. Shutemov committed
    • index: extract index_entry_dup() from index_insert() · 51917d9c
      Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
      Kirill A. Shutemov committed
    • index: fix cast warnings · 7d9cc9f8
      /home/kas/git/public/libgit2/src/index.c: In function ‘git_index_clear’:
      /home/kas/git/public/libgit2/src/index.c:228:8: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual]
      /home/kas/git/public/libgit2/src/index.c:235:8: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual]
      /home/kas/git/public/libgit2/src/index.c: In function ‘index_insert’:
      /home/kas/git/public/libgit2/src/index.c:392:7: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual]
      /home/kas/git/public/libgit2/src/index.c:399:7: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual]
      /home/kas/git/public/libgit2/src/index.c: In function ‘read_unmerged’:
      /home/kas/git/public/libgit2/src/index.c:681:35: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual]
      /home/kas/git/public/libgit2/src/index.c: In function ‘read_entry’:
      /home/kas/git/public/libgit2/src/index.c:716:33: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual]
      
      Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
      Kirill A. Shutemov committed
  2. 23 Jul, 2011 1 commit
  3. 19 Jul, 2011 1 commit
  4. 13 Jul, 2011 8 commits
  5. 09 Jul, 2011 1 commit
  6. 07 Jul, 2011 2 commits
    • index: Fix memory leak on OOM · da5b1e1c
      Vicent Marti committed
    • vector: Timsort all of the things · de18f276
      Drop the GLibc implementation of Merge Sort and replace it with Timsort.
      
      The algorithm has been tuned to work on arrays of pointers (void **),
      so there's no longer a need to abstract the byte-width of each element
      in the array.
      
      All the comparison callbacks now take pointers-to-elements, not
      pointers-to-pointers, so there's now one less level of dereferencing.
      
      E.g.
      
      	 int index_cmp(const void *a, const void *b)
      	 {
      	-	const git_index_entry *entry_a = *(const git_index_entry **)(a);
      	+	const git_index_entry *entry_a = (const git_index_entry *)(a);
      
      The result is up to a 40% speed-up when sorting vectors. Memory usage
      remains lineal.
      
      A new `bsearch` implementation has been added, whose callback also
      supplies pointer-to-elements, to uniform the Vector API again.
      Vicent Marti committed
  7. 05 Jul, 2011 3 commits
    • index: introduce git_index_uniq() function · 245adf4f
      It removes all entries with equal path except last added.
      
      On large indexes git_index_append() + git_index_uniq() before writing is
      *much* faster, than git_index_add().
      
      Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
      Kirill A. Shutemov committed
    • index: speedup git_index_append()/git_index_append2() · 8cc16e29
      git_index_find() in index_insert() is useless if replace is not
      requested (append). Do not call it in this case.
      It speedup git_index_append() *dramatically* on large indexes.
      
      $ cat index_test.c
      
      int main(int argc, char **argv)
      {
              git_index *index;
              git_repository *repo;
              git_odb *odb;
              struct git_index_entry entry;
              git_oid tree_oid;
              char tree_hex[41];
              int i;
      
              git_repository_init(&repo, "/tmp/myrepo", 0);
              odb = git_repository_database(repo);
              git_repository_index(&index, repo);
      
              memset(&entry, 0, sizeof(entry));
              git_odb_write(&entry.oid, odb, "", 0, GIT_OBJ_BLOB);
              entry.path = "test.file";
      
              for (i = 0; i < 50000; i++)
                      git_index_append2(index, &entry);
      
              git_tree_create_fromindex(&tree_oid, index);
              git_oid_fmt(tree_hex, &tree_oid);
              tree_hex[40] = '\0';
              printf("tree: %s\n", tree_hex);
      
              git_index_free(index);
              git_repository_free(repo);
      
              return 0;
      }
      
      Before:
      $ time ./index_test
      tree: 43f73659c43b651588cc81459d9e25b08721b95d
      ./index_test  151.19s user 0.05s system 99% cpu 2:31.78 total
      
      After:
      $ time ./index_test
      tree: 43f73659c43b651588cc81459d9e25b08721b95d
      ./index_test  0.05s user 0.00s system 94% cpu 0.059 total
      
      About 2573 times speedup on this test :)
      
      Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
      Kirill A. Shutemov committed
    • fileops: Cleanup · f79026b4
      Cleaned up the structure of the whole OS-abstraction layer.
      
      fileops.c now contains a set of utility methods for file management used
      by the library. These are abstractions on top of the original POSIX
      calls.
      
      There's a new file called `posix.c` that contains
      emulations/reimplementations of all the POSIX calls the library uses.
      These are prefixed with `p_`. There's a specific posix file for each
      platform (win32 and unix).
      
      All the path-related methods have been moved from `utils.c` to `path.c`
      and have their own prefix.
      Vicent Marti committed
  8. 01 Jul, 2011 1 commit
  9. 16 Jun, 2011 1 commit
  10. 10 Jun, 2011 1 commit
  11. 08 Jun, 2011 1 commit
    • windows: Fix Symlink issues · ae496955
      Handle Symlinks if they can be handled in Win32. This is not even
      compiled. Needs review.
      
      The lstat implementation is modified from core Git.
      The readlink implementation is modified from PHP.
      Vicent Marti committed
  12. 07 Jun, 2011 5 commits
    • fileops: Allow differentiation between deep and shallow exists() · fdd1e04c
      When calling gitfo_exists() on a symbolic link, sometimes we need to
      simply check whether the link exists and sometimes we need to check
      whether the file pointed to by the symlink exists.
      
      Introduce a new function gitfo_shallow_exists that only checks if the
      link exists and revert gitfo_exists to the original functionality of
      checking whether the file pointed to by the link exists.
      Jakob Pfender committed
    • blob: Stat path inside git_blob_create_fromfile · b74c867a
      00582bc introduced a change that required the caller of
      git_blob_create_fromfile() to pass a struct stat with the stat
      information for the file. Several developers pointed out that this would
      make life hard for the bindings developers as struct stat isn't widely
      supported by other languages.
      
      Make git_blob_create_fromfile() stat the path itself, eliminating the
      need for the file to be stat'ed by the caller. This makes
      index_init_entry() more costly as the file will be stat'ed twice but
      makes life easier for everyone else.
      Jakob Pfender committed
    • index: Correctly write entry mode · c1a2a14e
      The entry mode flags for an entry created from a path name were not
      correctly written if the entry was a symlink. The st_mode of a statted
      symlink is 0120777, however git requires the mode to read 0120000,
      because it does not care about permissions of symlinks.
      
      Introduce index_create_mode() that correctly writes the mode flags in
      the form expected by git.
      Jakob Pfender committed
    • index/fileops: Correctly process symbolic links · 1869b31e
      gitfo_exists() used to error out if the given file was a symbolic link,
      due to access() returning an error code. This is not expected behaviour,
      as gitfo_exists() should only check whether the file itself exists, not
      its link target if it is a symbolic link.
      
      Fix this by calling gitfo_lstat() instead, which is just a wrapper for
      lstat().
      
      Also fix the same error in index_init_entry().
      Jakob Pfender committed
    • blob: Require stat information for git_blob_create_fromfile() · 4d7905c5
      In order to be able to write symlinks with git_blob_create_fromfile(),
      we need to check whether the file to be written is a symbolic link or
      not. Since the calling function of git_blob_create_fromfile() is likely to have
      stated the file before calling, we make it pass the stat.
      
      The reason for this is that writing symbolic link blobs is significantly
      different from writing ordinary files - we do not want to open the link
      destination but instead want to write the link itself, regardless of
      whether it exists or not.
      
      Previously, index_init_entry() used to error out if the file to be added
      was a symlink that pointed to a nonexistent file. Fix this behaviour to
      add the file regardless of whether it exists. This mimics git.git's
      behaviour.
      Jakob Pfender committed
  13. 05 Jun, 2011 1 commit
  14. 03 Jun, 2011 1 commit
  15. 01 Jun, 2011 4 commits
  16. 31 May, 2011 1 commit
  17. 23 May, 2011 2 commits
  18. 19 May, 2011 1 commit