* Difficulty adding a symbolic link
@ 2013-06-14 16:15 Dale R. Worley
0 siblings, 0 replies; only message in thread
From: Dale R. Worley @ 2013-06-14 16:15 UTC (permalink / raw)
To: git
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 substituted for the shell
variables. The lines indented 8 spaces are the output of the various
commands.
Someone suggested that the problem may be triggered by the fact that
/dev is in a different filesystem than / and /etc. I added a third
section to the script by creating a symbolic link from /etc/hosts.link
to /etc/hosts, which is thus in the same filesystem as / and the
repository. Git handles it as expected.
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
$
$ # Third test: /etc/hosts.link, which is a link to /etc/hosts
$
$ # Try to add /etc/hosts.link
$ ABSOLUTE_NAME=/etc/hosts.link
+ ABSOLUTE_NAME=/etc/hosts.link
$ ll $ABSOLUTE_NAME
+ ls -al /etc/hosts.link
lrwxrwxrwx. 1 root root 5 Jun 14 12:04 /etc/hosts.link -> hosts
$ git add $ABSOLUTE_NAME
+ git add /etc/hosts.link
$ 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.link
$ RELATIVE_NAME=../../etc/hosts.link
+ RELATIVE_NAME=../../etc/hosts.link
$ ll $RELATIVE_NAME
+ ls -al ../../etc/hosts.link
lrwxrwxrwx. 1 root root 5 Jun 14 12:04 ../../etc/hosts.link -> hosts
$ git add $RELATIVE_NAME
+ git add ../../etc/hosts.link
$ git status -uno
+ git status -uno
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# new file: ../../etc/hosts.link
#
# Untracked files not listed (use -u option to show untracked files)
$ git reset
+ git reset
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2013-06-14 16:22 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-14 16:15 Difficulty adding a symbolic link Dale R. Worley
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).