1. 18 4月, 2013 1 次提交
  2. 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
  3. 16 11月, 2012 2 次提交
    • J
      ident: keep separate "explicit" flags for author and committer · d6991cee
      Jeff King 提交于
      We keep track of whether the user ident was given to us
      explicitly, or if we guessed at it from system parameters
      like username and hostname. However, we kept only a single
      variable. This covers the common cases (because the author
      and committer will usually come from the same explicit
      source), but can miss two cases:
      
        1. GIT_COMMITTER_* is set explicitly, but we fallback for
           GIT_AUTHOR. We claim the ident is explicit, even though
           the author is not.
      
        2. GIT_AUTHOR_* is set and we ask for author ident, but
           not committer ident. We will claim the ident is
           implicit, even though it is explicit.
      
      This patch uses two variables instead of one, updates both
      when we set the "fallback" values, and updates them
      individually when we read from the environment.
      
      Rather than keep user_ident_sufficiently_given as a
      compatibility wrapper, we update the only two callers to
      check the committer_ident, which matches their intent and
      what was happening already.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d6991cee
    • J
      ident: make user_ident_explicitly_given static · 45280230
      Jeff King 提交于
      In v1.5.6-rc0~56^2 (2008-05-04) "user_ident_explicitly_given"
      was introduced as a global for communication between config,
      ident, and builtin-commit.  In v1.7.0-rc0~72^2 (2010-01-07)
      readers switched to using the common wrapper
      user_ident_sufficiently_given().  After v1.7.11-rc1~15^2~18
      (2012-05-21), the var is only written in ident.c.
      
      Now we can make it static, which will enable further
      refactoring without worrying about upsetting other code.
      Signed-off-by: NJeff King <peff@peff.net>
      Reviewed-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      45280230
  4. 29 10月, 2012 4 次提交
  5. 16 9月, 2012 4 次提交
  6. 14 8月, 2012 1 次提交
    • J
      parse_feature_request: make it easier to see feature values · 94427108
      Jeff King 提交于
      We already take care to parse key/value capabilities like
      "foo=bar", but the code does not provide a good way of
      actually finding out what is on the right-hand side of the
      "=".
      
      A server using "parse_feature_request" could accomplish this
      with some extra parsing. You must skip past the "key"
      portion manually, check for "=" versus NUL or space, and
      then find the length by searching for the next space (or
      NUL).  But clients can't even do that, since the
      "server_supports" interface does not even return the
      pointer.
      
      Instead, let's have our parser share more information by
      providing a pointer to the value and its length. The
      "parse_feature_value" function returns a pointer to the
      feature's value portion, along with the length of the value.
      If the feature is missing, NULL is returned. If it does not
      have an "=", then a zero-length value is returned.
      
      Similarly, "server_feature_value" behaves in the same way,
      but always checks the static server_feature_list variable.
      
      We can then implement "server_supports" in terms of
      "server_feature_value". We cannot implement the original
      "parse_feature_request" in terms of our new function,
      because it returned a pointer to the beginning of the
      feature. However, no callers actually cared about the value
      of the returned pointer, so we can simplify it to a boolean
      just as we do for "server_supports".
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      94427108
  7. 30 7月, 2012 1 次提交
  8. 12 7月, 2012 1 次提交
    • T
      Strip namelen out of ce_flags into a ce_namelen field · b60e188c
      Thomas Gummerer 提交于
      Strip the name length from the ce_flags field and move it
      into its own ce_namelen field in struct cache_entry. This
      will both give us a tiny bit of a performance enhancement
      when working with long pathnames and is a refactoring for
      more readability of the code.
      
      It enhances readability, by making it more clear what
      is a flag, and where the length is stored and make it clear
      which functions use stages in comparisions and which only
      use the length.
      
      It also makes CE_NAMEMASK private, so that users don't
      mistakenly write the name length in the flags.
      Signed-off-by: NThomas Gummerer <t.gummerer@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b60e188c
  9. 10 7月, 2012 5 次提交
    • J
      rev-parse --disambiguate=<prefix> · 957d7406
      Junio C Hamano 提交于
      The new option allows you to feed an ambiguous prefix and enumerate
      all the objects that share it as a prefix of their object names.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      957d7406
    • J
      sha1_name.c: add support for disambiguating other types · daba53ae
      Junio C Hamano 提交于
      This teaches the revision parser that in "$name:$path" (used for a
      blob object name), "$name" must be a tree-ish.
      
      There are many more places where we know what types of objects are
      called for.  This patch adds support for "commit", "treeish", "tree",
      and "blob", which could be used in the following contexts:
      
       - "git apply --build-fake-ancestor" reads the "index" lines from
         the patch; they must name blob objects (not even "blob-ish");
      
       - "git commit-tree" reads a tree object name (not "tree-ish"), and
         zero or more commit object names (not "committish");
      
       - "git reset $rev" wants a committish; "git reset $rev -- $path"
         wants a treeish.
      
      They will come in later patches in the series.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      daba53ae
    • J
      sha1_name.c: introduce get_sha1_committish() · cd74e473
      Junio C Hamano 提交于
      Many callers know that the user meant to name a committish by
      syntactical positions where the object name appears.  Calling this
      function allows the machinery to disambiguate shorter-than-unique
      abbreviated object names between committish and others.
      
      Note that this does NOT error out when the named object is not a
      committish. It is merely to give a hint to the disambiguation
      machinery.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      cd74e473
    • J
      sha1_name.c: teach lookup context to get_sha1_with_context() · 33bd598c
      Junio C Hamano 提交于
      The function takes user input string and returns the object name
      (binary SHA-1) with mode bits and path when the object was looked
      up in a tree.
      
      Additionally give hints to help disambiguation of abbreviated object
      names when the caller knows what it is looking for.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      33bd598c
    • J
      sha1_name.c: many short names can only be committish · e2643617
      Junio C Hamano 提交于
      We know that the token "$name" that appear in "$name^{commit}",
      "$name^4", "$name~4" etc. can only name a committish (either a
      commit or a tag that peels to a commit).  Teach get_short_sha1() to
      take advantage of that knowledge when disambiguating an abbreviated
      SHA-1 given as an object name.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      e2643617
  10. 09 7月, 2012 1 次提交
    • T
      git on Mac OS and precomposed unicode · 76759c7d
      Torsten Bögershausen 提交于
      Mac OS X mangles file names containing unicode on file systems HFS+,
      VFAT or SAMBA.  When a file using unicode code points outside ASCII
      is created on a HFS+ drive, the file name is converted into
      decomposed unicode and written to disk. No conversion is done if
      the file name is already decomposed unicode.
      
      Calling open("\xc3\x84", ...) with a precomposed "Ä" yields the same
      result as open("\x41\xcc\x88",...) with a decomposed "Ä".
      
      As a consequence, readdir() returns the file names in decomposed
      unicode, even if the user expects precomposed unicode.  Unlike on
      HFS+, Mac OS X stores files on a VFAT drive (e.g. an USB drive) in
      precomposed unicode, but readdir() still returns file names in
      decomposed unicode.  When a git repository is stored on a network
      share using SAMBA, file names are send over the wire and written to
      disk on the remote system in precomposed unicode, but Mac OS X
      readdir() returns decomposed unicode to be compatible with its
      behaviour on HFS+ and VFAT.
      
      The unicode decomposition causes many problems:
      
      - The names "git add" and other commands get from the end user may
        often be precomposed form (the decomposed form is not easily input
        from the keyboard), but when the commands read from the filesystem
        to see what it is going to update the index with already is on the
        filesystem, readdir() will give decomposed form, which is different.
      
      - Similarly "git log", "git mv" and all other commands that need to
        compare pathnames found on the command line (often but not always
        precomposed form; a command line input resulting from globbing may
        be in decomposed) with pathnames found in the tree objects (should
        be precomposed form to be compatible with other systems and for
        consistency in general).
      
      - The same for names stored in the index, which should be
        precomposed, that may need to be compared with the names read from
        readdir().
      
      NFS mounted from Linux is fully transparent and does not suffer from
      the above.
      
      As Mac OS X treats precomposed and decomposed file names as equal,
      we can
      
       - wrap readdir() on Mac OS X to return the precomposed form, and
      
       - normalize decomposed form given from the command line also to the
         precomposed form,
      
      to ensure that all pathnames used in Git are always in the
      precomposed form.  This behaviour can be requested by setting
      "core.precomposedunicode" configuration variable to true.
      
      The code in compat/precomposed_utf8.c implements basically 4 new
      functions: precomposed_utf8_opendir(), precomposed_utf8_readdir(),
      precomposed_utf8_closedir() and precompose_argv().  The first three
      are to wrap opendir(3), readdir(3), and closedir(3) functions.
      
      The argv[] conversion allows to use the TAB filename completion done
      by the shell on command line.  It tolerates other tools which use
      readdir() to feed decomposed file names into git.
      
      When creating a new git repository with "git init" or "git clone",
      "core.precomposedunicode" will be set "false".
      
      The user needs to activate this feature manually.  She typically
      sets core.precomposedunicode to "true" on HFS and VFAT, or file
      systems mounted via SAMBA.
      Helped-by: NJunio C Hamano <gitster@pobox.com>
      Signed-off-by: NTorsten Bögershausen <tboegi@web.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      76759c7d
  11. 04 7月, 2012 4 次提交
  12. 03 7月, 2012 1 次提交
  13. 26 6月, 2012 1 次提交
  14. 23 6月, 2012 1 次提交
  15. 19 6月, 2012 1 次提交
    • M
      verify_filename(): ask the caller to chose the kind of diagnosis · 023e37c3
      Matthieu Moy 提交于
      verify_filename() can be called in two different contexts. Either we
      just tried to interpret a string as an object name, and it fails, so
      we try looking for a working tree file (i.e. we finished looking at
      revs that come earlier on the command line, and the next argument
      must be a pathname), or we _know_ that we are looking for a
      pathname, and shouldn't even try interpreting the string as an
      object name.
      
      For example, with this change, we get:
      
        $ git log COPYING HEAD:inexistant
        fatal: HEAD:inexistant: no such path in the working tree.
        Use '-- <path>...' to specify paths that do not exist locally.
        $ git log HEAD:inexistant
        fatal: Path 'inexistant' does not exist in 'HEAD'
      Signed-off-by: NMatthieu Moy <Matthieu.Moy@imag.fr>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      023e37c3
  16. 25 5月, 2012 2 次提交
    • J
      ident: rename IDENT_ERROR_ON_NO_NAME to IDENT_STRICT · f9bc573f
      Jeff King 提交于
      Callers who ask for ERROR_ON_NO_NAME are not so much
      concerned that the name will be blank (because, after all,
      we will fall back to using the username), but rather it is a
      check to make sure that low-quality identities do not end up
      in things like commit messages or emails (whereas it is OK
      for them to end up in things like reflogs).
      
      When future commits add more quality checks on the identity,
      each of these callers would want to use those checks, too.
      Rather than modify each of them later to add a new flag,
      let's refactor the flag.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f9bc573f
    • J
      ident: let callers omit name with fmt_indent · c15e1987
      Jeff King 提交于
      Most callers want to see all of "$name <$email> $date", but
      a few want only limited parts, omitting the date, or even
      the name. We already have IDENT_NO_DATE to handle the date
      part, but there's not a good option for getting just the
      email. Callers have to done one of:
      
        1. Call ident_default_email; this does not respect
           environment variables, nor does it promise to trim
           whitespace or other crud from the result.
      
        2. Call git_{committer,author}_info; this returns the name
           and email, leaving the caller to parse out the wanted
           bits.
      
      This patch adds IDENT_NO_NAME; it stops short of adding
      IDENT_NO_EMAIL, as no callers want it (nor are likely to),
      and it complicates the error handling of the function.
      
      When no name is requested, the angle brackets (<>) around
      the email address are also omitted.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c15e1987
  17. 23 5月, 2012 4 次提交
  18. 15 5月, 2012 1 次提交
  19. 25 4月, 2012 2 次提交
  20. 06 4月, 2012 1 次提交
    • J
      run-command: treat inaccessible directories as ENOENT · 38f865c2
      Jeff King 提交于
      When execvp reports EACCES, it can be one of two things:
      
        1. We found a file to execute, but did not have
           permissions to do so.
      
        2. We did not have permissions to look in some directory
           in the $PATH.
      
      In the former case, we want to consider this a
      permissions problem and report it to the user as such (since
      getting this for something like "git foo" is likely a
      configuration error).
      
      In the latter case, there is a good chance that the
      inaccessible directory does not contain anything of
      interest. Reporting "permission denied" is confusing to the
      user (and prevents our usual "did you mean...?" lookup). It
      also prevents git from trying alias lookup, since we do so
      only when an external command does not exist (not when it
      exists but has an error).
      
      This patch detects EACCES from execvp, checks whether we are
      in case (2), and if so converts errno to ENOENT. This
      behavior matches that of "bash" (but not of simpler shells
      that use execvp more directly, like "dash").
      
      Test stolen from Junio.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      38f865c2
  21. 05 4月, 2012 1 次提交