1. 29 10月, 2012 2 次提交
  2. 16 9月, 2012 4 次提交
  3. 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
  4. 30 7月, 2012 1 次提交
  5. 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
  6. 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
  7. 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
  8. 04 7月, 2012 4 次提交
  9. 03 7月, 2012 1 次提交
  10. 26 6月, 2012 1 次提交
  11. 23 6月, 2012 1 次提交
  12. 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
  13. 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
  14. 23 5月, 2012 4 次提交
  15. 15 5月, 2012 1 次提交
  16. 25 4月, 2012 2 次提交
  17. 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
  18. 05 4月, 2012 1 次提交
  19. 04 4月, 2012 1 次提交
    • J
      cache.h: hide on-disk index details · db3b313c
      Junio C Hamano 提交于
      The on-disk format of the index file is a detail whose implementation is
      neatly encapsulated in read-cache.c; there is no need to expose it to the
      general public that include the cache.h header file.
      
      Also add a prominent mark to read-cache.c to delineate the parts that deal
      with the index file I/O routines from the remainder of the file.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      db3b313c
  20. 27 3月, 2012 1 次提交
    • J
      clean up struct ref's nonfastforward field · e339aa92
      Jeff King 提交于
      Each ref structure contains a "nonfastforward" field which
      is set during push to show whether the ref rewound history.
      Originally this was a single bit, but it was changed in
      f25950f3 (push: Provide situational hints for non-fast-forward
      errors) to an enum differentiating a non-ff of the current
      branch versus another branch.
      
      However, we never actually set the member according to the
      enum values, nor did we ever read it expecting anything but
      a boolean value. But we did use the side effect of declaring
      the enum constants to store those values in a totally
      different integer variable. The code as-is isn't buggy, but
      the enum declaration inside "struct ref" is somewhat
      misleading.
      
      Let's convert nonfastforward back into a single bit, and
      then define the NON_FF_* constants closer to where they
      would be used (they are returned via the "int *nonfastforward"
      parameter to transport_push, so we can define them there).
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      e339aa92
  21. 24 3月, 2012 1 次提交
  22. 20 3月, 2012 1 次提交
    • C
      push: Provide situational hints for non-fast-forward errors · f25950f3
      Christopher Tiwald 提交于
      Pushing a non-fast-forward update to a remote repository will result in
      an error, but the hint text doesn't provide the correct resolution in
      every case. Give better resolution advice in three push scenarios:
      
      1) If you push your current branch and it triggers a non-fast-forward
      error, you should merge remote changes with 'git pull' before pushing
      again.
      
      2) If you push to a shared repository others push to, and your local
      tracking branches are not kept up to date, the 'matching refs' default
      will generate non-fast-forward errors on outdated branches. If this is
      your workflow, the 'matching refs' default is not for you. Consider
      setting the 'push.default' configuration variable to 'current' or
      'upstream' to ensure only your current branch is pushed.
      
      3) If you explicitly specify a ref that is not your current branch or
      push matching branches with ':', you will generate a non-fast-forward
      error if any pushed branch tip is out of date. You should checkout the
      offending branch and merge remote changes before pushing again.
      
      Teach transport.c to recognize these scenarios and configure push.c
      to hint for them. If 'git push's default behavior changes or we
      discover more scenarios, extension is easy. Standardize on the
      advice API and add three new advice variables, 'pushNonFFCurrent',
      'pushNonFFDefault', and 'pushNonFFMatching'. Setting any of these
      to 'false' will disable their affiliated advice. Setting
      'pushNonFastForward' to false will disable all three, thus preserving the
      config option for users who already set it, but guaranteeing new
      users won't disable push advice accidentally.
      Based-on-patch-by: NJunio C Hamano <gitster@pobox.com>
      Signed-off-by: NChristopher Tiwald <christiwald@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f25950f3
  23. 11 3月, 2012 1 次提交
    • J
      ident.c: add split_ident_line() to parse formatted ident line · 4b340cfa
      Junio C Hamano 提交于
      The commit formatting logic format_person_part() in pretty.c
      implements the logic to split an author/committer ident line into
      its parts, intermixed with logic to compute its output using these
      piece it computes.
      
      Separate the former out to a helper function split_ident_line() so
      that other codepath can use the same logic, and rewrite the function
      using the helper function.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4b340cfa
  24. 05 3月, 2012 1 次提交
    • R
      ctype.c: Fix a sparse warning · f1589d10
      Ramsay Jones 提交于
      In particular, sparse complains as follows:
      
              SP ctype.c
          ctype.c:30:12: warning: symbol 'tolower_trans_tbl' was not declared.\
               Should it be static?
      
      An appropriate extern declaration for the 'tolower_trans_tbl' symbol
      is included in the "cache.h" header file. In order to suppress the
      warning, therefore, we could replace the "git-compat-util.h" header
      inclusion with "cache.h", since "cache.h" includes "git-compat-util.h"
      in turn. Here, however, we choose to move the extern declaration for
      'tolower_trans_tbl' into "git-compat-util.h", alongside the other
      extern declaration from ctype.c for 'sane_ctype'.
      Signed-off-by: NRamsay Jones <ramsay@ramsay1.demon.co.uk>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f1589d10