Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

May 26, 2011

  1. Junio C Hamano

    Add streaming filter API

    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 <gitster@pobox.com>
    authored May 20, 2011

May 21, 2011

  1. Junio C Hamano

    streaming_write_entry(): support files with holes

    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 <gitster@pobox.com>
    authored May 13, 2011
  2. Junio C Hamano

    streaming_write_entry(): use streaming API in write_entry()

    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 <gitster@pobox.com>
    authored May 12, 2011
  3. Junio C Hamano

    write_entry(): separate two helper functions out

    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 <gitster@pobox.com>
    authored May 12, 2011

Nov 29, 2010

  1. Nguyễn Thái Ngọc Duy

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

    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 <pclouds@gmail.com>
    Acked-by: Jeff King <peff@peff.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    authored November 28, 2010 gitster committed November 29, 2010

Jan 20, 2010

  1. Junio C Hamano

    Merge branch 'jc/symbol-static'

    * 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
    authored January 20, 2010

Jan 13, 2010

  1. Junio C Hamano

    Merge branch 'nd/sparse'

    * 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()
      ...
    
    Conflicts:
    	.gitignore
    	Documentation/config.txt
    	Documentation/git-update-index.txt
    	Makefile
    	entry.c
    	t/t7002-grep.sh
    authored January 13, 2010

Jan 12, 2010

  1. Junio C Hamano

    entry.c: mark file-local function static

    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    authored January 11, 2010

Dec 14, 2009

  1. Nguyễn Thái Ngọc Duy

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

    …_VALID
    
    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 <pclouds@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    authored December 14, 2009 gitster committed December 14, 2009

Aug 18, 2009

  1. Junio C Hamano

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

    Merlyn noticed that Documentation/install-doc-quick.sh 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 <gitster@pobox.com>
    authored August 16, 2009

Jul 30, 2009

  1. Linus Torvalds

    git-checkout: be careful about untracked symlinks

    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 <gitster@pobox.com>
    authored July 29, 2009 gitster committed July 29, 2009

Jun 27, 2009

  1. trast

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

    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 <trast@student.ethz.ch>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    authored June 27, 2009 gitster committed June 27, 2009
  2. trast

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

    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 <trast@student.ethz.ch>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    authored June 27, 2009 gitster committed June 27, 2009

Apr 30, 2009

  1. replace direct calls to unlink(2) with unlink_or_warn

    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 <raa.lkml@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    authored April 29, 2009 gitster committed April 29, 2009

Apr 20, 2009

  1. Windows: Skip fstat/lstat optimization in write_entry()

    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."
    
    (http://msdn.microsoft.com/en-us/library/ms724290(VS.85).aspx)
    
    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 <j6t@kdbg.org>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    authored April 20, 2009 gitster committed April 20, 2009

Feb 10, 2009

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

    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 <barvik@broadpark.no>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    authored February 09, 2009 gitster committed February 09, 2009
  2. write_entry(): cleanup of some duplicated code

    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 <barvik@broadpark.no>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    authored February 09, 2009 gitster committed February 09, 2009
  3. create_directories(): remove some memcpy() and strchr() calls

    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 <barvik@broadpark.no>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    authored February 09, 2009 gitster committed February 09, 2009
  4. lstat_cache(): swap func(length, string) into func(string, length)

    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 <barvik@broadpark.no>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    authored February 09, 2009 gitster committed February 09, 2009

Jan 26, 2009

  1. Junio C Hamano

    Merge branch 'kb/lstat-cache'

    * 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
    authored January 25, 2009

Jan 18, 2009

  1. lstat_cache(): introduce has_dirs_only_path() function

    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 <barvik@broadpark.no>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    authored January 18, 2009 gitster committed January 18, 2009

Jan 11, 2009

  1. Alexander Potashev

    add is_dot_or_dotdot inline function

    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 <aspotashev@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    authored January 10, 2009 gitster committed January 11, 2009

Aug 31, 2008

  1. Junio C Hamano

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

    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 <gitster@pobox.com>
    authored August 31, 2008

Mar 19, 2008

  1. Linus Torvalds

    Fix possible Solaris problem in 'checkout_entry()'

    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
    there.
    
    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 <torvalds@linux-foundation.org>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    authored March 17, 2008 gitster committed March 18, 2008

Jan 21, 2008

  1. Linus Torvalds

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

    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
    simpler.
    
    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 <torvalds@linux-foundation.org>
    authored January 14, 2008

Nov 14, 2007

  1. Junio C Hamano

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

    * 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
    
    Conflicts:
    
    	builtin-add.c
    authored November 14, 2007

Nov 10, 2007

  1. Junio C Hamano

    ce_match_stat, run_diff_files: use symbolic constants for readability

    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 <gitster@pobox.com>
    authored November 10, 2007

Oct 22, 2007

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

    Fix size_t vs. unsigned long pointer mismatch warnings introduced
    with the addition of strbuf_detach().
    
    Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
    Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
    authored October 21, 2007 spearce committed October 22, 2007

Sep 29, 2007

  1. Pierre Habouzit

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

    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
    anymore.
    
    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
        macro.
      * 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 <madcoder@debian.org>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    authored September 27, 2007 gitster committed September 29, 2007

Sep 17, 2007

  1. Pierre Habouzit

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

    * 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 <madcoder@debian.org>
    Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    authored September 16, 2007 gitster committed September 16, 2007

Aug 15, 2007

  1. Junio C Hamano

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

    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 <gitster@pobox.com>
    authored August 14, 2007

Jul 19, 2007

  1. Junio C Hamano

    Merge branch 'maint'

    * maint:
      Force listingblocks to be monospaced in manpages
      Do not expect unlink(2) to fail on a directory.
    authored July 18, 2007

Jul 18, 2007

  1. Junio C Hamano

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

    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 <torvalds@linux-foundation.org>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    authored July 17, 2007

Jun 07, 2007

  1. Junio C Hamano

    War on whitespace

    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 <gitster@pobox.com>
    authored June 07, 2007

May 22, 2007

  1. Martin Waitz

    rename dirlink to gitlink.

    Unify naming of plumbing dirlink/gitlink concept:
    
    git ls-files -z '*.[ch]' |
    xargs -0 perl -pi -e 's/dirlink/gitlink/g;' -e 's/DIRLNK/GITLINK/g;'
    
    Signed-off-by: Junio C Hamano <junkio@cox.net>
    authored May 21, 2007 Junio C Hamano committed May 21, 2007
Something went wrong with that request. Please try again.