1. 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
  2. 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
  3. 13 12月, 2012 1 次提交
  4. 02 12月, 2012 4 次提交
  5. 27 11月, 2012 1 次提交
    • N
      pathspec: apply "*.c" optimization from exclude · 8c6abbcd
      Nguyễn Thái Ngọc Duy 提交于
      When a pattern contains only a single asterisk as wildcard,
      e.g. "foo*bar", after literally comparing the leading part "foo" with
      the string, we can compare the tail of the string and make sure it
      matches "bar", instead of running fnmatch() on "*bar" against the
      remainder of the string.
      
      -O2 build on linux-2.6, without the patch:
      
      $ time git rev-list --quiet HEAD -- '*.c'
      
      real    0m40.770s
      user    0m40.290s
      sys     0m0.256s
      
      With the patch
      
      $ time ~/w/git/git rev-list --quiet HEAD -- '*.c'
      
      real    0m34.288s
      user    0m33.997s
      sys     0m0.205s
      
      The above command is not supposed to be widely popular. It's chosen
      because it exercises pathspec matching a lot. The point is it cuts
      down matching time for popular patterns like *.c, which could be used
      as pathspec in other places.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      8c6abbcd
  6. 20 11月, 2012 1 次提交
  7. 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
  8. 29 10月, 2012 4 次提交
  9. 16 9月, 2012 4 次提交
  10. 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
  11. 30 7月, 2012 1 次提交
  12. 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
  13. 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
  14. 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
  15. 04 7月, 2012 4 次提交
  16. 03 7月, 2012 1 次提交
  17. 26 6月, 2012 1 次提交
  18. 23 6月, 2012 1 次提交
  19. 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
  20. 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
  21. 23 5月, 2012 2 次提交