Sync with v1.8.4.2
authorJunio C Hamano <gitster@pobox.com>
Mon, 28 Oct 2013 17:51:53 +0000 (10:51 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 28 Oct 2013 17:51:53 +0000 (10:51 -0700)
1  2 
Documentation/git.txt
sha1_file.c
t/test-lib.sh
diff --combined Documentation/git.txt
index 4f7e07f2e0f4f6317c81467f7f880b4113b12de1,90c5f37cebd043d2c8cc43a65d99f7b08f63383b..824a179a965ba419492840afb55d1d55e038ed0e
@@@ -9,7 -9,7 +9,7 @@@ git - the stupid content tracke
  SYNOPSIS
  --------
  [verse]
 -'git' [--version] [--help] [-c <name>=<value>]
 +'git' [--version] [--help] [-C <path>] [-c <name>=<value>]
      [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
      [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
      [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
@@@ -43,9 -43,10 +43,10 @@@ unreleased) version of Git, that is ava
  branch of the `git.git` repository.
  Documentation for older releases are available here:
  
- * link:v1.8.4.1/git.html[documentation for release 1.8.4.1]
+ * link:v1.8.4.2/git.html[documentation for release 1.8.4.2]
  
  * release notes for
+   link:RelNotes/1.8.4.2.txt[1.8.4.2],
    link:RelNotes/1.8.4.1.txt[1.8.4.1],
    link:RelNotes/1.8.4.txt[1.8.4].
  
@@@ -396,20 -397,6 +397,20 @@@ displayed. See linkgit:git-help[1] for 
  because `git --help ...` is converted internally into `git
  help ...`.
  
 +-C <path>::
 +      Run as if git was started in '<path>' instead of the current working
 +      directory.  When multiple `-C` options are given, each subsequent
 +      non-absolute `-C <path>` is interpreted relative to the preceding `-C
 +      <path>`.
 ++
 +This option affects options that expect path name like `--git-dir` and
 +`--work-tree` in that their interpretations of the path names would be
 +made relative to the working directory caused by the `-C` option. For
 +example the following invocations are equivalent:
 +
 +    git --git-dir=a.git --work-tree=b -C c status
 +    git --git-dir=c/a.git --work-tree=c/b status
 +
  -c <name>=<value>::
        Pass a configuration parameter to the command. The value
        given will override values from configuration files.
        linkgit:git-replace[1] for more information.
  
  --literal-pathspecs::
 -      Treat pathspecs literally, rather than as glob patterns. This is
 -      equivalent to setting the `GIT_LITERAL_PATHSPECS` environment
 +      Treat pathspecs literally (i.e. no globbing, no pathspec magic).
 +      This is equivalent to setting the `GIT_LITERAL_PATHSPECS` environment
        variable to `1`.
  
 +--glob-pathspecs::
 +      Add "glob" magic to all pathspec. This is equivalent to setting
 +      the `GIT_GLOB_PATHSPECS` environment variable to `1`. Disabling
 +      globbing on individual pathspecs can be done using pathspec
 +      magic ":(literal)"
 +
 +--noglob-pathspecs::
 +      Add "literal" magic to all pathspec. This is equivalent to setting
 +      the `GIT_NOGLOB_PATHSPECS` environment variable to `1`. Enabling
 +      globbing on individual pathspecs can be done using pathspec
 +      magic ":(glob)"
 +
 +--icase-pathspecs::
 +      Add "icase" magic to all pathspec. This is equivalent to setting
 +      the `GIT_ICASE_PATHSPECS` environment variable to `1`.
  
  GIT COMMANDS
  ------------
@@@ -853,7 -825,7 +854,7 @@@ for further details
  'GIT_FLUSH'::
        If this environment variable is set to "1", then commands such
        as 'git blame' (in incremental mode), 'git rev-list', 'git log',
 -      'git check-attr', 'git check-ignore', and 'git whatchanged' will
 +      'git check-attr' and 'git check-ignore' will
        force a flush of the output stream after each record have been
        flushed. If this
        variable is set to "0", the output of these commands will be done
@@@ -897,28 -869,6 +898,28 @@@ GIT_LITERAL_PATHSPECS:
        literal paths to Git (e.g., paths previously given to you by
        `git ls-tree`, `--raw` diff output, etc).
  
 +GIT_GLOB_PATHSPECS::
 +      Setting this variable to `1` will cause Git to treat all
 +      pathspecs as glob patterns (aka "glob" magic).
 +
 +GIT_NOGLOB_PATHSPECS::
 +      Setting this variable to `1` will cause Git to treat all
 +      pathspecs as literal (aka "literal" magic).
 +
 +GIT_ICASE_PATHSPECS::
 +      Setting this variable to `1` will cause Git to treat all
 +      pathspecs as case-insensitive.
 +
 +'GIT_REFLOG_ACTION'::
 +      When a ref is updated, reflog entries are created to keep
 +      track of the reason why the ref was updated (which is
 +      typically the name of the high-level command that updated
 +      the ref), in addition to the old and new values of the ref.
 +      A scripted Porcelain command can use set_reflog_action
 +      helper function in `git-sh-setup` to set its name to this
 +      variable when it is invoked as the top level command by the
 +      end user, to be recorded in the body of the reflog.
 +
  
  Discussion[[Discussion]]
  ------------------------
diff --combined sha1_file.c
index f80bbe467437a4ffc161a4cdd09f97cf5436d4f9,613839db544dc852ee49d026bb1b561e6e1ce4bf..7dadd04cb75a9f681cab17f616600cf437fe82ba
@@@ -614,7 -614,7 +614,7 @@@ static void scan_windows(struct packed_
        }
  }
  
 -static int unuse_one_window(struct packed_git *current, int keep_fd)
 +static int unuse_one_window(struct packed_git *current)
  {
        struct packed_git *p, *lru_p = NULL;
        struct pack_window *lru_w = NULL, *lru_l = NULL;
                pack_mapped -= lru_w->len;
                if (lru_l)
                        lru_l->next = lru_w->next;
 -              else {
 +              else
                        lru_p->windows = lru_w->next;
 -                      if (!lru_p->windows && lru_p->pack_fd != -1
 -                              && lru_p->pack_fd != keep_fd) {
 -                              close(lru_p->pack_fd);
 -                              pack_open_fds--;
 -                              lru_p->pack_fd = -1;
 -                      }
 -              }
                free(lru_w);
                pack_open_windows--;
                return 1;
        return 0;
  }
  
 -void release_pack_memory(size_t need, int fd)
 +void release_pack_memory(size_t need)
  {
        size_t cur = pack_mapped;
 -      while (need >= (cur - pack_mapped) && unuse_one_window(NULL, fd))
 +      while (need >= (cur - pack_mapped) && unuse_one_window(NULL))
                ; /* nothing */
  }
  
@@@ -651,7 -658,7 +651,7 @@@ void *xmmap(void *start, size_t length
        if (ret == MAP_FAILED) {
                if (!length)
                        return NULL;
 -              release_pack_memory(length, fd);
 +              release_pack_memory(length);
                ret = mmap(start, length, prot, flags, fd, offset);
                if (ret == MAP_FAILED)
                        die_errno("Out of memory? mmap failed");
@@@ -675,83 -682,6 +675,83 @@@ void close_pack_windows(struct packed_g
        }
  }
  
 +/*
 + * The LRU pack is the one with the oldest MRU window, preferring packs
 + * with no used windows, or the oldest mtime if it has no windows allocated.
 + */
 +static void find_lru_pack(struct packed_git *p, struct packed_git **lru_p, struct pack_window **mru_w, int *accept_windows_inuse)
 +{
 +      struct pack_window *w, *this_mru_w;
 +      int has_windows_inuse = 0;
 +
 +      /*
 +       * Reject this pack if it has windows and the previously selected
 +       * one does not.  If this pack does not have windows, reject
 +       * it if the pack file is newer than the previously selected one.
 +       */
 +      if (*lru_p && !*mru_w && (p->windows || p->mtime > (*lru_p)->mtime))
 +              return;
 +
 +      for (w = this_mru_w = p->windows; w; w = w->next) {
 +              /*
 +               * Reject this pack if any of its windows are in use,
 +               * but the previously selected pack did not have any
 +               * inuse windows.  Otherwise, record that this pack
 +               * has windows in use.
 +               */
 +              if (w->inuse_cnt) {
 +                      if (*accept_windows_inuse)
 +                              has_windows_inuse = 1;
 +                      else
 +                              return;
 +              }
 +
 +              if (w->last_used > this_mru_w->last_used)
 +                      this_mru_w = w;
 +
 +              /*
 +               * Reject this pack if it has windows that have been
 +               * used more recently than the previously selected pack.
 +               * If the previously selected pack had windows inuse and
 +               * we have not encountered a window in this pack that is
 +               * inuse, skip this check since we prefer a pack with no
 +               * inuse windows to one that has inuse windows.
 +               */
 +              if (*mru_w && *accept_windows_inuse == has_windows_inuse &&
 +                  this_mru_w->last_used > (*mru_w)->last_used)
 +                      return;
 +      }
 +
 +      /*
 +       * Select this pack.
 +       */
 +      *mru_w = this_mru_w;
 +      *lru_p = p;
 +      *accept_windows_inuse = has_windows_inuse;
 +}
 +
 +static int close_one_pack(void)
 +{
 +      struct packed_git *p, *lru_p = NULL;
 +      struct pack_window *mru_w = NULL;
 +      int accept_windows_inuse = 1;
 +
 +      for (p = packed_git; p; p = p->next) {
 +              if (p->pack_fd == -1)
 +                      continue;
 +              find_lru_pack(p, &lru_p, &mru_w, &accept_windows_inuse);
 +      }
 +
 +      if (lru_p) {
 +              close(lru_p->pack_fd);
 +              pack_open_fds--;
 +              lru_p->pack_fd = -1;
 +              return 1;
 +      }
 +
 +      return 0;
 +}
 +
  void unuse_pack(struct pack_window **w_cursor)
  {
        struct pack_window *w = *w_cursor;
@@@ -847,7 -777,7 +847,7 @@@ static int open_packed_git_1(struct pac
                        pack_max_fds = 1;
        }
  
 -      while (pack_max_fds <= pack_open_fds && unuse_one_window(NULL, -1))
 +      while (pack_max_fds <= pack_open_fds && close_one_pack())
                ; /* nothing */
  
        p->pack_fd = git_open_noatime(p->pack_name);
@@@ -963,7 -893,7 +963,7 @@@ unsigned char *use_pack(struct packed_g
                        win->len = (size_t)len;
                        pack_mapped += win->len;
                        while (packed_git_limit < pack_mapped
 -                              && unuse_one_window(p, p->pack_fd))
 +                              && unuse_one_window(p))
                                ; /* nothing */
                        win->base = xmmap(NULL, win->len,
                                PROT_READ, MAP_PRIVATE,
@@@ -1009,7 -939,7 +1009,7 @@@ static struct packed_git *alloc_packed_
  
  static void try_to_free_pack_memory(size_t size)
  {
 -      release_pack_memory(size, -1);
 +      release_pack_memory(size);
  }
  
  struct packed_git *add_packed_git(const char *path, int path_len, int local)
@@@ -2126,16 -2056,6 +2126,16 @@@ void *unpack_entry(struct packed_git *p
                int i;
                struct delta_base_cache_entry *ent;
  
 +              ent = get_delta_base_cache_entry(p, curpos);
 +              if (eq_delta_base_cache_entry(ent, p, curpos)) {
 +                      type = ent->type;
 +                      data = ent->data;
 +                      size = ent->size;
 +                      clear_delta_base_cache_entry(ent);
 +                      base_from_cache = 1;
 +                      break;
 +              }
 +
                if (do_check_packed_object_crc && p->index_version > 1) {
                        struct revindex_entry *revidx = find_pack_revindex(p, obj_offset);
                        unsigned long len = revidx[1].offset - obj_offset;
                        }
                }
  
 -              ent = get_delta_base_cache_entry(p, curpos);
 -              if (eq_delta_base_cache_entry(ent, p, curpos)) {
 -                      type = ent->type;
 -                      data = ent->data;
 -                      size = ent->size;
 -                      clear_delta_base_cache_entry(ent);
 -                      base_from_cache = 1;
 -                      break;
 -              }
 -
                type = unpack_object_header(p, &w_curs, &curpos, &size);
                if (type != OBJ_OFS_DELTA && type != OBJ_REF_DELTA)
                        break;
@@@ -2514,7 -2444,6 +2514,6 @@@ static int sha1_loose_object_info(cons
        return 0;
  }
  
- /* returns enum object_type or negative */
  int sha1_object_info_extended(const unsigned char *sha1, struct object_info *oi)
  {
        struct cached_object *co;
        return 0;
  }
  
+ /* returns enum object_type or negative */
  int sha1_object_info(const unsigned char *sha1, unsigned long *sizep)
  {
        enum object_type type;
diff --combined t/test-lib.sh
index 0fa7dfde7bbf201d4756202f3797854b54030ea8,c5e914a781e7aff82f712cecf2b2320320a0dc44..3dc1792ebc8eac840adad10a189d33225aa9bc32
@@@ -325,7 -325,7 +325,7 @@@ trap 'die' EXI
  . "$TEST_DIRECTORY/test-lib-functions.sh"
  
  # You are not expected to call test_ok_ and test_failure_ directly, use
- # the text_expect_* functions instead.
+ # the test_expect_* functions instead.
  
  test_ok_ () {
        test_success=$(($test_success + 1))
@@@ -700,6 -700,15 +700,6 @@@ test -d "$GIT_BUILD_DIR"/templates/blt 
        error "You haven't built things yet, have you?"
  }
  
 -if test -z "$GIT_TEST_INSTALLED" && test -z "$NO_PYTHON"
 -then
 -      GITPYTHONLIB="$GIT_BUILD_DIR/git_remote_helpers/build/lib"
 -      export GITPYTHONLIB
 -      test -d "$GIT_BUILD_DIR"/git_remote_helpers/build || {
 -              error "You haven't built git_remote_helpers yet, have you?"
 -      }
 -fi
 -
  if ! test -x "$GIT_BUILD_DIR"/test-chmtime
  then
        echo >&2 'You need to build test-chmtime:'