Skip to content
Commits on Mar 7, 2012
  1. @gitster

    streaming: make streaming-write-entry to be more reusable

    gitster committed Mar 7, 2012
    The static function in entry.c takes a cache entry and streams its blob
    contents to a file in the working tree.  Refactor the logic to a new API
    function stream_blob_to_fd() that takes an object name and an open file
    descriptor, so that it can be reused by other callers.
    Signed-off-by: Nguyễn Thái Ngọc Duy <>
    Signed-off-by: Junio C Hamano <>
Commits on May 26, 2011
  1. @gitster

    Add streaming filter API

    gitster committed May 20, 2011
    This introduces an API to plug custom filters to an input stream.
    The caller gets get_stream_filter("path") to obtain an appropriate
    filter for the path, and then uses it when opening an input stream
    via open_istream().  After that, the caller can read from the stream
    with read_istream(), and close it with close_istream(), just like an
    unfiltered stream.
    This only adds a "null" filter that is a pass-thru filter, but later
    changes can add LF-to-CRLF and other filters, and the callers of the
    streaming API do not have to change.
    Signed-off-by: Junio C Hamano <>
Commits on May 21, 2011
  1. @gitster

    streaming_write_entry(): support files with holes

    gitster committed May 13, 2011
    One typical use of a large binary file is to hold a sparse on-disk hash
    table with a lot of holes. Help preserving the holes with lseek().
    Signed-off-by: Junio C Hamano <>
  2. @gitster

    streaming_write_entry(): use streaming API in write_entry()

    gitster committed May 12, 2011
    When the output to a path does not have to be converted, we can read from
    the object database from the streaming API and write to the file in the
    working tree, without having to hold everything in the memory.
    The ident, auto- and safe- crlf conversions inherently require you to read
    the whole thing before deciding what to do, so while it is technically
    possible to support them by using a buffer of an unbound size or rewinding
    and reading the stream twice, it is less practical than the traditional
    "read the whole thing in core and convert" approach.
    Adding streaming filters for the other conversions on top of this should
    be doable by tweaking the can_bypass_conversion() function (it should be
    renamed to can_filter_stream() when it happens). Then the streaming API
    can be extended to wrap the git_istream streaming_write_entry() opens on
    the underlying object in another git_istream that reads from it, filters
    what is read, and let the streaming_write_entry() read the filtered
    result. But that is outside the scope of this series.
    Signed-off-by: Junio C Hamano <>
  3. @gitster

    write_entry(): separate two helper functions out

    gitster committed May 12, 2011
    In the write-out codepath, a block of code determines what file in the
    working tree to write to, and opens an output file descriptor to it.
    After writing the contents out to the file, another block of code runs
    fstat() on the file descriptor when appropriate.
    Separate these blocks out to open_output_fd() and fstat_output()
    helper functions.
    Signed-off-by: Junio C Hamano <>
Commits on Nov 29, 2010
  1. @pclouds @gitster

    entry.c: remove "checkout-index" from error messages

    pclouds committed with gitster Nov 28, 2010
    Back then when entry.c was part of checkout-index (or checkout-cache
    at that time [1]). It makes sense to print the command name in error
    messages. Nowadays entry.c is in libgit and can be used by any
    commands, printing "git checkout-index: blah" does no more than
    confusion. The error messages without it still give enough information.
    [1] 12dccc1 (Make fiel checkout function available to the git library - 2005-06-05)
    Signed-off-by: Nguyễn Thái Ngọc Duy <>
    Acked-by: Jeff King <>
    Signed-off-by: Junio C Hamano <>
Commits on Jan 20, 2010
  1. @gitster

    Merge branch 'jc/symbol-static'

    gitster committed Jan 20, 2010
    * jc/symbol-static:
      date.c: mark file-local function static
      Replace parse_blob() with an explanatory comment
      symlinks.c: remove unused functions
      object.c: remove unused functions
      strbuf.c: remove unused function
      sha1_file.c: remove unused function
      mailmap.c: remove unused function
      utf8.c: mark file-local function static
      submodule.c: mark file-local function static
      quote.c: mark file-local function static
      remote-curl.c: mark file-local function static
      read-cache.c: mark file-local functions static
      parse-options.c: mark file-local function static
      entry.c: mark file-local function static
      http.c: mark file-local functions static
      pretty.c: mark file-local function static
      builtin-rev-list.c: mark file-local function static
      bisect.c: mark file-local function static
Commits on Jan 13, 2010
  1. @gitster

    Merge branch 'nd/sparse'

    gitster committed Jan 13, 2010
    * nd/sparse: (25 commits)
      t7002: test for not using external grep on skip-worktree paths
      t7002: set test prerequisite "external-grep" if supported
      grep: do not do external grep on skip-worktree entries
      commit: correctly respect skip-worktree bit
      ie_match_stat(): do not ignore skip-worktree bit with CE_MATCH_IGNORE_VALID
      tests: rename duplicate t1009
      sparse checkout: inhibit empty worktree
      Add tests for sparse checkout
      read-tree: add --no-sparse-checkout to disable sparse checkout support
      unpack-trees(): ignore worktree check outside checkout area
      unpack_trees(): apply $GIT_DIR/info/sparse-checkout to the final index
      unpack-trees(): "enable" sparse checkout and load $GIT_DIR/info/sparse-checkout
      unpack-trees.c: generalize verify_* functions
      unpack-trees(): add CE_WT_REMOVE to remove on worktree alone
      Introduce "sparse checkout"
      dir.c: export excluded_1() and add_excludes_from_file_1()
      excluded_1(): support exclude files in index
      unpack-trees(): carry skip-worktree bit over in merged_entry()
      Read .gitignore from index if it is skip-worktree
      Avoid writing to buffer in add_excludes_from_file_1()
Commits on Jan 12, 2010
  1. @gitster

    entry.c: mark file-local function static

    gitster committed Jan 11, 2010
    Signed-off-by: Junio C Hamano <>
Commits on Dec 14, 2009
  1. @pclouds @gitster

    ie_match_stat(): do not ignore skip-worktree bit with CE_MATCH_IGNORE…

    pclouds committed with gitster Dec 14, 2009
    Previously CE_MATCH_IGNORE_VALID flag is used by both valid and
    skip-worktree bits. While the two bits have similar behaviour, sharing
    this flag means "git update-index --really-refresh" will ignore
    skip-worktree while it should not. Instead another flag is
    introduced to ignore skip-worktree bit, CE_MATCH_IGNORE_VALID only
    applies to valid bit.
    Signed-off-by: Nguyễn Thái Ngọc Duy <>
    Signed-off-by: Junio C Hamano <>
Commits on Aug 18, 2009
  1. @gitster

    check_path(): allow symlinked directories to checkout-index --prefix

    gitster committed Aug 16, 2009
    Merlyn noticed that Documentation/ no longer correctly
    removes old installed documents when the target directory has a leading
    path that is a symlink.  It turns out that "checkout-index --prefix" was
    broken by recent b6986d8 (git-checkout: be careful about untracked
    symlinks, 2009-07-29).
    I suspect has_symlink_leading_path() could learn the third parameter
    (prefix that is allowed to be symlinked directories) to allow us to retire
    a similar function has_dirs_only_path().
    Another avenue of fixing this I considered was to get rid of base_dir and
    base_dir_len from "struct checkout", and instead make "git checkout-index"
    when run with --prefix mkdir the leading path and chdir in there.  It
    might be the best longer term solution to this issue, as the base_dir
    feature is used only by that rather obscure codepath as far as I know.
    But at least this patch should fix this breakage.
    Signed-off-by: Junio C Hamano <>
Commits on Jul 30, 2009
  1. @torvalds @gitster

    git-checkout: be careful about untracked symlinks

    torvalds committed with gitster Jul 29, 2009
    This fixes the case where an untracked symlink that points at a directory
    with tracked paths confuses the checkout logic, demostrated in t6035.
    Signed-off-by: Junio C Hamano <>
Commits on Jun 27, 2009
  1. @trast @gitster

    Use die_errno() instead of die() when checking syscalls

    trast committed with gitster Jun 27, 2009
    Lots of die() calls did not actually report the kind of error, which
    can leave the user confused as to the real problem.  Use die_errno()
    where we check a system/library call that sets errno on failure, or
    one of the following that wrap such calls:
      Function              Passes on error from
      --------              --------------------
      odb_pack_keep         open
      read_ancestry         fopen
      read_in_full          xread
      strbuf_read           xread
      strbuf_read_file      open or strbuf_read_file
      strbuf_readlink       readlink
      write_in_full         xwrite
    Signed-off-by: Thomas Rast <>
    Signed-off-by: Junio C Hamano <>
  2. @trast @gitster

    Convert existing die(..., strerror(errno)) to die_errno()

    trast committed with gitster Jun 27, 2009
    Change calls to die(..., strerror(errno)) to use the new die_errno().
    In the process, also make slight style adjustments: at least state
    _something_ about the function that failed (instead of just printing
    the pathname), and put paths in single quotes.
    Signed-off-by: Thomas Rast <>
    Signed-off-by: Junio C Hamano <>
Commits on Apr 30, 2009
  1. @raalkml @gitster

    replace direct calls to unlink(2) with unlink_or_warn

    raalkml committed with gitster Apr 29, 2009
    This helps to notice when something's going wrong, especially on
    systems which lock open files.
    I used the following criteria when selecting the code for replacement:
    - it was already printing a warning for the unlink failures
    - it is in a function which already printing something or is
      called from such a function
    - it is in a static function, returning void and the function is only
      called from a builtin main function (cmd_)
    - it is in a function which handles emergency exit (signal handlers)
    - it is in a function which is obvously cleaning up the lockfiles
    Signed-off-by: Alex Riesen <>
    Signed-off-by: Junio C Hamano <>
Commits on Apr 20, 2009
  1. @j6t @gitster

    Windows: Skip fstat/lstat optimization in write_entry()

    j6t committed with gitster Apr 20, 2009
    Commit e4c7292 (write_entry(): use fstat() instead of lstat() when file
    is open, 2009-02-09) introduced an optimization of write_entry().
    Unfortunately, we cannot take advantage of this optimization on Windows
    because there is no guarantee that the time stamps are updated before the
    file is closed:
      "The only guarantee about a file timestamp is that the file time is
       correctly reflected when the handle that makes the change is closed."
    The failure of this optimization on Windows can be observed most easily by
    running a 'git checkout' that has to update several large files. In this
    case, 'git checkout' will report modified files, but infact only the
    timestamps were incorrectly recorded in the index, as can be verified by a
    subsequent 'git diff', which shows no change.
    Dmitry Potapov reports the same fix needs on Cygwin; this commit contains
    his updates for that.
    Signed-off-by: Johannes Sixt <>
    Signed-off-by: Junio C Hamano <>
Commits on Feb 10, 2009
  1. @gitster

    write_entry(): use fstat() instead of lstat() when file is open

    Kjetil Barvik committed with gitster Feb 9, 2009
    Currently inside write_entry() we do an lstat(path, &st) call on a
    file which have just been opened inside the exact same function.  It
    should be better to call fstat(fd, &st) on the file while it is open,
    and it should be at least as fast as the lstat() method.
    Signed-off-by: Kjetil Barvik <>
    Signed-off-by: Junio C Hamano <>
  2. @gitster

    write_entry(): cleanup of some duplicated code

    Kjetil Barvik committed with gitster Feb 9, 2009
    The switch-cases for S_IFREG and S_IFLNK was so similar that it will
    be better to do some cleanup and use the common parts of it.
    And the entry.c file should now be clean for 'gcc -Wextra' warnings.
    Signed-off-by: Kjetil Barvik <>
    Signed-off-by: Junio C Hamano <>
  3. @gitster

    create_directories(): remove some memcpy() and strchr() calls

    Kjetil Barvik committed with gitster Feb 9, 2009
    Remove the call to memcpy() and strchr() for each path component
    tested, and instead add each path component as we go forward inside
    the while-loop.
    Impact: small optimisation
    Signed-off-by: Kjetil Barvik <>
    Signed-off-by: Junio C Hamano <>
  4. @gitster

    lstat_cache(): swap func(length, string) into func(string, length)

    Kjetil Barvik committed with gitster Feb 9, 2009
    Swap function argument pair (length, string) into (string, length) to
    conform with the commonly used order inside the GIT source code.
    Also, add a note about this fact into the coding guidelines.
    Signed-off-by: Kjetil Barvik <>
    Signed-off-by: Junio C Hamano <>
Commits on Jan 26, 2009
  1. @gitster

    Merge branch 'kb/lstat-cache'

    gitster committed Jan 25, 2009
    * kb/lstat-cache:
      lstat_cache(): introduce clear_lstat_cache() function
      lstat_cache(): introduce invalidate_lstat_cache() function
      lstat_cache(): introduce has_dirs_only_path() function
      lstat_cache(): introduce has_symlink_or_noent_leading_path() function
      lstat_cache(): more cache effective symlink/directory detection
Commits on Jan 18, 2009
  1. @gitster

    lstat_cache(): introduce has_dirs_only_path() function

    Kjetil Barvik committed with gitster Jan 18, 2009
    The create_directories() function in entry.c currently calls stat()
    or lstat() for each path component of the pathname 'path' each and every
    time.  For the 'git checkout' command, this function is called on each
    file for which we must do an update (ce->ce_flags & CE_UPDATE), so we get
    lots and lots of calls.
    To fix this, we make a new wrapper to the lstat_cache() function, and
    call the wrapper function instead of the calls to the stat() or the
    lstat() functions.  Since the paths given to the create_directories()
    function, is sorted alphabetically, the new wrapper would be very
    cache effective in this situation.
    To support it we must update the lstat_cache() function to be able to
    say that "please test the complete length of 'name'", and also to give
    it the length of a prefix, where the cache should use the stat()
    function instead of the lstat() function to test each path component.
    Thanks to Junio C Hamano, Linus Torvalds and Rene Scharfe for valuable
    comments to this patch!
    Signed-off-by: Kjetil Barvik <>
    Signed-off-by: Junio C Hamano <>
Commits on Jan 11, 2009
  1. @aspotashev @gitster

    add is_dot_or_dotdot inline function

    aspotashev committed with gitster Jan 10, 2009
    A new inline function is_dot_or_dotdot is used to check if the
    directory name is either "." or "..". It returns a non-zero value if
    the given string is "." or "..". It's applicable to a lot of Git
    source code.
    Signed-off-by: Alexander Potashev <>
    Signed-off-by: Junio C Hamano <>
Commits on Aug 31, 2008
  1. @gitster

    'git foo' program identifies itself without dash in die() messages

    gitster committed Aug 31, 2008
    This is a mechanical conversion of all '*.c' files with:
    	s/((?:die|error|warning)\("git)-(\S+:)/$1 $2/;
    The result was manually inspected and no false positive was found.
    Signed-off-by: Junio C Hamano <>
Commits on Mar 19, 2008
  1. @torvalds @gitster

    Fix possible Solaris problem in 'checkout_entry()'

    torvalds committed with gitster Mar 17, 2008
    Currently when checking out an entry "path", we try to unlink(2) it first
    (because there could be stale file), and if there is a directory there,
    try to deal with it (typically we run recursive rmdir).  We ignore the
    error return from this unlink because there may not even be any file
    However if you are root on Solaris, you can unlink(2) a directory
    successfully and corrupt your filesystem.
    This moves the code around and check the directory first, and then
    unlink(2).  Also we check the error code from it.
    Signed-off-by: Linus Torvalds <>
    Signed-off-by: Junio C Hamano <>
Commits on Jan 21, 2008
  1. @torvalds

    Make on-disk index representation separate from in-core one

    torvalds committed Jan 14, 2008
    This converts the index explicitly on read and write to its on-disk
    format, allowing the in-core format to contain more flags, and be
    In particular, the in-core format is now host-endian (as opposed to the
    on-disk one that is network endian in order to be able to be shared
    across machines) and as a result we can dispense with all the
    htonl/ntohl on accesses to the cache_entry fields.
    This will make it easier to make use of various temporary flags that do
    not exist in the on-disk format.
    Signed-off-by: Linus Torvalds <>
Commits on Nov 14, 2007
  1. @gitster

    Merge branch 'jc/maint-add-sync-stat'

    gitster committed Nov 14, 2007
    * jc/maint-add-sync-stat:
      t2200: test more cases of "add -u"
      git-add: make the entry stat-clean after re-adding the same contents
      ce_match_stat, run_diff_files: use symbolic constants for readability
Commits on Nov 10, 2007
  1. @gitster

    ce_match_stat, run_diff_files: use symbolic constants for readability

    gitster committed Nov 10, 2007
    ce_match_stat() can be told:
     (1) to ignore CE_VALID bit (used under "assume unchanged" mode)
         and perform the stat comparison anyway;
     (2) not to perform the contents comparison for racily clean
         entries and report mismatch of cached stat information;
    using its "option" parameter.  Give them symbolic constants.
    Similarly, run_diff_files() can be told not to report anything
    on removed paths.  Also give it a symbolic constant for that.
    Signed-off-by: Junio C Hamano <>
Commits on Oct 22, 2007
  1. @spearce

    Correct some sizeof(size_t) != sizeof(unsigned long) typing errors

    René Scharfe committed with spearce Oct 21, 2007
    Fix size_t vs. unsigned long pointer mismatch warnings introduced
    with the addition of strbuf_detach().
    Signed-off-by: Rene Scharfe <>
    Signed-off-by: Shawn O. Pearce <>
Commits on Sep 29, 2007
  1. @gitster

    strbuf change: be sure ->buf is never ever NULL.

    Pierre Habouzit committed with gitster Sep 27, 2007
    For that purpose, the ->buf is always initialized with a char * buf living
    in the strbuf module. It is made a char * so that we can sloppily accept
    things that perform: sb->buf[0] = '\0', and because you can't pass "" as an
    initializer for ->buf without making gcc unhappy for very good reasons.
    strbuf_init/_detach/_grow have been fixed to trust ->alloc and not ->buf
    as a consequence strbuf_detach is _mandatory_ to detach a buffer, copying
    ->buf isn't an option anymore, if ->buf is going to escape from the scope,
    and eventually be free'd.
    API changes:
      * strbuf_setlen now always works, so just make strbuf_reset a convenience
      * strbuf_detatch takes a size_t* optional argument (meaning it can be
        NULL) to copy the buffer's len, as it was needed for this refactor to
        make the code more readable, and working like the callers.
    Signed-off-by: Pierre Habouzit <>
    Signed-off-by: Junio C Hamano <>
Commits on Sep 17, 2007
  1. @gitster

    Rewrite convert_to_{git,working_tree} to use strbuf's.

    Pierre Habouzit committed with gitster Sep 16, 2007
    * Now, those functions take an "out" strbuf argument, where they store their
      result if any. In that case, it also returns 1, else it returns 0.
    * those functions support "in place" editing, in the sense that it's OK to
      call them this way:
        convert_to_git(path, sb->buf, sb->len, sb);
      When doable, conversions are done in place for real, else the strbuf
      content is just replaced with the new one, transparentely for the caller.
    If you want to create a new filter working this way, being the accumulation
    of filter1, filter2, ... filtern, then your meta_filter would be:
        int meta_filter(..., const char *src, size_t len, struct strbuf *sb)
            int ret = 0;
            ret |= filter1(...., src, len, sb);
            if (ret) {
                src = sb->buf;
                len = sb->len;
            ret |= filter2(...., src, len, sb);
            if (ret) {
                src = sb->buf;
                len = sb->len;
            return ret | filtern(..., src, len, sb);
    That's why subfilters the convert_to_* functions called were also rewritten
    to work this way.
    Signed-off-by: Pierre Habouzit <>
    Acked-by: Linus Torvalds <>
    Signed-off-by: Junio C Hamano <>
Commits on Aug 15, 2007
  1. @gitster

    attr.c: read .gitattributes from index as well.

    gitster committed Aug 14, 2007
    This makes .gitattributes files to be read from the index when
    they are not checked out to the work tree.  This is in line with
    the way we always allowed low-level tools to operate in sparsely
    checked out work tree in a reasonable way.
    It swaps the order of new file creation and converting the blob
    to work tree representation; otherwise when we are in the middle
    of checking out .gitattributes we would notice an empty but
    unwritten .gitattributes file in the work tree and will ignore
    the copy in the index.
    Signed-off-by: Junio C Hamano <>
Commits on Jul 19, 2007
  1. @gitster

    Merge branch 'maint'

    gitster committed Jul 18, 2007
    * maint:
      Force listingblocks to be monospaced in manpages
      Do not expect unlink(2) to fail on a directory.
Commits on Jul 18, 2007
  1. @gitster

    Do not expect unlink(2) to fail on a directory.

    gitster committed Jul 17, 2007
    When "git checkout-index" checks out path A/B/C, it makes sure A
    and A/B are truly directories; if there is a regular file or
    symlink at A, we prefer to remove it.
    We used to do this by catching an error return from mkdir(2),
    and on EEXIST did unlink(2), and when it succeeded, tried
    another mkdir(2).
    Thomas Glanzmann found out the above does not work on Solaris
    for a root user, as unlink(2) was so old fashioned there that it
    allowed to unlink a directory.
    As pointed out, this still doesn't guarantee that git won't call
    "unlink()" on a directory (race conditions etc), but that's
    fundamentally true (there is no "funlink()" like there is
    "fstat()"), and besides, that is in no way git-specific (ie it's
    true of any application that gets run as root).
    Acked-by: Linus Torvalds <>
    Signed-off-by: Junio C Hamano <>
Commits on Jun 7, 2007
  1. @gitster

    War on whitespace

    gitster committed Jun 7, 2007
    This uses "git-apply --whitespace=strip" to fix whitespace errors that have
    crept in to our source files over time.  There are a few files that need
    to have trailing whitespaces (most notably, test vectors).  The results
    still passes the test, and build result in Documentation/ area is unchanged.
    Signed-off-by: Junio C Hamano <>
Something went wrong with that request. Please try again.