1. 04 9月, 2013 1 次提交
  2. 30 7月, 2013 1 次提交
  3. 18 7月, 2013 1 次提交
  4. 13 7月, 2013 3 次提交
    • J
      sha1_object_info_extended: make type calculation optional · 5b086407
      Jeff King 提交于
      Each caller of sha1_object_info_extended sets up an
      object_info struct to tell the function which elements of
      the object it wants to get. Until now, getting the type of
      the object has always been required (and it is returned via
      the return type rather than a pointer in object_info).
      
      This can involve actually opening a loose object file to
      determine its type, or following delta chains to determine a
      packed file's base type. These effects produce a measurable
      slow-down when doing a "cat-file --batch-check" that does
      not include %(objecttype).
      
      This patch adds a "typep" query to struct object_info, so
      that it can be optionally queried just like size and
      disk_size. As a result, the return type of the function is
      no longer the object type, but rather 0/-1 for success/error.
      
      As there are only three callers total, we just fix up each
      caller rather than keep a compatibility wrapper:
      
        1. The simpler sha1_object_info wrapper continues to
           always ask for and return the type field.
      
        2. The istream_source function wants to know the type, and
           so always asks for it.
      
        3. The cat-file batch code asks for the type only when
           %(objecttype) is part of the format string.
      
      On linux.git, the best-of-five for running:
      
        $ git rev-list --objects --all >objects
        $ time git cat-file --batch-check='%(objectsize:disk)'
      
      on a fully packed repository goes from:
      
        real    0m8.680s
        user    0m8.160s
        sys     0m0.512s
      
      to:
      
        real    0m7.205s
        user    0m6.580s
        sys     0m0.608s
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      5b086407
    • J
      cat-file: disable object/refname ambiguity check for batch mode · 25fba78d
      Jeff King 提交于
      A common use of "cat-file --batch-check" is to feed a list
      of objects from "rev-list --objects" or a similar command.
      In this instance, all of our input objects are 40-byte sha1
      ids. However, cat-file has always allowed arbitrary revision
      specifiers, and feeds the result to get_sha1().
      
      Fortunately, get_sha1() recognizes a 40-byte sha1 before
      doing any hard work trying to look up refs, meaning this
      scenario should end up spending very little time converting
      the input into an object sha1. However, since 798c35fc
      (get_sha1: warn about full or short object names that look
      like refs, 2013-05-29), when we encounter this case, we
      spend the extra effort to do a refname lookup anyway, just
      to print a warning. This is further exacerbated by ca919930
      (get_packed_ref_cache: reload packed-refs file when it
      changes, 2013-06-20), which makes individual ref lookup more
      expensive by requiring a stat() of the packed-refs file for
      each missing ref.
      
      With no patches, this is the time it takes to run:
      
        $ git rev-list --objects --all >objects
        $ time git cat-file --batch-check='%(objectname)' <objects
      
      on the linux.git repository:
      
        real    1m13.494s
        user    0m25.924s
        sys     0m47.532s
      
      If we revert ca919930, the packed-refs up-to-date check, it
      gets a little better:
      
        real    0m54.697s
        user    0m21.692s
        sys     0m32.916s
      
      but we are still spending quite a bit of time on ref lookup
      (and we would not want to revert that patch, anyway, which
      has correctness issues).  If we revert 798c35fc, disabling
      the warning entirely, we get a much more reasonable time:
      
        real    0m7.452s
        user    0m6.836s
        sys     0m0.608s
      
      This patch does the moral equivalent of this final case (and
      gets similar speedups). We introduce a global flag that
      callers of get_sha1() can use to avoid paying the price for
      the warning.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      25fba78d
    • H
      teach config --blob option to parse config from database · 1bc88819
      Heiko Voigt 提交于
      This can be used to read configuration values directly from git's
      database. For example it is useful for reading to be checked out
      .gitmodules files directly from the database.
      Signed-off-by: NHeiko Voigt <hvoigt@hvoigt.net>
      Acked-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      1bc88819
  5. 10 7月, 2013 1 次提交
    • N
      Convert "struct cache_entry *" to "const ..." wherever possible · 9c5e6c80
      Nguyễn Thái Ngọc Duy 提交于
      I attempted to make index_state->cache[] a "const struct cache_entry **"
      to find out how existing entries in index are modified and where. The
      question I have is what do we do if we really need to keep track of on-disk
      changes in the index. The result is
      
       - diff-lib.c: setting CE_UPTODATE
      
       - name-hash.c: setting CE_HASHED
      
       - preload-index.c, read-cache.c, unpack-trees.c and
         builtin/update-index: obvious
      
       - entry.c: write_entry() may refresh the checked out entry via
         fill_stat_cache_info(). This causes "non-const struct cache_entry
         *" in builtin/apply.c, builtin/checkout-index.c and
         builtin/checkout.c
      
       - builtin/ls-files.c: --with-tree changes stagemask and may set
         CE_UPDATE
      
      Of these, write_entry() and its call sites are probably most
      interesting because it modifies on-disk info. But this is stat info
      and can be retrieved via refresh, at least for porcelain
      commands. Other just uses ce_flags for local purposes.
      
      So, keeping track of "dirty" entries is just a matter of setting a
      flag in index modification functions exposed by read-cache.c. Except
      unpack-trees, the rest of the code base does not do anything funny
      behind read-cache's back.
      
      The actual patch is less valueable than the summary above. But if
      anyone wants to re-identify the above sites. Applying this patch, then
      this:
      
          diff --git a/cache.h b/cache.h
          index 430d021..1692891 100644
          --- a/cache.h
          +++ b/cache.h
          @@ -267,7 +267,7 @@ static inline unsigned int canon_mode(unsigned int mode)
           #define cache_entry_size(len) (offsetof(struct cache_entry,name) + (len) + 1)
      
           struct index_state {
          -	struct cache_entry **cache;
          +	const struct cache_entry **cache;
           	unsigned int version;
           	unsigned int cache_nr, cache_alloc, cache_changed;
           	struct string_list *resolve_undo;
      
      will help quickly identify them without bogus warnings.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      9c5e6c80
  6. 08 7月, 2013 1 次提交
    • J
      teach sha1_object_info_extended a "disk_size" query · 161f00e7
      Jeff King 提交于
      Using sha1_object_info_extended, a caller can find out the
      type of an object, its size, and information about where it
      is stored. In addition to the object's "true" size, it can
      also be useful to know the size that the object takes on
      disk (e.g., to generate statistics about which refs consume
      space).
      
      This patch adds a "disk_sizep" field to "struct object_info",
      and fills it in during sha1_object_info_extended if it is
      non-NULL.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      161f00e7
  7. 27 6月, 2013 1 次提交
    • J
      path.c: refactor relative_path(), not only strip prefix · e02ca72f
      Jiang Xin 提交于
      Original design of relative_path() is simple, just strip the prefix
      (*base) from the absolute path (*abs).
      
      In most cases, we need a real relative path, such as: ../foo,
      ../../bar.  That's why there is another reimplementation
      (path_relative()) in quote.c.
      
      Borrow some codes from path_relative() in quote.c to refactor
      relative_path() in path.c, so that it could return real relative
      path, and user can reuse this function without reimplementing
      his/her own.  The function path_relative() in quote.c will be
      substituted, and I would use the new relative_path() function when
      implementing the interactive git-clean later.
      
      Different results for relative_path() before and after this refactor:
      
          abs path  base path  relative (original)  relative (refactor)
          ========  =========  ===================  ===================
          /a/b      /a/b       .                    ./
          /a/b/     /a/b       .                    ./
          /a        /a/b/      /a                   ../
          /         /a/b/      /                    ../../
          /a/c      /a/b/      /a/c                 ../c
          /x/y      /a/b/      /x/y                 ../../x/y
      
          a/b/      a/b/       .                    ./
          a/b/      a/b        .                    ./
          a         a/b        a                    ../
          x/y       a/b/       x/y                  ../../x/y
          a/c       a/b        a/c                  ../c
      
          (empty)   (null)     (empty)              ./
          (empty)   (empty)    (empty)              ./
          (empty)   /a/b       (empty)              ./
          (null)    (null)     (null)               ./
          (null)    (empty)    (null)               ./
          (null)    /a/b       (segfault)           ./
      
      You may notice that return value "." has been changed to "./".
      It is because:
      
       * Function quote_path_relative() in quote.c will show the relative
         path as "./" if abs(in) and base(prefix) are the same.
      
       * Function relative_path() is called only once (in setup.c), and
         it will be OK for the return value as "./" instead of ".".
      Signed-off-by: NJiang Xin <worldhello.net@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      e02ca72f
  8. 21 6月, 2013 2 次提交
  9. 10 6月, 2013 1 次提交
  10. 03 6月, 2013 2 次提交
  11. 13 5月, 2013 1 次提交
    • J
      refactor "ref->merge" flag · 900f2814
      Jeff King 提交于
      Each "struct ref" has a boolean flag that is set by the
      fetch code to determine whether the ref should be marked as
      "not-for-merge" or not when we write it out to FETCH_HEAD.
      
      It would be useful to turn this boolean into a tri-state,
      with the third state meaning "do not bother writing it out
      to FETCH_HEAD at all". That would let us add extra refs to
      the set of refs to be stored (e.g., to store copies of
      things we fetched) without impacting FETCH_HEAD.
      
      This patch turns it into an enum that covers the tri-state
      case, and hopefully makes the code more explicit and easier
      to read.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      900f2814
  12. 18 4月, 2013 3 次提交
  13. 06 4月, 2013 1 次提交
  14. 04 4月, 2013 1 次提交
    • J
      add -u: only show pathless 'add -u' warning when changes exist outside cwd · 71c7b053
      Jonathan Nieder 提交于
      A common workflow in large projects is to chdir into a subdirectory of
      interest and only do work there:
      
      	cd src
      	vi foo.c
      	make test
      	git add -u
      	git commit
      
      The upcoming change to 'git add -u' behavior would not affect such a
      workflow: when the only changes present are in the current directory,
      'git add -u' will add all changes, and whether that happens via an
      implicit "." or implicit ":/" parameter is an unimportant
      implementation detail.
      
      The warning about use of 'git add -u' with no pathspec is annoying
      because it seemingly serves no purpose in this case.  So suppress the
      warning unless there are changes outside the cwd that are not being
      added.
      
      A previous version of this patch ran two I/O-intensive diff-files
      passes: one to find changes outside the cwd, and another to find
      changes to add to the index within the cwd.  This version runs one
      full-tree diff and decides for each change whether to add it or warn
      and suppress it in update_callback.  As a result, even on very large
      repositories "git add -u" will not be significantly slower than the
      future default behavior ("git add -u :/"), and the slowdown relative
      to "git add -u ." should be a useful clue to users of such
      repositories to get into the habit of explicitly passing '.'.
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Acked-by: NJeff King <peff@peff.net>
      Improved-by: NJunio C Hamano <gitster@pobox.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      71c7b053
  15. 27 3月, 2013 1 次提交
    • N
      checkout: avoid unnecessary match_pathspec calls · e721c154
      Nguyễn Thái Ngọc Duy 提交于
      In checkout_paths() we do this
      
       - for all updated items, call match_pathspec
       - for all items, call match_pathspec (inside unmerge_cache)
       - for all items, call match_pathspec (for showing "path .. is unmerged)
       - for updated items, call match_pathspec and update paths
      
      That's a lot of duplicate match_pathspec(s) and the function is not
      exactly cheap to be called so many times, especially on large indexes.
      This patch makes it call match_pathspec once per updated index entry,
      save the result in ce_flags and reuse the results in the following
      loops.
      
      The changes in 0a1283bc (checkout $tree $path: do not clobber local
      changes in $path not in $tree - 2011-09-30) limit the affected paths
      to ones we read from $tree. We do not do anything to other modified
      entries in this case, so the "for all items" above could be modified
      to "for all updated items". But..
      
      The command's behavior now is modified slightly: unmerged entries that
      match $path, but not updated by $tree, are now NOT touched.  Although
      this should be considered a bug fix, not a regression. A new test is
      added for this change.
      
      And while at there, free ps_matched after use.
      
      The following command is tested on webkit, 215k entries. The pattern
      is chosen mainly to make match_pathspec sweat:
      
      git checkout -- "*[a-zA-Z]*[a-zA-Z]*[a-zA-Z]*"
      
              before      after
      real    0m3.493s    0m2.737s
      user    0m2.239s    0m1.586s
      sys     0m1.252s    0m1.151s
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      e721c154
  16. 17 3月, 2013 1 次提交
    • R
      archive-zip: use deflateInit2() to ask for raw compressed data · c3c2e1a0
      René Scharfe 提交于
      We use the function git_deflate_init() -- which wraps the zlib function
      deflateInit() -- to initialize compression of ZIP file entries.  This
      results in compressed data prefixed with a two-bytes long header and
      followed by a four-bytes trailer.  ZIP file entries consist of ZIP
      headers and raw compressed data instead, so we remove the zlib wrapper
      before writing the result.
      
      We can ask zlib for the the raw compressed data without the unwanted
      parts in the first place by using deflateInit2() and specifying a
      negative number of bits to size the window.  For that purpose, factor
      out the function do_git_deflate_init() and add git_deflate_init_raw(),
      which wraps it.  Then use the latter in archive-zip.c and get rid of
      the code that stripped the zlib header and trailer.
      
      Also rename the helper function zlib_deflate() to zlib_deflate_raw()
      to reflect the change.
      
      Thus we avoid generating data that we throw away anyway, the code
      becomes shorter and some magic constants are removed.
      Signed-off-by: NRene Scharfe <rene.scharfe@lsrfire.ath.cx>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c3c2e1a0
  17. 09 3月, 2013 2 次提交
    • J
      setup: suppress implicit "." work-tree for bare repos · 2cd83d10
      Jeff King 提交于
      If an explicit GIT_DIR is given without a working tree, we
      implicitly assume that the current working directory should
      be used as the working tree. E.g.,:
      
        GIT_DIR=/some/repo.git git status
      
      would compare against the cwd.
      
      Unfortunately, we fool this rule for sub-invocations of git
      by setting GIT_DIR internally ourselves. For example:
      
        git init foo
        cd foo/.git
        git status ;# fails, as we expect
        git config alias.st status
        git status ;# does not fail, but should
      
      What happens is that we run setup_git_directory when doing
      alias lookup (since we need to see the config), set GIT_DIR
      as a result, and then leave GIT_WORK_TREE blank (because we
      do not have one). Then when we actually run the status
      command, we do setup_git_directory again, which sees our
      explicit GIT_DIR and uses the cwd as an implicit worktree.
      
      It's tempting to argue that we should be suppressing that
      second invocation of setup_git_directory, as it could use
      the values we already found in memory. However, the problem
      still exists for sub-processes (e.g., if "git status" were
      an external command).
      
      You can see another example with the "--bare" option, which
      sets GIT_DIR explicitly. For example:
      
        git init foo
        cd foo/.git
        git status ;# fails
        git --bare status ;# does NOT fail
      
      We need some way of telling sub-processes "even though
      GIT_DIR is set, do not use cwd as an implicit working tree".
      We could do it by putting a special token into
      GIT_WORK_TREE, but the obvious choice (an empty string) has
      some portability problems.
      
      Instead, we add a new boolean variable, GIT_IMPLICIT_WORK_TREE,
      which suppresses the use of cwd as a working tree when
      GIT_DIR is set. We trigger the new variable when we know we
      are in a bare setting.
      
      The variable is left intentionally undocumented, as this is
      an internal detail (for now, anyway). If somebody comes up
      with a good alternate use for it, and once we are confident
      we have shaken any bugs out of it, we can consider promoting
      it further.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2cd83d10
    • J
      environment: add GIT_PREFIX to local_repo_env · a6f7f9a3
      Jeff King 提交于
      The GIT_PREFIX variable is set based on our location within
      the working tree. It should therefore be cleared whenever
      GIT_WORK_TREE is cleared.
      
      In practice, this doesn't cause any bugs, because none of
      the sub-programs we invoke with local_repo_env cleared
      actually care about GIT_PREFIX. But this is the right thing
      to do, and future proofs us against that assumption changing.
      
      While we're at it, let's define a GIT_PREFIX_ENVIRONMENT
      macro; this avoids repetition of the string literal, which
      can help catch any spelling mistakes in the code.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a6f7f9a3
  18. 08 3月, 2013 1 次提交
    • J
      cache.h: drop LOCAL_REPO_ENV_SIZE · 2163e5db
      Jeff King 提交于
      We keep a static array of variables that should be cleared
      when invoking a sub-process on another repo. We statically
      size the array with the LOCAL_REPO_ENV_SIZE macro so that
      any readers do not have to count it themselves.
      
      As it turns out, no readers actually use the macro, and it
      creates a maintenance headache, as modifications to the
      array need to happen in two places (one to add the new
      element, and another to bump the size).
      
      Since it's NULL-terminated, we can just drop the size macro
      entirely. While we're at it, we'll clean up some comments
      around it, and add a new mention of it at the top of the
      list of environment variable macros. Even though
      local_repo_env is right below that list, it's easy to miss,
      and additions to that list should consider local_repo_env.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2163e5db
  19. 28 2月, 2013 1 次提交
    • K
      name-hash.c: fix endless loop with core.ignorecase=true · 2092678c
      Karsten Blees 提交于
      With core.ignorecase=true, name-hash.c builds a case insensitive index of
      all tracked directories. Currently, the existing cache entry structures are
      added multiple times to the same hashtable (with different name lengths and
      hash codes). However, there's only one dir_next pointer, which gets
      completely messed up in case of hash collisions. In the worst case, this
      causes an endless loop if ce == ce->dir_next (see t7062).
      
      Use a separate hashtable and separate structures for the directory index
      so that each directory entry has its own next pointer. Use reference
      counting to track which directory entry contains files.
      
      There are only slight changes to the name-hash.c API:
      - new free_name_hash() used by read_cache.c::discard_index()
      - remove_name_hash() takes an additional index_state parameter
      - index_name_exists() for a directory (trailing '/') may return a cache
        entry that has been removed (CE_UNHASHED). This is not a problem as the
        return value is only used to check if the directory exists (dir.c) or to
        normalize casing of directory names (read-cache.c).
      
      Getting rid of cache_entry.dir_next reduces memory consumption, especially
      with core.ignorecase=false (which doesn't use that member at all).
      
      With core.ignorecase=true, building the directory index is slightly faster
      as we add / check the parent directory first (instead of going through all
      directory levels for each file in the index). E.g. with WebKit (~200k
      files, ~7k dirs), time spent in lazy_init_name_hash is reduced from 176ms
      to 130ms.
      Signed-off-by: NKarsten Blees <blees@dcon.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2092678c
  20. 24 2月, 2013 1 次提交
  21. 16 2月, 2013 1 次提交
  22. 08 2月, 2013 1 次提交
    • J
      fetch: use struct ref to represent refs to be fetched · f2db854d
      Junio C Hamano 提交于
      Even though "git fetch" has full infrastructure to parse refspecs to
      be fetched and match them against the list of refs to come up with
      the final list of refs to be fetched, the list of refs that are
      requested to be fetched were internally converted to a plain list of
      strings at the transport layer and then passed to the underlying
      fetch-pack driver.
      
      Stop this conversion and instead pass around an array of refs.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f2db854d
  23. 25 1月, 2013 2 次提交
    • J
      push: introduce REJECT_FETCH_FIRST and REJECT_NEEDS_FORCE · 75e5c0dc
      Junio C Hamano 提交于
      When we push to update an existing ref, if:
      
       * the object at the tip of the remote is not a commit; or
       * the object we are pushing is not a commit,
      
      it won't be correct to suggest to fetch, integrate and push again,
      as the old and new objects will not "merge".  We should explain that
      the push must be forced when there is a non-committish object is
      involved in such a case.
      
      If we do not have the current object at the tip of the remote, we do
      not even know that object, when fetched, is something that can be
      merged.  In such a case, suggesting to pull first just like
      non-fast-forward case may not be technically correct, but in
      practice, most such failures are seen when you try to push your work
      to a branch without knowing that somebody else already pushed to
      update the same branch since you forked, so "pull first" would work
      as a suggestion most of the time.  And if the object at the tip is
      not a commit, "pull first" will fail, without making any permanent
      damage.  As a side effect, it also makes the error message the user
      will get during the next "push" attempt easier to understand, now
      the user is aware that a non-commit object is involved.
      
      In these cases, the current code already rejects such a push on the
      client end, but we used the same error and advice messages as the
      ones used when rejecting a non-fast-forward push, i.e. pull from
      there and integrate before pushing again.
      
      Introduce new rejection reasons and reword the messages
      appropriately.
      
      [jc: with help by Peff on message details]
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      75e5c0dc
    • J
      push: further clean up fields of "struct ref" · 5ece083f
      Junio C Hamano 提交于
      The "nonfastforward" and "update" fields are only used while
      deciding what value to assign to the "status" locally in a single
      function.  Remove them from the "struct ref".
      
      The "requires_force" field is not used to decide if the proposed
      update requires a --force option to succeed, or to record such a
      decision made elsewhere.  It is used by status reporting code that
      the particular update was "forced".  Rename it to "forced_update",
      and move the code to assign to it around to further clarify how it
      is used and what it is used for.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      5ece083f
  24. 24 1月, 2013 1 次提交
  25. 23 1月, 2013 1 次提交
    • R
      Enable minimal stat checking · c08e4d5b
      Robin Rosenberg 提交于
      Specifically the fields uid, gid, ctime, ino and dev are set to zero
      by JGit. Other implementations, eg. Git in cygwin are allegedly also
      somewhat incompatible with Git For Windows and on *nix platforms
      the resolution of the timestamps may differ.
      
      Any stat checking by git will then need to check content, which may
      be very slow, particularly on Windows. Since mtime and size
      is typically enough we should allow the user to tell git to avoid
      checking these fields if they are set to zero in the index.
      
      This change introduces a core.checkstat config option where the
      the user can select to check all fields (default), or just size
      and the whole second part of mtime (minimal).
      Signed-off-by: NRobin Rosenberg <robin.rosenberg@dewire.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c08e4d5b
  26. 17 1月, 2013 3 次提交
    • J
      push: fix "refs/tags/ hierarchy cannot be updated without --force" · 256b9d70
      Junio C Hamano 提交于
      When pushing to update a branch with a commit that is not a
      descendant of the commit at the tip, a wrong message "already
      exists" was given, instead of the correct "non-fast-forward", if we
      do not have the object sitting in the destination repository at the
      tip of the ref we are updating.
      
      The primary cause of the bug is that the check in a new helper
      function is_forwardable() assumed both old and new objects are
      available and can be checked, which is not always the case.
      
      The way the caller uses the result of this function is also wrong.
      If the helper says "we do not want to let this push go through", the
      caller unconditionally translates it into "we blocked it because the
      destination already exists", which is not true at all in this case.
      
      Fix this by doing these three things:
      
       * Remove unnecessary not_forwardable from "struct ref"; it is only
         used inside set_ref_status_for_push();
      
       * Make "refs/tags/" the only hierarchy that cannot be replaced
         without --force;
      
       * Remove the misguided attempt to force that everything that
         updates an existing ref has to be a commit outside "refs/tags/"
         hierarchy.
      
      The policy last one tried to implement may later be resurrected and
      extended to ensure fast-forwardness (defined as "not losing
      objects", extending from the traditional "not losing commits from
      the resulting history") when objects that are not commit are
      involved (e.g. an annotated tag in hierarchies outside refs/tags),
      but such a logic belongs to "is this a fast-forward?" check that is
      done by ref_newer(); is_forwardable(), which is now removed, was not
      the right place to do so.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      256b9d70
    • J
      Allow custom "comment char" · eff80a9f
      Junio C Hamano 提交于
      Some users do want to write a line that begin with a pound sign, #,
      in their commit log message.  Many tracking system recognise
      a token of #<bugid> form, for example.
      
      The support we offer these use cases is not very friendly to the end
      users.  They have a choice between
      
       - Don't do it.  Avoid such a line by rewrapping or indenting; and
      
       - Use --cleanup=whitespace but remove all the hint lines we add.
      
      Give them a way to set a custom comment char, e.g.
      
          $ git -c core.commentchar="%" commit
      
      so that they do not have to do either of the two workarounds.
      
      [jc: although I started the topic, all the tests and documentation
      updates, many of the call sites of the new strbuf_add_commented_*()
      functions, and the change to git-submodule.sh scripted Porcelain are
      from Ralf.]
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      Signed-off-by: NRalf Thielow <ralf.thielow@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      eff80a9f
    • M
      fix clang -Wunused-value warnings for error functions · 5ded807f
      Max Horn 提交于
      Commit a469a101 wraps some error calls in macros to give the
      compiler a chance to do more static analysis on their
      constant -1 return value.  We limit the use of these macros
      to __GNUC__, since gcc is the primary beneficiary of the new
      information, and because we use GNU features for handling
      variadic macros.
      
      However, clang also defines __GNUC__, but generates warnings
      with -Wunused-value when these macros are used in a void
      context, because the constant "-1" ends up being useless.
      Gcc does not complain about this case (though it is unclear
      if it is because it is smart enough to see what we are
      doing, or too dumb to realize that the -1 is unused).  We
      can squelch the warning by just disabling these macros when
      clang is in use.
      Signed-off-by: NMax Horn <max@quendi.de>
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      5ded807f
  27. 20 12月, 2012 1 次提交
    • J
      add global --literal-pathspecs option · 823ab40f
      Jeff King 提交于
      Git takes pathspec arguments in many places to limit the
      scope of an operation. These pathspecs are treated not as
      literal paths, but as glob patterns that can be fed to
      fnmatch. When a user is giving a specific pattern, this is a
      nice feature.
      
      However, when programatically providing pathspecs, it can be
      a nuisance. For example, to find the latest revision which
      modified "$foo", one can use "git rev-list -- $foo". But if
      "$foo" contains glob characters (e.g., "f*"), it will
      erroneously match more entries than desired. The caller
      needs to quote the characters in $foo, and even then, the
      results may not be exactly the same as with a literal
      pathspec. For instance, the depth checks in
      match_pathspec_depth do not kick in if we match via fnmatch.
      
      This patch introduces a global command-line option (i.e.,
      one for "git" itself, not for specific commands) to turn
      this behavior off. It also has a matching environment
      variable, which can make it easier if you are a script or
      porcelain interface that is going to issue many such
      commands.
      
      This option cannot turn off globbing for particular
      pathspecs. That could eventually be done with a ":(noglob)"
      magic pathspec prefix. However, that level of granularity is
      more cumbersome to use for many cases, and doing ":(noglob)"
      right would mean converting the whole codebase to use
      "struct pathspec", as the usual "const char **pathspec"
      cannot represent extra per-item flags.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      823ab40f
  28. 16 12月, 2012 1 次提交
    • J
      silence some -Wuninitialized false positives · a469a101
      Jeff King 提交于
      There are a few error functions that simply wrap error() and
      provide a standardized message text. Like error(), they
      always return -1; knowing that can help the compiler silence
      some false positive -Wuninitialized warnings.
      
      One strategy would be to just declare these as inline in the
      header file so that the compiler can see that they always
      return -1. However, gcc does not always inline them (e.g.,
      it will not inline opterror, even with -O3), which renders
      our change pointless.
      
      Instead, let's follow the same route we did with error() in
      the last patch, and define a macro that makes the constant
      return value obvious to the compiler.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a469a101
  29. 13 12月, 2012 1 次提交
  30. 02 12月, 2012 1 次提交