Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Commits on Sep 29, 2009
  1. @spearce

    git branch -D: give a better error message when lockfile creation fails

    Miklos Vajna authored spearce committed
    Previously the old error message just told the user that it was not
    possible to delete the ref from the packed-refs file. Give instructions
    on how to resolve the problem.
    Signed-off-by: Miklos Vajna <>
    Signed-off-by: Jeff King <>
    Signed-off-by: Shawn O. Pearce <>
Commits on May 18, 2009
  1. @gitster

    Merge branch 'ar/unlink-err'

    gitster authored
    * ar/unlink-err:
      print unlink(2) errno in copy_or_link_directory
      replace direct calls to unlink(2) with unlink_or_warn
      Introduce an unlink(2) wrapper which gives warning if unlink failed
Commits on May 1, 2009
  1. @felipec @gitster

    Fix a bunch of pointer declarations (codestyle)

    felipec authored gitster committed
    Essentially; s/type* /type */ as per the coding guidelines.
    Signed-off-by: Felipe Contreras <>
    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 authored gitster committed
    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 Mar 5, 2009
  1. @johnflux @gitster

    Make the 'lock file' exists error more informative

    johnflux authored gitster committed
    It looks like someone did 90% of the work, then forgot to actually use
    the function in one place.
    Also the helper function did not use the correct variable.
    Signed-off-by: Junio C Hamano <>
Commits on Feb 20, 2009
  1. @gitster

    Merge branch 'maint'

    gitster authored
    * maint:
      More friendly message when locking the index fails.
      Document git blame --reverse.
      Documentation: Note file formats send-email accepts
  2. @moy @gitster

    More friendly message when locking the index fails.

    moy authored gitster committed
    Just saying that index.lock exists doesn't tell the user _what_ to do
    to fix the problem. We should give an indication that it's normally
    safe to delete index.lock after making sure git isn't running here.
    Signed-off-by: Matthieu Moy <>
    Signed-off-by: Junio C Hamano <>
Commits on Jan 22, 2009
  1. @peff @gitster

    refactor signal handling for cleanup functions

    peff authored gitster committed
    The current code is very inconsistent about which signals
    are caught for doing cleanup of temporary files and lock
    files. Some callsites checked only SIGINT, while others
    checked a variety of death-dealing signals.
    This patch factors out those signals to a single function,
    and then calls it everywhere. For some sites, that means
    this is a simple clean up. For others, it is an improvement
    in that they will now properly clean themselves up after a
    larger variety of signals.
    Signed-off-by: Jeff King <>
    Signed-off-by: Junio C Hamano <>
  2. @peff @gitster

    chain kill signals for cleanup functions

    peff authored gitster committed
    If a piece of code wanted to do some cleanup before exiting
    (e.g., cleaning up a lockfile or a tempfile), our usual
    strategy was to install a signal handler that did something
    like this:
      do_cleanup(); /* actual work */
      signal(signo, SIG_DFL); /* restore previous behavior */
      raise(signo); /* deliver signal, killing ourselves */
    For a single handler, this works fine. However, if we want
    to clean up two _different_ things, we run into a problem.
    The most recently installed handler will run, but when it
    removes itself as a handler, it doesn't put back the first
    This patch introduces sigchain, a tiny library for handling
    a stack of signal handlers. You sigchain_push each handler,
    and use sigchain_pop to restore whoever was before you in
    the stack.
    Signed-off-by: Jeff King <>
    Signed-off-by: Junio C Hamano <>
Commits on Dec 21, 2008
  1. @gitster

    Make sure lockfiles are unlocked when dying on SIGPIPE

    gitster authored
    We cleaned up lockfiles upon receiving the usual suspects HUP, TERM, QUIT
    but a wicked user could kill us of asphyxiation by piping our output to a
    pipe that does not read.  Protect ourselves by catching SIGPIPE and clean
    up the lockfiles as well in such a case.
    Signed-off-by: Junio C Hamano <>
Commits on Oct 19, 2008
  1. @gitster

    Enhance hold_lock_file_for_{update,append}() API

    gitster authored
    This changes the "die_on_error" boolean parameter to a mere "flags", and
    changes the existing callers of hold_lock_file_for_update/append()
    functions to pass LOCK_DIE_ON_ERROR.
    Signed-off-by: Junio C Hamano <>
Commits on May 31, 2008
  1. @bonzini @gitster

    rollback lock files on more signals than just SIGINT

    bonzini authored gitster committed
    Other signals are also common, for example SIGTERM and SIGHUP.
    This patch modifies the lock file mechanism to catch more signals.
    It also modifies http-push.c which was missing SIGTERM.
    Signed-off-by: Paolo Bonzini <>
    Signed-off-by: Junio C Hamano <>
Commits on May 25, 2008
  1. @gitster

    Merge branch 'db/clone-in-c'

    gitster authored
    * db/clone-in-c:
      Add test for cloning with "--reference" repo being a subset of source repo
      Add a test for another combination of --reference
      Test that --reference actually suppresses fetching referenced objects
      clone: fall back to copying if hardlinking fails
      builtin-clone.c: Need to closedir() in copy_or_link_directory()
      builtin-clone: fix initial checkout
      Build in clone
      Provide API access to init_db()
      Add a function to set a non-default work tree
      Allow for having for_each_ref() list extra refs
      Have a constant extern refspec for "--tags"
      Add a library function to add an alternate to the alternates file
      Add a lockfile function to append to a file
      Mark the list of refs to fetch as const
  2. @drizzd @gitster

    Reset the signal being handled

    drizzd authored gitster committed
    This did not cause any problems, because remove_lock_file_on_signal is
    only registered for SIGINT.
    Signed-off-by: Clemens Buchacher <>
    Signed-off-by: Junio C Hamano <>
Commits on May 5, 2008
  1. @gitster

    Add a lockfile function to append to a file

    Daniel Barkalow authored gitster committed
    This takes care of copying the original contents into the replacement
    file after the lock is held, so that concurrent additions can't miss
    each other's changes.
    [jc: munged to drop mmap in favor of copy_file.]
    Signed-off-by: Daniel Barkalow <>
    Signed-off-by: Junio C Hamano <>
Commits on Jan 16, 2008
  1. @gitster

    close_lock_file(): new function in the lockfile API

    Brandon Casey authored gitster committed
    The lockfile API is a handy way to obtain a file that is cleaned
    up if you die().  But sometimes you would need this sequence to
     1. hold_lock_file_for_update() to get a file descriptor for
     2. write the contents out, without being able to decide if the
        results should be committed or rolled back;
     3. do something else that makes the decision --- and this
        "something else" needs the lockfile not to have an open file
        descriptor for writing (e.g. Windows do not want a open file
        to be renamed);
     4. call commit_lock_file() or rollback_lock_file() as
    This adds close_lock_file() you can call between step 2 and 3 in
    the above sequence.
    Signed-off-by: Junio C Hamano <>
Commits on Nov 26, 2007
  1. @sprohaska @gitster

    Use is_absolute_path() in diff-lib.c, lockfile.c, setup.c, trace.c

    sprohaska authored gitster committed
    Using the helper function to test for absolute paths makes porting easier.
    Signed-off-by: Steffen Prohaska <>
    Signed-off-by: Junio C Hamano <>
Commits on Nov 14, 2007
  1. @dscho @gitster

    Close files opened by lock_file() before unlinking.

    dscho authored gitster committed
    This is needed on Windows since open files cannot be unlinked.
    Signed-off-by: Johannes Sixt <>
    Signed-off-by: Junio C Hamano <>
Commits on Jul 27, 2007
  1. @gitster

    fully resolve symlinks when creating lockfiles

    Bradford C. Smith authored gitster committed
    Make the code for resolving symlinks in lockfile.c more robust as
    1. Handle relative symlinks
    2. recursively resolve symlink chains up to 5
    [jc: removed lstat/stat calls to do things stupid way]
    Signed-off-by: Bradford C. Smith <>
    Signed-off-by: Junio C Hamano <>
Commits on Jul 25, 2007
  1. @gitster

    When locking in a symlinked repository, try to lock the original.

    gitster authored
    In a working tree prepared in new-workdir (in contrib/), some files in .git/
    directory are symbolic links to the original repository.  The usual sequence of
    lock-write-rename would break the symbolic link.
    Ideally we should resolve relative symbolic link with maxdepth, but I do not
    want to risk too elaborate patch before 1.5.3 release, so this is a minimum
    and trivially obvious fix.  new-workdir creates its symbolic links absolute,
    and does not link from a symlinked workdir, so this fix should suffice for now.
    Signed-off-by: Junio C Hamano <>
Commits on Jul 13, 2007
  1. @gitster

    lockfile.c: schedule remove_lock_file only once.

    Sven Verdoolaege authored gitster committed
    Removing a lockfile once should be enough.
    Signed-off-by: Sven Verdoolaege <>
    Signed-off-by: Junio C Hamano <>
Commits on Jun 7, 2007
  1. @gitster

    War on whitespace

    gitster authored
    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 <>
Commits on Apr 21, 2007
  1. lockfile: record the primary process.

    Junio C Hamano authored
    The usual process flow is the main process opens and holds the lock to
    the index, does its thing, perhaps spawning children during the course,
    and then writes the resulting index out by releaseing the lock.
    However, the lockfile interface uses atexit(3) to clean it up, without
    regard to who actually created the lock.  This typically leads to a
    confusing behaviour of lock being released too early when the child
    exits, and then the parent process when it calls commit_lockfile()
    finds that it cannot unlock it.
    This fixes the problem by recording who created and holds the lock, and
    upon atexit(3) handler, child simply ignores the lockfile the parent
    Signed-off-by: Junio C Hamano <>
Commits on Apr 4, 2007
  1. git-read-tree --index-output=<file>

    Junio C Hamano authored
    This corrects the interface mistake of the previous one, and
    gives a command line parameter to the only plumbing command that
    currently needs it: "git-read-tree".
    We can add the calls to set_alternate_index_output() to other
    plumbing commands that update the index if/when needed.
    Signed-off-by: Junio C Hamano <>
  2. _GIT_INDEX_OUTPUT: allow plumbing to output to an alternative index f…

    Junio C Hamano authored
    When defined, this allows plumbing commands that update the
    index (add, apply, checkout-index, merge-recursive, mv,
    read-tree, rm, update-index, and write-tree) to write their
    resulting index to an alternative index file while holding a
    lock to the original index file.  With this, git-commit that
    jumps the index does not have to make an extra copy of the index
    file, and more importantly, it can do the update while holding
    the lock on the index.
    However, I think the interface to let an environment variable
    specify the output is a mistake, as shown in the documentation.
    If a curious user has the environment variable set to something
    other than the file GIT_INDEX_FILE points at, almost everything
    will break.  This should instead be a command line parameter to
    tell these plumbing commands to write the result in the named
    file, to prevent stupid mistakes.
    Signed-off-by: Junio C Hamano <>
Commits on Jan 6, 2007
  1. Print a more accurate error message when we fail to create a lock file.

    Steven Grimm authored Junio C Hamano committed
    Signed-off-by: Steven Grimm <>
    Signed-off-by: Junio C Hamano <>
Commits on Jan 5, 2007
  1. Merge branch 'maint'

    Junio C Hamano authored
    * maint:
      pack-check.c::verify_packfile(): don't run SHA-1 update on huge data
      Fix infinite loop when deleting multiple packed refs.
Commits on Jan 3, 2007
  1. Fix infinite loop when deleting multiple packed refs.

    Junio C Hamano authored
    It was stupid to link the same element twice to lock_file_list
    and end up in a loop, so we certainly need a fix.
    But it is not like we are taking a lock on multiple files in
    this case.  It is just that we leave the linked element on the
    list even after commit_lock_file() successfully removes the
    We cannot remove the list element in commit_lock_file(); if we
    are interrupted in the middle of list manipulation, the call to
    remove_lock_file_on_signal() will happen with a broken list
    structure pointed by lock_file_list, which would cause the cruft
    to remain, so not removing the list element is the right thing
    to do.  Instead we should be reusing the element already on the
    There is already a code for that in lock_file() function in
    lockfile.c.  The code checks lk->next and the element is linked
    only when it is not already on the list -- which is incorrect
    for the last element on the list (which has NULL in its next
    field), but if you read the check as "is this element already on
    the list?" it actually makes sense.  We do not want to link it
    on the list again, nor we would want to set up signal/atexit
    over and over.
    Signed-off-by: Junio C Hamano <>
Commits on Dec 20, 2006
  1. simplify inclusion of system header files.

    Junio C Hamano authored
    This is a mechanical clean-up of the way *.c files include
    system header files.
     (1) sources under compat/, platform sha-1 implementations, and
         xdelta code are exempt from the following rules;
     (2) the first #include must be "git-compat-util.h" or one of
         our own header file that includes it first (e.g. config.h,
         builtin.h, pkt-line.h);
     (3) system headers that are included in "git-compat-util.h"
         need not be included in individual C source files.
     (4) "git-compat-util.h" does not have to include subsystem
         specific header files (e.g. expat.h).
    Signed-off-by: Junio C Hamano <>
Commits on Aug 13, 2006
  1. Better error message when we are unable to lock the index file

    Junio C Hamano authored
    Most of the callers except the one in refs.c use the function to
    update the index file.  Among the index writers, everybody
    except write-tree dies if they cannot open it for writing.
    This gives the function an extra argument, to tell it to die
    when it cannot create a new file as the lockfile.
    The only caller that does not have to die is write-tree, because
    updating the index for the cache-tree part is optional and not
    being able to do so does not affect the correctness.  I think we
    do not have to be so careful and make the failure into die() the
    same way as other callers, but that would be a different patch.
    Signed-off-by: Junio C Hamano <>
Commits on Jun 10, 2006
  1. shared repository - add a few missing calls to adjust_shared_perm().

    Junio C Hamano authored
    There were a few calls to adjust_shared_perm() that were
     - init-db creates refs, refs/heads, and refs/tags before
       reading from templates that could specify sharedrepository in
       the config file;
     - updating config file created it under user's umask without
     - updating refs created it under user's umask without
     - switching branches created .git/HEAD under user's umask
       without adjusting.
    This moves adjust_shared_perm() from sha1_file.c to path.c,
    since a few SIMPLE_PROGRAM need to call repository configuration
    functions which in turn need to call adjust_shared_perm().
    sha1_file.c needs to link with SHA1 computation library which
    is usually not linked to SIMPLE_PROGRAM.
    Signed-off-by: Junio C Hamano <>
Commits on Jun 6, 2006
  1. Make index file locking code reusable to others.

    Junio C Hamano authored
    The framework to create lockfiles that are removed at exit is
    first used to reliably write the index file, but it is
    applicable to other things, so stop calling it "cache_file".
    This also rewords a few remaining error message that called the
    index file "cache file".
    Signed-off-by: Junio C Hamano <>
Something went wrong with that request. Please try again.