1. 08 2月, 2009 4 次提交
    • J
      Remove unused normalize_absolute_path() · f2a782b8
      Johannes Sixt 提交于
      This function is now superseded by normalize_path_copy().
      Signed-off-by: NJohannes Sixt <j6t@kdbg.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f2a782b8
    • J
      Test and fix normalize_path_copy() · f42302b4
      Johannes Sixt 提交于
      This changes the test-path-utils utility to invoke normalize_path_copy()
      instead of normalize_absolute_path() because the latter is about to be
      removed.
      
      The test cases in t0060 are adjusted in two regards:
      
      - normalize_path_copy() more often leaves a trailing slash in the result.
        This has no negative side effects because the new user of this function,
        longest_ancester_length(), already accounts for this behavior.
      
      - The function can fail.
      
      The tests uncover a flaw in normalize_path_copy(): If there are
      sufficiently many '..' path components so that the root is reached, such as
      in "/d1/s1/../../d2", then the leading slash was lost. This manifested
      itself that (assuming there is a repository at /tmp/foo)
      
        $ git add /d1/../tmp/foo/some-file
      
      reported 'pathspec is outside repository'. This is now fixed.
      
      Moreover, the test case descriptions of t0060 now include the test data and
      expected outcome.
      Signed-off-by: NJohannes Sixt <j6t@kdbg.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f42302b4
    • R
      Fix GIT_CEILING_DIRECTORIES on Windows · 43a7ddb5
      René Scharfe 提交于
      Using git with GIT_CEILING_DIRECTORIES crashed on Windows due to a failed
      assertion in normalize_absolute_path(): This function expects absolute
      paths to start with a slash, while on Windows they can start with a drive
      letter or a backslash.
      
      This fixes it by using the alternative, normalize_path_copy() instead,
      which can handle Windows-style paths just fine.
      
      Secondly, the portability macro PATH_SEP is used instead of expecting
      colons to be used as path list delimiter.
      
      The test script t1504 is also changed to help MSYS's bash recognize some
      program arguments as path list. (MSYS's bash must translate POSIX-style
      path lists to Windows-style path lists, and the heuristic did not catch
      some cases.)
      Signed-off-by: NRene Scharfe <rene.scharfe@lsrfire.ath.cx>
      Signed-off-by: NJohannes Sixt <j6t@kdbg.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      43a7ddb5
    • J
      Move sanitary_path_copy() to path.c and rename it to normalize_path_copy() · f3cad0ad
      Johannes Sixt 提交于
      This function and normalize_absolute_path() do almost the same thing. The
      former already works on Windows, but the latter crashes.
      
      In subsequent changes we will remove normalize_absolute_path(). Here we
      make the replacement function reusable. On the way we rename it to reflect
      that it does some path normalization. Apart from that this is only moving
      around code.
      Signed-off-by: NJohannes Sixt <j6t@kdbg.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f3cad0ad
  2. 29 1月, 2009 1 次提交
    • J
      validate_headref: tighten ref-matching to just branches · b229d18a
      Jeff King 提交于
      When we are trying to determine whether a directory contains
      a git repository, one of the tests we do is to check whether
      HEAD is either a symlink or a symref into the "refs/"
      hierarchy, or a detached HEAD.
      
      We can tighten this a little more, though: a non-detached
      HEAD should always point to a branch (since checking out
      anything else should result in detachment), so it is safe to
      check for "refs/heads/".
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b229d18a
  3. 12 11月, 2008 1 次提交
  4. 02 11月, 2008 1 次提交
  5. 31 10月, 2008 2 次提交
  6. 27 10月, 2008 1 次提交
  7. 12 8月, 2008 1 次提交
  8. 26 7月, 2008 1 次提交
    • J
      Allow add_path() to add non-existent directories to the path · 10c4c881
      Johannes Sixt 提交于
      This function had used make_absolute_path(); but this function dies if
      the directory that contains the entry whose relative path was supplied in
      the argument does not exist. This is a problem if the argument is, for
      example, "../libexec/git-core", and that "../libexec" does not exist.
      
      Since the resolution of symbolic links is not required for elements in
      PATH, we can fall back to using make_nonrelative_path(), which simply
      prepends $PWD to the path.
      
      We have to move make_nonrelative_path() alongside make_absolute_path() in
      abspath.c so that git-shell can be linked. See 5b8e6f85.
      Signed-off-by: NJohannes Sixt <johannes.sixt@telecom.at>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      10c4c881
  9. 12 7月, 2008 1 次提交
    • P
      Fix backwards-incompatible handling of core.sharedRepository · 8c6202d8
      Petr Baudis 提交于
      06cbe855 (Make core.sharedRepository more generic, 2008-04-16) broke the
      traditional setting of core.sharedRepository to true, which was to make
      the repository group writable: with umask 022, it would clear the
      permission bits for 'other'. (umask 002 did not exhibit this behaviour
      since pre-chmod() check in adjust_shared_perm() fails in that case.)
      
      The call to adjust_shared_perm() should only loosen the permission.
      If the user has umask like 022 or 002 that allow others to read, the
      resulting files should be made readable and writable by group, without
      restricting the readability by others.
      
      This patch fixes the adjust_shared_perm() mode tweak based on Junio's
      suggestion and adds the appropriate tests to t/t1301-shared-repo.sh.
      
      Cc: Heikki Orsila <heikki.orsila@iki.fi>
      Signed-off-by: NPetr Baudis <pasky@suse.cz>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      8c6202d8
  10. 28 6月, 2008 1 次提交
    • D
      shrink git-shell by avoiding redundant dependencies · 5b8e6f85
      Dmitry Potapov 提交于
      A lot of modules that have nothing to do with git-shell functionality
      were linked in, bloating git-shell more than 8 times.
      
      This patch cuts off redundant dependencies by:
      1. providing stubs for three functions that make no sense for git-shell;
      2. moving quote_path_fully from environment.c to quote.c to make the
         later self sufficient;
      3. moving make_absolute_path into a new separate file.
      
      The following numbers have been received with the default optimization
      settings on master using GCC 4.1.2:
      
      Before:
         text    data     bss     dec     hex filename
       143915    1348   93168  238431   3a35f git-shell
      
      After:
         text    data     bss     dec     hex filename
        17670     788    8232   26690    6842 git-shell
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      5b8e6f85
  11. 20 6月, 2008 1 次提交
    • L
      Make git_dir a path relative to work_tree in setup_work_tree() · 044bbbcb
      Linus Torvalds 提交于
      Once we find the absolute paths for git_dir and work_tree, we can make
      git_dir a relative path since we know pwd will be work_tree. This should
      save the kernel some time traversing the path to work_tree all the time
      if git_dir is inside work_tree.
      
      Daniel's patch didn't apply for me as-is, so I recreated it with some
      differences, and here are the numbers from ten runs each.
      
      There is some IO for me - probably due to more-or-less random flushing of
      the journal - so the variation is bigger than I'd like, but whatever:
      
      	Before:
      		real    0m8.135s
      		real    0m7.933s
      		real    0m8.080s
      		real    0m7.954s
      		real    0m7.949s
      		real    0m8.112s
      		real    0m7.934s
      		real    0m8.059s
      		real    0m7.979s
      		real    0m8.038s
      
      	After:
      		real    0m7.685s
      		real    0m7.968s
      		real    0m7.703s
      		real    0m7.850s
      		real    0m7.995s
      		real    0m7.817s
      		real    0m7.963s
      		real    0m7.955s
      		real    0m7.848s
      		real    0m7.969s
      
      Now, going by "best of ten" (on the assumption that the longer numbers
      are all due to IO), I'm saying a 7.933s -> 7.685s reduction, and it does
      seem to be outside of the noise (ie the "after" case never broke 8s, while
      the "before" case did so half the time).
      
      So looks like about 3% to me.
      
      Doing it for a slightly smaller test-case (just the "arch" subdirectory)
      gets more stable numbers probably due to not filling the journal with
      metadata updates, so we have:
      
      	Before:
      		real    0m1.633s
      		real    0m1.633s
      		real    0m1.633s
      		real    0m1.632s
      		real    0m1.632s
      		real    0m1.630s
      		real    0m1.634s
      		real    0m1.631s
      		real    0m1.632s
      		real    0m1.632s
      
      	After:
      		real    0m1.610s
      		real    0m1.609s
      		real    0m1.610s
      		real    0m1.608s
      		real    0m1.607s
      		real    0m1.610s
      		real    0m1.609s
      		real    0m1.611s
      		real    0m1.608s
      		real    0m1.611s
      
      where I'ld just take the averages and say 1.632 vs 1.610, which is just
      over 1% peformance improvement.
      
      So it's not in the noise, but it's not as big as I initially thought and
      measured.
      
      (That said, it obviously depends on how deep the working directory path is
      too, and whether it is behind NFS or something else that might need to
      cause more work to look up).
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      044bbbcb
  12. 09 6月, 2008 1 次提交
  13. 07 6月, 2008 1 次提交
  14. 24 5月, 2008 2 次提交
  15. 30 4月, 2008 1 次提交
  16. 17 4月, 2008 1 次提交
    • H
      Make core.sharedRepository more generic · 06cbe855
      Heikki Orsila 提交于
      git init --shared=0xxx, where '0xxx' is an octal number, will create
      a repository with file modes set to '0xxx'. Users with a safe umask
      value (0077) can use this option to force file modes. For example,
      '0640' is a group-readable but not group-writable regardless of
      user's umask value. Values compatible with old Git versions are written
      as they were before, for compatibility reasons. That is, "1" for
      "group" and "2" for "everybody".
      
      "git config core.sharedRepository 0xxx" is also handled.
      Signed-off-by: NHeikki Orsila <heikki.orsila@iki.fi>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      06cbe855
  17. 06 3月, 2008 1 次提交
  18. 02 3月, 2008 1 次提交
  19. 01 8月, 2007 1 次提交
  20. 26 7月, 2007 1 次提交
  21. 02 7月, 2007 1 次提交
  22. 08 3月, 2007 1 次提交
    • S
      General const correctness fixes · 3a55602e
      Shawn O. Pearce 提交于
      We shouldn't attempt to assign constant strings into char*, as the
      string is not writable at runtime.  Likewise we should always be
      treating unsigned values as unsigned values, not as signed values.
      
      Most of these are very straightforward.  The only exception is the
      (unnecessary) xstrdup/free in builtin-branch.c for the detached
      head case.  Since this is a user-level interactive type program
      and that particular code path is executed no more than once, I feel
      that the extra xstrdup call is well worth the easy elimination of
      this warning.
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      3a55602e
  23. 09 1月, 2007 1 次提交
  24. 08 1月, 2007 1 次提交
    • J
      Detached HEAD (experimental) · c847f537
      Junio C Hamano 提交于
      This allows "git checkout v1.4.3" to dissociate the HEAD of
      repository from any branch.  After this point, "git branch"
      starts reporting that you are not on any branch.  You can go
      back to an existing branch by saying "git checkout master", for
      example.
      
      This is still experimental.  While I think it makes sense to
      allow commits on top of detached HEAD, it is rather dangerous
      unless you are careful in the current form.  Next "git checkout
      master" will obviously lose what you have done, so we might want
      to require "git checkout -f" out of a detached HEAD if we find
      that the HEAD commit is not an ancestor of any other branches.
      There is no such safety valve implemented right now.
      
      On the other hand, the reason the user did not start the ad-hoc
      work on a new branch with "git checkout -b" was probably because
      the work was of a throw-away nature, so the convenience of not
      having that safety valve might be even better.  The user, after
      accumulating some commits on top of a detached HEAD, can always
      create a new branch with "git checkout -b" not to lose useful
      work done while the HEAD was detached.
      
      We'll see.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      c847f537
  25. 21 12月, 2006 1 次提交
    • J
      simplify inclusion of system header files. · 85023577
      Junio C Hamano 提交于
      This is a mechanical clean-up of the way *.c files include
      system header files.
      
       (1) sources under compat/, platform sha-1 implementations, and
           xdelta code are exempt from the following rules;
      
       (2) the first #include must be "git-compat-util.h" or one of
           our own header file that includes it first (e.g. config.h,
           builtin.h, pkt-line.h);
      
       (3) system headers that are included in "git-compat-util.h"
           need not be included in individual C source files.
      
       (4) "git-compat-util.h" does not have to include subsystem
           specific header files (e.g. expat.h).
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      85023577
  26. 06 11月, 2006 1 次提交
  27. 16 9月, 2006 1 次提交
    • L
      Allow multiple "git_path()" uses · e7676d2f
      Linus Torvalds 提交于
      This allows you to maintain a few filesystem pathnames concurrently, by
      simply replacing the single static "pathname" buffer with a LRU of four
      buffers.
      
      We did exactly the same thing with sha1_to_hex(), for pretty much exactly
      the same reason. Sometimes you want to use two pathnames, and while it's
      easy enough to xstrdup() them, why not just do the LU buffer thing.
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      e7676d2f
  28. 25 6月, 2006 1 次提交
  29. 17 6月, 2006 1 次提交
  30. 10 6月, 2006 2 次提交
    • J
      shared repository: optionally allow reading to "others". · 94df2506
      Junio C Hamano 提交于
      This enhances core.sharedrepository to have additionally
      specify that read and exec permissions to be given to others as
      well.  It is useful when serving a repository via gitweb and
      git-daemon that runs as a user outside the project group.
      
      The configuration item can take the following values:
      
          [core]
      	sharedrepository 	 ; the same as "group"
      	sharedrepository = true  ; ditto
      	sharedrepository = 1	 ; ditto
      	sharedrepository = group ; allow rwx to group
      	sharedrepository = all   ; allow rwx to group, allow rx to other
      	sharedrepository = umask ; not shared - use umask
      
      It also extends "git init-db" to take "--shared=all" and friends
      from the command line.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      94df2506
    • J
      shared repository - add a few missing calls to adjust_shared_perm(). · 138086a7
      Junio C Hamano 提交于
      There were a few calls to adjust_shared_perm() that were
      missing:
      
       - init-db creates refs, refs/heads, and refs/tags before
         reading from templates that could specify sharedrepository in
         the config file;
      
       - updating config file created it under user's umask without
         adjusting;
      
       - updating refs created it under user's umask without
         adjusting;
      
       - switching branches created .git/HEAD under user's umask
         without adjusting.
      
      This moves adjust_shared_perm() from sha1_file.c to path.c,
      since a few SIMPLE_PROGRAM need to call repository configuration
      functions which in turn need to call adjust_shared_perm().
      sha1_file.c needs to link with SHA1 computation library which
      is usually not linked to SIMPLE_PROGRAM.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      138086a7
  31. 04 12月, 2005 1 次提交
    • J
      [PATCH] daemon.c and path.enter_repo(): revamp path validation. · d79374c7
      Junio C Hamano 提交于
      The whitelist of git-daemon is checked against return value from
      enter_repo(), and enter_repo() used to return the value obtained
      from getcwd() to avoid directory aliasing issues as discussed
      earier (mid October 2005).
      
      Unfortunately, it did not go well as we hoped.
      
      For example, /pub on a kernel.org public machine is a symlink to
      its real mountpoint, and it is understandable that the
      administrator does not want to adjust the whitelist every time
      /pub needs to point at a different partition for storage
      allcation or whatever reasons.  Being able to keep using
      /pub/scm as the whitelist is a desirable property.
      
      So this version of enter_repo() reports what it used to chdir()
      and validate, but does not use getcwd() to canonicalize the
      directory name.  When it sees a user relative path ~user/path,
      it internally resolves it to try chdir() there, but it still
      reports ~user/path (possibly after appending .git if allowed to
      do so, in which case it would report ~user/path.git).
      
      What this means is that if a whitelist wants to allow a user
      relative path, it needs to say "~" (for all users) or list user
      home directories like "~alice" "~bob".  And no, you cannot say
      /home if the advertised way to access user home directories are
      ~alice,~bob, etc.  The whole point of this is to avoid
      unnecessary aliasing issues.
      
      Anyway, because of this, daemon needs to do a bit more work to
      guard itself.  Namely, it needs to make sure that the accessor
      does not try to exploit its leading path match rule by inserting
      /../ in the middle or hanging /.. at the end.  I resurrected the
      belts and suspender paranoia code HPA did for this purpose.
      
      This check cannot be done in the enter_repo() unconditionally,
      because there are valid callers of enter_repo() that want to
      honor /../; authorized users coming over ssh to run send-pack
      and fetch-pack should be allowed to do so.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      d79374c7
  32. 27 11月, 2005 1 次提交
  33. 21 11月, 2005 2 次提交