Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

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>
    gitster authored

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>
    torvalds authored gitster committed

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>
    trast authored gitster committed
  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>
    trast authored gitster committed

Apr 30, 2009

  1. Alex Riesen

    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>
    raalkml authored gitster committed

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>
    Johannes Sixt authored gitster committed

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>
    Kjetil Barvik authored gitster committed
  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>
    Kjetil Barvik authored gitster committed
  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>
    Kjetil Barvik authored gitster committed
  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>
    Kjetil Barvik authored gitster committed

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
    gitster authored

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>
    Kjetil Barvik authored gitster committed

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>
    aspotashev authored gitster committed

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>
    gitster authored

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>
    torvalds authored gitster committed

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>
    torvalds authored

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
    gitster authored

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>
    gitster authored

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>
    René Scharfe authored spearce committed

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>
    MadCoder authored gitster committed

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>
    MadCoder authored gitster committed

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>
    gitster authored

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.
    gitster authored

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>
    gitster authored

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>
    gitster authored

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>
    tali authored Junio C Hamano committed

Apr 25, 2007

  1. entry.c: Use const qualifier for 'struct checkout' parameters

    Signed-off-by: Luiz Fernando N. Capitulino <lcapitulino@mandriva.com.br>
    Signed-off-by: Junio C Hamano <junkio@cox.net>
    Luiz Fernando N. Capitulino authored Junio C Hamano committed
  2. remove_subtree(): Use strerror() when possible

    Signed-off-by: Luiz Fernando N. Capitulino <lcapitulino@mandriva.com.br>
    Signed-off-by: Junio C Hamano <junkio@cox.net>
    Luiz Fernando N. Capitulino authored Junio C Hamano committed

Apr 22, 2007

  1. Merge branch 'jc/attr'

    * 'jc/attr': (28 commits)
      lockfile: record the primary process.
      convert.c: restructure the attribute checking part.
      Fix bogus linked-list management for user defined merge drivers.
      Simplify calling of CR/LF conversion routines
      Document gitattributes(5)
      Update 'crlf' attribute semantics.
      Documentation: support manual section (5) - file formats.
      Simplify code to find recursive merge driver.
      Counto-fix in merge-recursive
      Fix funny types used in attribute value representation
      Allow low-level driver to specify different behaviour during internal merge.
      Custom low-level merge driver: change the configuration scheme.
      Allow the default low-level merge driver to be configured.
      Custom low-level merge driver support.
      Add a demonstration/test of customized merge.
      Allow specifying specialized merge-backend per path.
      merge-recursive: separate out xdl_merge() interface.
      Allow more than true/false to attributes.
      Document git-check-attr
      Change attribute negation marker from '!' to '-'.
      ...
    Junio C Hamano authored

Apr 21, 2007

  1. Alex Riesen

    Simplify calling of CR/LF conversion routines

    Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
    Signed-off-by: Junio C Hamano <junkio@cox.net>
    raalkml authored Junio C Hamano committed

Apr 14, 2007

  1. Linus Torvalds

    Teach "git-read-tree -u" to check out submodules as a directory

    This actually allows us to check out a supermodule after cloning, although
    the submodules themselves will obviously not be checked out, and will just
    be empty directories.
    
    Checking out the submodules will be up to higher levels - we may not even
    want to!
    
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Junio C Hamano <junkio@cox.net>
    torvalds authored Junio C Hamano committed

Mar 03, 2007

  1. Add core.symlinks to mark filesystems that do not support symbolic li…

    …nks.
    
    Some file systems that can host git repositories and their working copies
    do not support symbolic links. But then if the repository contains a symbolic
    link, it is impossible to check out the working copy.
    
    This patch enables partial support of symbolic links so that it is possible
    to check out a working copy on such a file system.  A new flag
    core.symlinks (which is true by default) can be set to false to indicate
    that the filesystem does not support symbolic links. In this case, symbolic
    links that exist in the trees are checked out as small plain files, and
    checking in modifications of these files preserve the symlink property in
    the database (as long as an entry exists in the index).
    
    Of course, this does not magically make symbolic links work on such defective
    file systems; hence, this solution does not help if the working copy relies
    on that an entry is a real symbolic link.
    
    Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
    Signed-off-by: Junio C Hamano <junkio@cox.net>
    Johannes Sixt authored Junio C Hamano committed

Feb 27, 2007

  1. convert object type handling from a string to a number

    We currently have two parallel notation for dealing with object types
    in the code: a string and a numerical value.  One of them is obviously
    redundent, and the most used one requires more stack space and a bunch
    of strcmp() all over the place.
    
    This is an initial step for the removal of the version using a char array
    found in object reading code paths.  The patch is unfortunately large but
    there is no sane way to split it in smaller parts without breaking the
    system.
    
    Signed-off-by: Nicolas Pitre <nico@cam.org>
    Signed-off-by: Junio C Hamano <junkio@cox.net>
    Nicolas Pitre authored Junio C Hamano committed

Feb 14, 2007

  1. Linus Torvalds

    Lazy man's auto-CRLF

    It currently does NOT know about file attributes, so it does its
    conversion purely based on content. Maybe that is more in the "git
    philosophy" anyway, since content is king, but I think we should try to do
    the file attributes to turn it off on demand.
    
    Anyway, BY DEFAULT it is off regardless, because it requires a
    
    	[core]
    		AutoCRLF = true
    
    in your config file to be enabled. We could make that the default for
    Windows, of course, the same way we do some other things (filemode etc).
    
    But you can actually enable it on UNIX, and it will cause:
    
     - "git update-index" will write blobs without CRLF
     - "git diff" will diff working tree files without CRLF
     - "git checkout" will write files to the working tree _with_ CRLF
    
    and things work fine.
    
    Funnily, it actually shows an odd file in git itself:
    
    	git clone -n git test-crlf
    	cd test-crlf
    	git config core.autocrlf true
    	git checkout
    	git diff
    
    shows a diff for "Documentation/docbook-xsl.css". Why? Because we have
    actually checked in that file *with* CRLF! So when "core.autocrlf" is
    true, we'll always generate a *different* hash for it in the index,
    because the index hash will be for the content _without_ CRLF.
    
    Is this complete? I dunno. It seems to work for me. It doesn't use the
    filename at all right now, and that's probably a deficiency (we could
    certainly make the "is_binary()" heuristics also take standard filename
    heuristics into account).
    
    I don't pass in the filename at all for the "index_fd()" case
    (git-update-index), so that would need to be passed around, but this
    actually works fine.
    
    NOTE NOTE NOTE! The "is_binary()" heuristics are totally made-up by yours
    truly. I will not guarantee that they work at all reasonable. Caveat
    emptor. But it _is_ simple, and it _is_ safe, since it's all off by
    default.
    
    The patch is pretty simple - the biggest part is the new "convert.c" file,
    but even that is really just basic stuff that anybody can write in
    "Teaching C 101" as a final project for their first class in programming.
    Not to say that it's bug-free, of course - but at least we're not talking
    about rocket surgery here.
    
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Junio C Hamano <junkio@cox.net>
    torvalds authored Junio C Hamano committed

Feb 13, 2007

  1. Linus Torvalds

    Mark places that need blob munging later for CRLF conversion.

    Here's a patch that I think we can merge right now. There may be
    other places that need this, but this at least points out the
    three places that read/write working tree files for git
    update-index, checkout and diff respectively. That should cover
    a lot of it [jc: git-apply uses an entirely different codepath
    both for reading and writing].
    
    Some day we can actually implement it. In the meantime, this
    points out a place for people to start. We *can* even start with
    a really simple "we do CRLF conversion automatically, regardless
    of filename" kind of approach, that just look at the data (all
    three cases have the _full_ file data already in memory) and
    says "ok, this is text, so let's convert to/from DOS format
    directly".
    
    THAT somebody can write in ten minutes, and it would already
    make git much nicer on a DOS/Windows platform, I suspect.
    
    And it would be totally zero-cost if you just make it a config
    option (but please make it dynamic with the _default_ just being
    0/1 depending on whether it's UNIX/Windows, just so that UNIX
    people can _test_ it easily).
    
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Junio C Hamano <junkio@cox.net>
    torvalds authored Junio C Hamano committed
Something went wrong with that request. Please try again.