I'm having a problem with "git add" in version 1.7.7.6.

The situation is that I have a repository that is contained in a
second-level directory, a sub-sub-directory of "/".  The core.worktree
of the repository is "/", so the working directory is the entire file
tree.  I want this repository to track selected files, which I add
with "git add".

The difficulty is that "git add" seems to not add specific files,
depending on how they are specified as arguments to "git add".  In
particular, /dev/dvd (which is a symbolic link) can be added with "git
add ../../dev/dvd" but not with "git add /dev/dvd".  On the other
hand, /etc/hosts (an ordinary file) can be added with either "git add
/etc/hosts" or "git add ../../etc/hosts".

To demonstrate the problem, I've written a script.  A typical
execution of the script is as follows.  The lines at the left margin
start with "$", and are the lines of the script.  The lines indented 4
spaces start with "+", and are the "simple commands" as they are
executed by the shell, showing the values of variables.  The lines
indented 8 spaces are the output of the various commands.

Any help with this would be appreciated.

Dale

$ set -x
$ 
$ # Show git version.
$ git version
    + git version
        git version 1.7.7.6
$ 
$ # To be run in a directory that is contained in /.
$ pwd
    + pwd
        /git-add-issue
$ 
$ # Make a test directory.
$ DIR=temp.$$
    + DIR=temp.10714
$ mkdir $DIR
    + mkdir temp.10714
$ cd $DIR
    + cd temp.10714
    ++ pwd
$ DIR_ABSOLUTE=$( pwd )
    + DIR_ABSOLUTE=/git-add-issue/temp.10714
$ 
$ # Create a new repository.
$ git init
    + git init
        Initialized empty Git repository in /git-add-issue/temp.10714/.git/
$ # Set the worktree to be /
$ git config core.worktree /
    + git config core.worktree /
$ # Create empty commit.
$ git commit --allow-empty -m Empty.
    + git commit --allow-empty -m Empty.
        [master (root-commit) 62d86cb] Empty.
$ 
$ # Show empty status
$ git status -uno
    + git status -uno
        # On branch master
        nothing to commit (use -u to show untracked files)
$ 
$ # First test:  /dev/dvd, which is a symbolic link.
$ 
$ # Try to add /dev/dvd
$ ABSOLUTE_NAME=/dev/dvd
    + ABSOLUTE_NAME=/dev/dvd
$ ll $ABSOLUTE_NAME
    + ls -al /dev/dvd
        lrwxrwxrwx. 1 root root 9 Jun 12 22:23 /dev/dvd -> /dev/dvd1
$ git add $ABSOLUTE_NAME
    + git add /dev/dvd
$ git status -uno
    + git status -uno
        # On branch master
        nothing to commit (use -u to show untracked files)
$ git reset
    + git reset
$ 
$ # Try with alternative name ../../dev/dvd
$ RELATIVE_NAME=../../dev/dvd
    + RELATIVE_NAME=../../dev/dvd
$ ll $RELATIVE_NAME
    + ls -al ../../dev/dvd
        lrwxrwxrwx. 1 root root 9 Jun 12 22:23 ../../dev/dvd -> /dev/dvd1
$ git add $RELATIVE_NAME
    + git add ../../dev/dvd
$ git status -uno
    + git status -uno
        # On branch master
        # Changes to be committed:
        #   (use "git reset HEAD <file>..." to unstage)
        #
        #       new file:   ../../dev/dvd
        #
        # Untracked files not listed (use -u option to show untracked files)
$ git reset
    + git reset
$ 
$ # Second test:  /etc/hosts, which is an ordinary file.
$ 
$ # Try to add /etc/hosts
$ ABSOLUTE_NAME=/etc/hosts
    + ABSOLUTE_NAME=/etc/hosts
$ ll $ABSOLUTE_NAME
    + ls -al /etc/hosts
        -rw-r--r--. 1 root root 222 Nov  4  2012 /etc/hosts
$ git add $ABSOLUTE_NAME
    + git add /etc/hosts
$ git status -uno
    + git status -uno
        # On branch master
        # Changes to be committed:
        #   (use "git reset HEAD <file>..." to unstage)
        #
        #       new file:   ../../etc/hosts
        #
        # Untracked files not listed (use -u option to show untracked files)
$ git reset
    + git reset
$ 
$ # Try with alternative name ../../etc/hosts
$ RELATIVE_NAME=../../etc/hosts
    + RELATIVE_NAME=../../etc/hosts
$ ll $RELATIVE_NAME
    + ls -al ../../etc/hosts
        -rw-r--r--. 1 root root 222 Nov  4  2012 ../../etc/hosts
$ git add $RELATIVE_NAME
    + git add ../../etc/hosts
$ git status -uno
    + git status -uno
        # On branch master
        # Changes to be committed:
        #   (use "git reset HEAD <file>..." to unstage)
        #
        #       new file:   ../../etc/hosts
        #
        # Untracked files not listed (use -u option to show untracked files)
$ git reset
    + git reset

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to