Skip to content
Commits on Jan 19, 2010
  1. @pclouds @gitster

    rm: only refresh entries that we may touch

    pclouds committed with gitster Jan 17, 2010
    This gets rid of the whole tree cache refresh. Instead only path that
    we touch will get refreshed. We may still lstat() more than needed,
    but it'd be better playing safe.
    
    This potentially reduces a large number of lstat() on big trees. Take
    gentoo-x86 tree for example, which has roughly 80k files:
    
    Unmodified Git:
    
    $ time git rm --cached skel.ebuild
    rm 'skel.ebuild'
    
    real    0m1.441s
    user    0m0.821s
    sys     0m0.531s
    
    Modified Git:
    
    $ time ~/w/git/git rm --cached skel.ebuild
    rm 'skel.ebuild'
    
    real    0m0.941s
    user    0m0.828s
    sys     0m0.091s
    
    Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Jun 27, 2009
  1. @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 <trast@student.ethz.ch>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on May 25, 2009
  1. @bebarino @gitster

    parse-opts: prepare for OPT_FILENAME

    bebarino committed with gitster May 23, 2009
    To give OPT_FILENAME the prefix, we pass the prefix to parse_options()
    which passes the prefix to parse_options_start() which sets the prefix
    member of parse_opts_ctx accordingly. If there isn't a prefix in the
    calling context, passing NULL will suffice.
    
    Signed-off-by: Stephen Boyd <bebarino@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Mar 24, 2009
  1. @gitster

    builtin-rm: use warning() instead of fprintf(stderr, "warning: ")

    Miklos Vajna committed with gitster Mar 24, 2009
    Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Nov 29, 2008
  1. @gitster

    git add --intent-to-add: fix removal of cached emptiness

    gitster committed Nov 28, 2008
    This uses the extended index flag mechanism introduced earlier to mark
    the entries added to the index via "git add -N" with CE_INTENT_TO_ADD.
    
    The logic to detect an "intent to add" entry for the purpose of allowing
    "git rm --cached $path" is tightened to check not just for a staged empty
    blob, but with the CE_INTENT_TO_ADD bit.  This protects an empty blob that
    was explicitly added and then modified in the work tree from being dropped
    with this sequence:
    
    	$ >empty
    	$ git add empty
    	$ echo "non empty" >empty
    	$ git rm --cached empty
    
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2. @gitster

    builtin-rm.c: explain and clarify the "local change" logic

    gitster committed Nov 28, 2008
    Explain the logic to check local modification a bit more in the comment,
    especially because the existing comment that talks about "git rm --cached"
    was placed in a part that was not about "--cached" at all.
    
    Also clarify "if .. else if .." structure.
    
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Oct 23, 2008
  1. @peff @gitster

    rm: loosen safety valve for empty files

    peff committed with gitster Oct 21, 2008
    If a file is different between the working tree copy, the index, and the
    HEAD, then we do not allow it to be deleted without --force.
    
    However, this is overly tight in the face of "git add --intent-to-add":
    
      $ git add --intent-to-add file
      $ : oops, I don't actually want to stage that yet
      $ git rm --cached file
      error: 'empty' has staged content different from both the
      file and the HEAD (use -f to force removal)
      $ git rm -f --cached file
    
    Unfortunately, there is currently no way to distinguish between an empty
    file that has been added and an "intent to add" file. The ideal behavior
    would be to disallow the former while allowing the latter.
    
    This patch loosens the safety valve to allow the deletion only if we are
    deleting the cached entry and the cached content is empty.  This covers
    the intent-to-add situation, and assumes there is little harm in not
    protecting users who have legitimately added an empty file.  In many
    cases, the file will still be empty, in which case the safety valve does
    not trigger anyway (since the content remains untouched in the working
    tree). Otherwise, we do remove the fact that no content was staged, but
    given that the content is by definition empty, it is not terribly
    difficult for a user to recreate it.
    
    However, we still document the desired behavior in the form of two
    tests. One checks the correct removal of an intent-to-add file. The other
    checks that we still disallow removal of empty files, but is marked as
    expect_failure to indicate this compromise. If the intent-to-add feature
    is ever extended to differentiate between normal empty files and
    intent-to-add files, then the safety valve can be re-tightened.
    
    Signed-off-by: Jeff King <peff@peff.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Oct 8, 2008
  1. @dscho @spearce

    git rm: refresh index before up-to-date check

    dscho committed with spearce Oct 7, 2008
    Since "git rm" is supposed to be porcelain, we should convince it to
    be user friendly by refreshing the index itself.
    
    Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
    Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Commits on Sep 29, 2008
  1. @raalkml @spearce

    Use remove_path from dir.c instead of own implementation

    raalkml committed with spearce Sep 27, 2008
    Besides, it fixes a memleak (builtin-rm.c) and accidental change of
    the input const argument (builtin-merge-recursive.c).
    
    Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
    Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Commits on Sep 16, 2008
  1. @heikkiorsila @gitster

    Start conforming code to "git subcmd" style part 3

    heikkiorsila committed with gitster Sep 13, 2008
    User notifications are presented as 'git cmd', and code comments
    are presented as '"cmd"' or 'git's cmd', rather than 'git-cmd'.
    
    Signed-off-by: Heikki Orsila <heikki.orsila@iki.fi>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
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 <gitster@pobox.com>
Commits on Aug 9, 2008
  1. @pieter @gitster

    builtin-rm: Add a --force flag

    pieter committed with gitster Aug 9, 2008
    This adds a --force flag to git-rm, making it somewhat easier for
    subversion people to switch.
    
    Signed-off-by: Pieter de Bie <pdebie@ai.rug.nl>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Jul 19, 2008
  1. @gitster

    Merge branch 'maint'

    gitster committed Jul 19, 2008
    * maint:
      GIT 1.5.6.4
      builtin-rm: fix index lock file path
      http-fetch: do not SEGV after fetching a bad pack idx file
      rev-list: honor --quiet option
      api-run-command.txt: typofix
  2. @gitster

    builtin-rm: fix index lock file path

    Olivier Marin committed with gitster Jul 19, 2008
    When hold_locked_index() is called with a relative git_dir and you are
    outside the work tree, the lock file become relative to the current
    directory. So when later setup_work_tree() change the current directory
    it breaks lock file path and commit_locked_index() fails.
    
    This patch move index locking code after setup_work_tree() call to make
    lock file relative to the working tree as it should be and add a test
    case.
    
    Noticed by Nick Andrew.
    
    Signed-off-by: Olivier Marin <dkr@freesurf.fr>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Jul 13, 2008
  1. @sbeyer @gitster

    Make usage strings dash-less

    sbeyer committed with gitster Jul 13, 2008
    When you misuse a git command, you are shown the usage string.
    But this is currently shown in the dashed form.  So if you just
    copy what you see, it will not work, when the dashed form
    is no longer supported.
    
    This patch makes git commands show the dash-less version.
    
    For shell scripts that do not specify OPTIONS_SPEC, git-sh-setup.sh
    generates a dash-less usage string now.
    
    Signed-off-by: Stephan Beyer <s-beyer@gmx.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on May 14, 2008
  1. @dscho @gitster

    Provide git_config with a callback-data parameter

    dscho committed with gitster May 14, 2008
    git_config() only had a function parameter, but no callback data
    parameter.  This assumes that all callback functions only modify
    global variables.
    
    With this patch, every callback gets a void * parameter, and it is hoped
    that this will help the libification effort.
    
    Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Jan 16, 2008
  1. @gitster

    Improve use of lockfile API

    Brandon Casey committed with gitster Jan 16, 2008
    Remove remaining double close(2)'s.  i.e. close() before
    commit_locked_index() or commit_lock_file().
    
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Nov 6, 2007
  1. @glandium @gitster

    Don't always require working tree for git-rm

    glandium committed with gitster Nov 3, 2007
    This allows to do git rm --cached -r directory, instead of
    git ls-files -z directory | git update-index --remove -z --stdin.
    This can be particularly useful for git-filter-branch users.
    
    Signed-off-by: Mike Hommey <mh@glandium.org>
    Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Oct 30, 2007
  1. @gitster

    Make builtin-rm.c use parse_options.

    Pierre Habouzit committed with gitster Oct 5, 2007
    Signed-off-by: Pierre Habouzit <madcoder@debian.org>
    Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Commits on Sep 14, 2007
  1. @gitster

    Simplify cache API

    gitster committed Sep 13, 2007
    Earlier, add_file_to_index() invalidated the path in the cache-tree
    but remove_file_from_cache() did not, and the user of the latter
    needed to invalidate the entry himself.  This led to a few bugs due to
    missed invalidate calls already.  This patch makes the management of
    cache-tree less error prone by making more invalidate calls from lower
    level cache API functions.
    
    The rules are:
    
     - If you are going to write the index, you should either maintain
       cache_tree correctly.
    
       - If you cannot, alternatively you can remove the entire cache_tree
         by calling cache_tree_free() before you call write_cache().
    
       - When you modify the index, cache_tree_invalidate_path() should be
         called with the path you are modifying, to discard the entry from
         the cache-tree structure.
    
     - The following cache API functions exported from read-cache.c (and
       the macro whose names have "cache" instead of "index")
       automatically call cache_tree_invalidate_path() for you:
    
       - remove_file_from_index();
       - add_file_to_index();
       - add_index_entry();
    
       You can modify the index bypassing the above API functions
       (e.g. find an existing cache entry from the index and modify it in
       place).  You need to call cache_tree_invalidate_path() yourself in
       such a case.
    
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Jul 14, 2007
  1. @moy @gitster

    More permissive "git-rm --cached" behavior without -f.

    moy committed with gitster Jul 13, 2007
    In the previous behavior, "git-rm --cached" (without -f) had the same
    restriction as "git-rm". This forced the user to use the -f flag in
    situations which weren't actually dangerous, like:
    
    $ git add foo           # oops, I didn't want this
    $ git rm --cached foo   # back to initial situation
    
    Previously, the index had to match the file *and* the HEAD. With
    --cached, the index must now match the file *or* the HEAD. The behavior
    without --cached is unchanged, but provides better error messages.
    
    Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Apr 17, 2007
  1. Add --ignore-unmatch option to exit with zero status when no files ar…

    Steven Grimm committed with Junio C Hamano Apr 16, 2007
    …e removed.
    
    Signed-off-by: Steven Grimm <koreth@midwinter.com>
    Signed-off-by: Junio C Hamano <junkio@cox.net>
Commits on Apr 16, 2007
  1. git-rm: Trivial fix for a comment typo.

    Steven Grimm committed with Junio C Hamano Apr 16, 2007
    Signed-off-by: Steven Grimm <koreth@midwinter.com>
    Signed-off-by: Junio C Hamano <junkio@cox.net>
  2. Add --quiet option to suppress output of "rm" commands for removed fi…

    Steven Grimm committed with Junio C Hamano Apr 16, 2007
    …les.
    
    Signed-off-by: Steven Grimm <koreth@midwinter.com>
    Signed-off-by: Junio C Hamano <junkio@cox.net>
Commits on Apr 4, 2007
  1. _GIT_INDEX_OUTPUT: allow plumbing to output to an alternative index f…

    Junio C Hamano committed Mar 31, 2007
    …ile.
    
    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 <junkio@cox.net>
Commits on Mar 27, 2007
  1. @peff

    git-rm: don't remove newly added file without -f

    peff committed with Junio C Hamano Mar 26, 2007
    Given this set of commands:
    
      $ echo "newly added file" >new
      $ git add new
      $ git rm new
    
    the file "new" was previously removed from the working
    directory and the index. Because it was not in HEAD, it is
    available only by searching for unreachable objects.
    
    Instead, we now err on the safe side and refuse to remove
    a file which is not referenced by HEAD.
    
    Signed-off-by: Jeff King <peff@peff.net>
    Signed-off-by: Junio C Hamano <junkio@cox.net>
Commits on Jan 16, 2007
  1. git-rm documentation: remove broken behaviour from the example.

    Junio C Hamano committed Jan 16, 2007
    The example section were talking about the old broken default
    behaviour.  Correct it.
    
    Signed-off-by: Junio C Hamano <junkio@cox.net>
Commits on Jan 11, 2007
  1. git-rm: do not fail on already removed file.

    Junio C Hamano committed Jan 11, 2007
    Often the user would do "/bin/rm foo" before telling git, but
    then want to tell git about it.  "git rm foo" however would fail
    because it cannot unlink(2) foo.
    
    Treat ENOENT error return from unlink(2) as if a successful
    removal happened.
    
    Signed-off-by: Junio C Hamano <junkio@cox.net>
Commits on Dec 25, 2006
  1. git-rm: update to saner semantics

    Junio C Hamano committed Dec 25, 2006
    This updates the "git rm" command with saner semantics suggested
    on the list earlier with:
    
    	Message-ID: <Pine.LNX.4.64.0612020919400.3476@woody.osdl.org>
    	Message-ID: <Pine.LNX.4.64.0612040737120.3476@woody.osdl.org>
    
    The command still validates that the given paths all talk about
    sensible paths to avoid mistakes (e.g. "git rm fiel" when file
    "fiel" does not exist would error out -- user meant to remove
    "file"), and it has further safety checks described next.  The
    biggest difference is that the paths are removed from both index
    and from the working tree (if you have an exotic need to remove
    paths only from the index, you can use the --cached option).
    
    The command refuses to remove if the copy on the working tree
    does not match the index, or if the index and the HEAD does not
    match.  You can defeat this check with -f option.
    
    This safety check has two exceptions: if the working tree file
    does not exist to begin with, that technically does not match
    the index but it is allowed.  This is to allow this CVS style
    command sequence:
    
    	rm <path> && git rm <path>
    
    Also if the index is unmerged at the <path>, you can use "git rm
    <path>" to declare that the result of the merge loses that path,
    and the above safety check does not trigger; requiring the file
    to match the index in this case forces the user to do "git
    update-index file && git rm file", which is just crazy.
    
    To recursively remove all contents from a directory, you need to
    pass -r option, not just the directory name as the <path>.
    
    Signed-off-by: Junio C Hamano <junkio@cox.net>
Commits on Sep 2, 2006
  1. @spearce

    Replace uses of strdup with xstrdup.

    spearce committed with Junio C Hamano Sep 2, 2006
    Like xmalloc and xrealloc xstrdup dies with a useful message if
    the native strdup() implementation returns NULL rather than a
    valid pointer.
    
    I just tried to use xstrdup in new code and found it to be missing.
    However I expected it to be present as xmalloc and xrealloc are
    already commonly used throughout the code.
    
    [jc: removed the part that deals with last_XXX, which I am
     finding more and more dubious these days.]
    
    Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
    Signed-off-by: Junio C Hamano <junkio@cox.net>
Commits on Aug 13, 2006
  1. Better error message when we are unable to lock the index file

    Junio C Hamano committed Aug 12, 2006
    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 <junkio@cox.net>
Commits on Aug 4, 2006
  1. Further clean-up: usage() vs die()

    Junio C Hamano committed Aug 3, 2006
    This hopefully finishes the clean-up Ramsay started with recent
    commit 15e593e and commit
    8cdf336.
    
    Signed-off-by: Junio C Hamano <junkio@cox.net>
  2. Replace some calls to die(usage_str) with usage(usage_str).

    Ramsay Allan Jones committed with Junio C Hamano Aug 3, 2006
    The only change in behaviour should be having a "usage: " prefix
    on the output string rather than "fatal: ", and an exit code of
    129 rather than 128.
    
    Signed-off-by: Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk>
    Signed-off-by: Junio C Hamano <junkio@cox.net>
Commits on Jul 29, 2006
  1. Call setup_git_directory() much earlier

    Linus Torvalds committed with Junio C Hamano Jul 28, 2006
    This changes the calling convention of built-in commands and
    passes the "prefix" (i.e. pathname of $PWD relative to the
    project root level) down to them.
    
    Signed-off-by: Linus Torvalds <torvalds@osdl.org>
    Signed-off-by: Junio C Hamano <junkio@cox.net>
Commits on Jul 25, 2006
  1. Substitute xmalloc()+memset(0) with xcalloc().

    Peter Eriksen committed with Junio C Hamano Jul 25, 2006
    Signed-off-by: Peter Eriksen <s022018@student.dtu.dk>
    Signed-off-by: Junio C Hamano <junkio@cox.net>
Something went wrong with that request. Please try again.