1. 16 4月, 2012 1 次提交
    • C
      properly keep track of current working directory · 2565b43b
      Clemens Buchacher 提交于
      Various failure modes in the repository detection code path currently
      quote the wrong directory in their error message. The working directory
      is changed iteratively to the parent directory until a git repository is
      found. If the working directory cannot be changed to the parent
      directory for some reason, the detection gives up and prints an error
      message. The error message should report the current working directory.
      
      Instead of continually updating the 'cwd' variable, which is actually
      used to remember the original working directory, the 'offset' variable
      is used to keep track of the current working directory. At the point
      where the affected error handling code is called, 'offset' already
      points to the end of the parent of the working directory, rather than
      the current working directory.
      
      Fix this by explicitly using a variable 'offset_parent' and update
      'offset' concurrently with the call to chdir.
      
      In a similar fashion, the function get_device_or_die() would print the
      original working directory in case of a failure, rather than the current
      working directory. Fix this as well by making use of the 'offset'
      variable.
      
      Lastly, replace the phrase 'mount parent' with 'mount point'. The former
      appears to be a typo.
      Signed-off-by: NClemens Buchacher <drizzd@aon.at>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2565b43b
  2. 03 2月, 2012 1 次提交
    • J
      standardize and improve lookup rules for external local repos · b3256eb8
      Jeff King 提交于
      When you specify a local repository on the command line of
      clone, ls-remote, upload-pack, receive-pack, or upload-archive,
      or in a request to git-daemon, we perform a little bit of
      lookup magic, doing things like looking in working trees for
      .git directories and appending ".git" for bare repos.
      
      For clone, this magic happens in get_repo_path. For
      everything else, it happens in enter_repo. In both cases,
      there are some ambiguous or confusing cases that aren't
      handled well, and there is one case that is not handled the
      same by both methods.
      
      This patch tries to provide (and test!) standard, sensible
      lookup rules for both code paths. The intended changes are:
      
        1. When looking up "foo", we have always preferred
           a working tree "foo" (containing "foo/.git" over the
           bare "foo.git". But we did not prefer a bare "foo" over
           "foo.git". With this patch, we do so.
      
        2. We would select directories that existed but didn't
           actually look like git repositories. With this patch,
           we make sure a selected directory looks like a git
           repo. Not only is this more sensible in general, but it
           will help anybody who is negatively affected by change
           (1) negatively (e.g., if they had "foo.git" next to its
           separate work tree "foo", and expect to keep finding
           "foo.git" when they reference "foo").
      
        3. The enter_repo code path would, given "foo", look for
           "foo.git/.git" (i.e., do the ".git" append magic even
           for a repo with working tree). The clone code path did
           not; with this patch, they now behave the same.
      
      In the unlikely case of a working tree overlaying a bare
      repo (i.e., a ".git" directory _inside_ a bare repo), we
      continue to treat it as a working tree (prefering the
      "inner" .git over the bare repo). This is mainly because the
      combination seems nonsensical, and I'd rather stick with
      existing behavior on the off chance that somebody is relying
      on it.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b3256eb8
  3. 13 9月, 2011 1 次提交
  4. 07 9月, 2011 2 次提交
  5. 23 8月, 2011 1 次提交
  6. 17 8月, 2011 1 次提交
  7. 12 8月, 2011 1 次提交
    • D
      Reduce parse-options.o dependencies · 06876284
      Dmitry Ivankov 提交于
      Currently parse-options.o pulls quite a big bunch of dependencies.
      his complicates it's usage in contrib/ because it pulls external
      dependencies and it also increases executables size.
      
      Split off less generic and more internal to git part of
      parse-options.c to parse-options-cb.c.
      
      Move prefix_filename function from setup.c to abspath.c. abspath.o
      and wrapper.o pull each other, so it's unlikely to increase the
      dependencies. It was a dependency of parse-options.o that pulled
      many others.
      
      Now parse-options.o pulls just abspath.o, ctype.o, strbuf.o, usage.o,
      wrapper.o, libc directly and strlcpy.o indirectly.
      Signed-off-by: NDmitry Ivankov <divanorama@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      06876284
  8. 03 8月, 2011 1 次提交
    • C
      commit: allow partial commits with relative paths · 8894d535
      Clemens Buchacher 提交于
      In order to do partial commits, git-commit overlays a tree on the
      cache and checks pathspecs against the result. Currently, the
      overlaying is done using "prefix" which prevents relative pathspecs
      with ".." and absolute pathspec from matching when they refer to
      files not under "prefix" and absent from the index, but still in
      the tree (i.e.  files staged for removal).
      
      The point of providing a prefix at all is performance optimization.
      If we say there is no common prefix for the files of interest, then
      we have to read the entire tree into the index.
      
      But even if we cannot use the working directory as a prefix, we can
      still figure out if there is a common prefix for all given paths,
      and use that instead. The pathspec_prefix() routine from ls-files.c
      does exactly that.
      
      Any use of global variables is removed from pathspec_prefix() so
      that it can be called from commit.c.
      Reported-by: NReuben Thomas <rrt@sc3d.org>
      Analyzed-by: NMichael J Gruber <git@drmicha.warpmail.net>
      Signed-off-by: NClemens Buchacher <drizzd@aon.at>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      8894d535
  9. 27 5月, 2011 2 次提交
  10. 18 5月, 2011 1 次提交
  11. 11 5月, 2011 4 次提交
    • J
      rev/path disambiguation: further restrict "misspelled index entry" diag · 0e539dca
      Junio C Hamano 提交于
      A colon followed by anything !isalnum() (e.g. ":/heh") at this point is
      known not to be an existing rev.  Just give a generic "neither a rev nor
      a path" error message.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      0e539dca
    • J
      fix overslow :/no-such-string-ever-existed diagnostics · 2e83b66c
      Junio C Hamano 提交于
      "git cmd :/no-such-string-ever-existed" runs an extra round of get_sha1()
      since 009fee47 (Detailed diagnosis when parsing an object name fails.,
      2009-12-07).  Once without error diagnosis to see there is no commit with
      such a string in the log message (hence "it cannot be a ref"), and after
      seeing that :/no-such-string-ever-existed is not a filename (hence "it
      cannot be a path, either"), another time to give "better diagnosis".
      
      The thing is, the second time it runs, we already know that traversing the
      history all the way down to the root will _not_ find any matching commit.
      
      Rename misguided "gently" parameter, which is turned off _only_ when the
      "detailed diagnosis" codepath knows that it cannot be a ref and making the
      call only for the caller to die with a message.  Flip its meaning (and
      adjust the callers) and call it "only_to_die", which is not a great name,
      but it describes far more clearly what the codepaths that switches their
      behaviour based on this variable do.
      
      On my box, the command spends ~1.8 seconds without the patch to make the
      report; with the patch it spends ~1.12 seconds.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2e83b66c
    • J
      pathspec: drop "lone : means no pathspec" from get_pathspec() · b060ce7d
      Junio C Hamano 提交于
      We may want to give the pathspec subsystem such a feature, but not while
      we are still using get_pathspec() that returns a stupid "char **" that
      loses subtle nuances that existed in the input string.
      
      In the meantime, the callers of get_pathspec() that want to support it
      could do an equivalent before feeding their argv[] to the function
      themselves quite easily.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b060ce7d
    • J
      Revert "magic pathspec: add ":(icase)path" to match case insensitively" · 6d942927
      Junio C Hamano 提交于
      This reverts commit d0546e2d, which
      was only meant to be a Proof-of-concept used during the discussion.
      
      The real implementation of the feature needs to wait until we migrate
      all the code to use "struct pathspec", not "char **", to represent
      richer semantics given to pathspec.
      6d942927
  12. 09 4月, 2011 2 次提交
    • J
    • J
      magic pathspec: futureproof shorthand form · 2f6c9760
      Junio C Hamano 提交于
      The earlier design was to take whatever non-alnum that the short format
      parser happens to support, leaving the rest as part of the pattern, so a
      version of git that knows '*' magic and a version that does not would have
      behaved differently when given ":*Makefile".  The former would have
      applied the '*' magic to the pattern "Makefile", while the latter would
      used no magic to the pattern "*Makefile".
      
      Instead, just reserve all non-alnum ASCII letters that are neither glob
      nor regexp special as potential magic signature, and when we see a magic
      that is not supported, die with an error message, just like the longhand
      codepath does.
      
      With this, ":%#!*Makefile" will always mean "%#!" magic applied to the
      pattern "*Makefile", no matter what version of git is used (it is a
      different matter if the version of git supports all of these three magic
      matching rules).
      
      Also make ':' without anything else to mean "there is no pathspec".  This
      would allow differences between "git log" and "git log ." run from the top
      level of the working tree (the latter simplifies no-op commits away from
      the history) to be expressed from a subdirectory by saying "git log :".
      Helped-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2f6c9760
  13. 07 4月, 2011 1 次提交
    • J
      magic pathspec: add tentative ":/path/from/top/level" pathspec support · 8a42c985
      Junio C Hamano 提交于
      Support ":/" magic string that can be prefixed to a pathspec element to
      say "this names the path from the top-level of the working tree", when
      you are in the subdirectory.
      
      For example, you should be able to say:
      
          $ edit Makefile ;# top-level
          $ cd Documentation
          $ edit git.txt ;# in the subdirectory
      
      and then do one of three things, still inside the subdirectory:
      
          $ git add -u .  ;# add only Documentation/git.txt
          $ git add -u :/ ;# add everything, including paths outside Documentation
          $ git add -u    ;# whatever the default setting is.
      
      To truly support magic pathspec, the API needs to be restructured so that
      get_pathspec() and init_pathspec() are unified into one call.  Currently,
      the former just prefixes the user supplied pathspec with the current
      subdirectory path, and the latter takes the output from the former and
      pre-parses them into a bit richer structure for easier handling.  They
      should become a single API function that takes the current subdirectory
      path and the remainder of argv[] (after parsing --options and revision
      arguments from the command line) and returns an array of parsed pathspec
      elements, and "magic" should become attributes of struct pathspec_item.
      
      This patch implements only "top" magic because it can be hacked into the
      system without such a refactoring.
      
      The syntax for magic pathspec prefix is designed to be extensible yet
      simple to type to invoke a simple magic like "from the top".  The parser
      for the magic prefix is hooked into get_pathspec() function in this patch,
      and it needs to be moved when we refactor the API.
      
      But we have to start from somewhere.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      8a42c985
  14. 29 3月, 2011 1 次提交
  15. 18 3月, 2011 1 次提交
  16. 22 1月, 2011 1 次提交
    • J
      Subject: setup: officially support --work-tree without --git-dir · 4868b2ea
      Jonathan Nieder 提交于
      The original intention of --work-tree was to allow people to work in a
      subdirectory of their working tree that does not have an embedded .git
      directory.  Because their working tree, which their $cwd was in, did not
      have an embedded .git, they needed to use $GIT_DIR to specify where it is,
      and because this meant there was no way to discover where the root level
      of the working tree was, so we needed to add $GIT_WORK_TREE to tell git
      where it was.
      
      However, this facility has long been (mis)used by people's scripts to
      start git from a working tree _with_ an embedded .git directory, let git
      find .git directory, and then pretend as if an unrelated directory were
      the associated working tree of the .git directory found by the discovery
      process.  It happens to work in simple cases, and is not worth causing
      "regression" to these scripts.
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4868b2ea
  17. 05 1月, 2011 1 次提交
  18. 28 12月, 2010 1 次提交
  19. 23 12月, 2010 5 次提交
  20. 08 12月, 2010 2 次提交
  21. 19 10月, 2010 1 次提交
  22. 12 8月, 2010 1 次提交
    • N
      setup: remember whether repository was found · a60645f9
      Nguyễn Thái Ngọc Duy 提交于
      As v1.7.2~16^2 (git --paginate: paginate external commands
      again, 2010-07-14) explains, builtins (like git config) that
      do not use RUN_SETUP are not finding GIT_DIR set correctly when
      it is time to launch the pager from run_builtin().  If they
      were to search for a repository sooner, then the outcome of such
      early repository accesses would be more predictable and reliable.
      
      The cmd_*() functions learn whether a repository was found through the
      *nongit_ok return value from setup_git_directory_gently().  If
      run_builtin() is to take care of the repository search itself, that
      datum needs to be retrievable from somewhere else.  Use the
      startup_info struct for this.
      
      As a bonus, this information becomes available to functions such as
      git_config() which might want to avoid trying to access a repository
      when none is present.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a60645f9
  23. 05 8月, 2010 2 次提交
  24. 26 7月, 2010 5 次提交