1. 05 7月, 2007 1 次提交
    • J
      Do not check if getcwd() result begins with a slash. · f66a4d68
      Junio C Hamano 提交于
      In user space, and for getcwd(), the check to see if the
      resulting path begins with a '/' does not make sense.  This is
      merely a mistake by Linus who is so used to code for the kernel,
      where a d_path() return value pathname can be either a real
      path, or something like "pipe:[8003]", and the difference is the
      '/' at the beginning.
      
      Pointed out by Dscho, Matthias Lederhofer and clarified by Linus.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f66a4d68
  2. 07 6月, 2007 4 次提交
    • J
      War on whitespace · a6080a0a
      Junio C Hamano 提交于
      This uses "git-apply --whitespace=strip" to fix whitespace errors that have
      crept in to our source files over time.  There are a few files that need
      to have trailing whitespaces (most notably, test vectors).  The results
      still passes the test, and build result in Documentation/ area is unchanged.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a6080a0a
    • M
      setup_git_directory: fix segfault if repository is found in cwd · f4f51add
      Matthias Lederhofer 提交于
      Additionally there was a similar part calling setenv and getenv
      in the same way which missed a check if getenv succeeded.
      Signed-off-by: NMatthias Lederhofer <matled@gmx.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f4f51add
    • M
      Use new semantics of is_bare/inside_git_dir/inside_work_tree · 7ae3df8c
      Matthias Lederhofer 提交于
      Up to now to check for a working tree this was used:
      	!is_bare && !inside_git_dir
      (the check for bare is redundant because is_inside_git_dir
      returned already 1 for bare repositories).
      Now the check is:
      	inside_work_tree && !inside_git_dir
      Signed-off-by: NMatthias Lederhofer <matled@gmx.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      7ae3df8c
    • M
      introduce GIT_WORK_TREE to specify the work tree · 892c41b9
      Matthias Lederhofer 提交于
      setup_gdg is used as abbreviation for setup_git_directory_gently.
      
      The work tree can be specified using the environment variable
      GIT_WORK_TREE and the config option core.worktree (the environment
      variable has precendence over the config option).  Additionally
      there is a command line option --work-tree which sets the
      environment variable.
      
      setup_gdg does the following now:
      
      GIT_DIR unspecified
      repository in .git directory
          parent directory of the .git directory is used as work tree,
          GIT_WORK_TREE is ignored
      
      GIT_DIR unspecified
      repository in cwd
          GIT_DIR is set to cwd
          see the cases with GIT_DIR specified what happens next and
          also see the note below
      
      GIT_DIR specified
      GIT_WORK_TREE/core.worktree unspecified
          cwd is used as work tree
      
      GIT_DIR specified
      GIT_WORK_TREE/core.worktree specified
          the specified work tree is used
      
      Note on the case where GIT_DIR is unspecified and repository is in cwd:
          GIT_WORK_TREE is used but is_inside_git_dir is always true.
          I did it this way because setup_gdg might be called multiple
          times (e.g. when doing alias expansion) and in successive calls
          setup_gdg should do the same thing every time.
      
      Meaning of is_bare/is_inside_work_tree/is_inside_git_dir:
      
      (1) is_bare_repository
          A repository is bare if core.bare is true or core.bare is
          unspecified and the name suggests it is bare (directory not
          named .git).  The bare option disables a few protective
          checks which are useful with a working tree.  Currently
          this changes if a repository is bare:
              updates of HEAD are allowed
              git gc packs the refs
              the reflog is disabled by default
      
      (2) is_inside_work_tree
          True if the cwd is inside the associated working tree (if there
          is one), false otherwise.
      
      (3) is_inside_git_dir
          True if the cwd is inside the git directory, false otherwise.
          Before this patch is_inside_git_dir was always true for bare
          repositories.
      
      When setup_gdg finds a repository git_config(git_default_config) is
      always called.  This ensure that is_bare_repository makes use of
      core.bare and does not guess even though core.bare is specified.
      
      inside_work_tree and inside_git_dir are set if setup_gdg finds a
      repository.  The is_inside_work_tree and is_inside_git_dir functions
      will die if they are called before a successful call to setup_gdg.
      Signed-off-by: NMatthias Lederhofer <matled@gmx.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      892c41b9
  3. 11 3月, 2007 1 次提交
  4. 21 2月, 2007 1 次提交
    • J
      Mechanical conversion to use prefixcmp() · cc44c765
      Junio C Hamano 提交于
      This mechanically converts strncmp() to use prefixcmp(), but only when
      the parameters match specific patterns, so that they can be verified
      easily.  Leftover from this will be fixed in a separate step, including
      idiotic conversions like
      
          if (!strncmp("foo", arg, 3))
      
        =>
      
          if (!(-prefixcmp(arg, "foo")))
      
      This was done by using this script in px.perl
      
         #!/usr/bin/perl -i.bak -p
         if (/strncmp\(([^,]+), "([^\\"]*)", (\d+)\)/ && (length($2) == $3)) {
                 s|strncmp\(([^,]+), "([^\\"]*)", (\d+)\)|prefixcmp($1, "$2")|;
         }
         if (/strncmp\("([^\\"]*)", ([^,]+), (\d+)\)/ && (length($1) == $3)) {
                 s|strncmp\("([^\\"]*)", ([^,]+), (\d+)\)|(-prefixcmp($2, "$1"))|;
         }
      
      and running:
      
         $ git grep -l strncmp -- '*.c' | xargs perl px.perl
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      cc44c765
  5. 21 1月, 2007 1 次提交
  6. 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
  7. 31 12月, 2006 1 次提交
    • S
      Automatically detect a bare git repository. · ad1a382f
      Shawn O. Pearce 提交于
      Many users find it unfriendly that they can create a bare git
      repository easily with `git clone --bare` but are then unable to
      run simple commands like `git log` once they cd into that newly
      created bare repository.  This occurs because we do not check to
      see if the current working directory is a git repository.
      
      Instead of failing out with "fatal: Not a git repository" we should
      try to automatically detect if the current working directory is
      a bare repository and use that for GIT_DIR, and fail out only if
      that doesn't appear to be true.
      
      We test the current working directory only after we have tried
      searching up the directory tree.  This is to retain backwards
      compatibility with our previous behavior on the off chance that
      a user has a 'refs' and 'objects' subdirectories and a 'HEAD'
      file that looks like a symref, all stored within a repository's
      associated working directory.
      
      This change also consolidates the validation logic between the case
      of GIT_DIR being supplied and GIT_DIR not being supplied, cleaning
      up the code.
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      ad1a382f
  8. 31 10月, 2006 1 次提交
  9. 21 9月, 2006 1 次提交
  10. 05 8月, 2006 1 次提交
  11. 31 7月, 2006 1 次提交
  12. 10 6月, 2006 1 次提交
    • 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
  13. 27 4月, 2006 2 次提交
    • J
      revision parsing: make "rev -- paths" checks stronger. · ea92f41f
      Junio C Hamano 提交于
      If you don't have a "--" marker, then:
      
       - all of the arguments we are going to assume are pathspecs
         must exist in the working tree.
      
       - none of the arguments we parsed as revisions could be
         interpreted as a filename.
      
      so that there really isn't any possibility of confusion in case
      somebody does have a revision that looks like a pathname too.
      
      The former rule has been in effect; this implements the latter.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      ea92f41f
    • L
      Fix filename verification when in a subdirectory · e23d0b4a
      Linus Torvalds 提交于
      When we are in a subdirectory of a git archive, we need to take the prefix
      of that subdirectory into accoung when we verify filename arguments.
      
      Noted by Matthias Lederhofer
      
      This also uses the improved error reporting for all the other git commands
      that use the revision parsing interfaces, not just git-rev-parse. Also, it
      makes the error reporting for mixed filenames and argument flags clearer
      (you cannot put flags after the start of the pathname list).
      
      [jc: with fix to a trivial typo noticed by Timo Hirvonen]
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      e23d0b4a
  14. 24 12月, 2005 1 次提交
    • J
      Introduce core.sharedrepository · 457f06d6
      Johannes Schindelin 提交于
      If the config variable 'core.sharedrepository' is set, the directories
      
      	$GIT_DIR/objects/
      	$GIT_DIR/objects/??
      	$GIT_DIR/objects/pack
      	$GIT_DIR/refs
      	$GIT_DIR/refs/heads
      	$GIT_DIR/refs/heads/tags
      
      are set group writable (and g+s, since the git group may be not the primary
      group of all users).
      
      Since all files are written as lock files first, and then moved to
      their destination, they do not have to be group writable.  Indeed, if
      this leads to problems you found a bug.
      
      Note that -- as in my first attempt -- the config variable is set in the
      function which checks the repository format. If this were done in
      git_default_config instead, a lot of programs would need to be modified
      to call git_config(git_default_config) first.
      
      [jc: git variables should be in environment.c unless there is a
       compelling reason to do otherwise.]
      Signed-off-by: NJohannes Schindelin <Johannes.Schindelin@gmx.de>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      457f06d6
  15. 01 12月, 2005 1 次提交
  16. 29 11月, 2005 1 次提交
    • J
      working from subdirectory: preparation · 4ca06608
      Junio C Hamano 提交于
       - prefix_filename() is like prefix_path() but can be used to
         name any file on the filesystem, not the files that might go
         into the index file.
      
       - setup_git_directory_gently() tries to find the GIT_DIR, but does
         not die() if called outside a git repository.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      4ca06608
  17. 27 11月, 2005 2 次提交
  18. 26 11月, 2005 1 次提交
  19. 02 10月, 2005 1 次提交
    • J
      Add git-symbolic-ref · 8098a178
      Junio C Hamano 提交于
      This adds the counterpart of git-update-ref that lets you read
      and create "symbolic refs".  By default it uses a symbolic link
      to represent ".git/HEAD -> refs/heads/master", but it can be compiled
      to use the textfile symbolic ref.
      
      The places that did 'readlink .git/HEAD' and 'ln -s refs/heads/blah
      .git/HEAD' have been converted to use new git-symbolic-ref command, so
      that they can deal with either implementation.
      Signed-off-by: NJunio C Hamano <junio@twinsun.com>
      8098a178
  20. 25 9月, 2005 1 次提交
  21. 10 9月, 2005 1 次提交
  22. 28 8月, 2005 1 次提交
    • L
      [PATCH] Make .git directory validation code test HEAD · 5f5608bc
      Linus Torvalds 提交于
      Inspired by a report by Kalle Valo, this changes git-sh-setup-script and
      the "setup_git_directory()" function to test that $GIT_DIR/HEAD is a
      symlink, since a number of core git features depend on that these days.
      
      We used to allow a regular file there, but git-fsck-cache has been
      complaining about that for a while, and anything that uses branches
      depends on the HEAD file being a symlink, so let's just encode that as a
      fundamental requirement.
      
      Before, a non-symlink HEAD file would appear to work, but have subtle bugs
      like not having the HEAD show up as a valid reference (because it wasn't
      under "refs"). Now, we will complain loudly, and the user can fix it up
      trivially instead of getting strange behaviour.
      
      This also removes the tests for "$GIT_DIR" and "$GIT_OBJECT_DIRECTORY"
      being directories, since the other tests will implicitly test for that
      anyway (ie the tests for HEAD, refs and 00 would fail).
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      5f5608bc
  23. 18 8月, 2005 1 次提交
  24. 17 8月, 2005 3 次提交