{"thread":{"id":"34272","subject":"Difficulty adding a symbolic link, part 2","startedAt":"2013-06-25T02:36:42Z","lastAt":"2013-06-25T02:36:42Z","messageCount":1,"participants":["Dale R. Worley"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"221920","messageId":"201306250236.r5P2ag85022808@hobgoblin.ariadne.com","threadId":"34272","inReplyTo":null,"subject":"Difficulty adding a symbolic link, part 2","fromName":"Dale R. Worley","fromEmail":"worley@alum.mit.edu","sentAt":"2013-06-25T02:36:42Z","receivedAt":"2013-06-25T02:36:42Z","isPatch":false,"sender":{"key":"worley@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/19911107?v=4"},"body":"Here's a slightly simpler test case for adding a symbolic link.  This\ntest exploits the fact that on my system, /bin/awk is a symbolic link\nto \"gawk\".  As you can see, the behavior of Git differs if the link's\npath is given to \"git add\" as an absolute path or a relative path.\n\nHere is the test script:\n----------------------------------------------------------------------\n#! /bin/bash\n\n# Illustrates a problem with applying \"git add\" to a symbolic link.\n\nset -x\n\n# To be run from a directory one step below the root directory.  E.g.,\n# \"/git-add-link\".\n# Exploits the fact that /bin/awk is a symbolic link to \"gawk\".\n\n# Show the Git version.\ngit version\n\n# Make a test directory and cd to it.\nDIR=temp.$$\nmkdir $DIR\ncd $DIR\n\n# Create a Git repository.\ngit init\n# Set the worktree to be /\ngit config core.worktree /\n# Create an empty commit.\ngit commit --allow-empty -m Empty.\n\n# Add the symbolic link using its absolute name.\nABSOLUTE=/bin/awk\nls -l $ABSOLUTE\ngit add $ABSOLUTE\n# Notice that the target of the link is added, not the link itself.\ngit status -uno\n\n# Reset the index.\ngit reset\n\n# Add the symbolic link using its relative name.\n# Remember that we are two directory levels below the root directory now.\nRELATIVE=../..$ABSOLUTE\nls -l $RELATIVE\ngit add $RELATIVE\n# Notice that now the link itself is added.\ngit status -uno\n----------------------------------------------------------------------\nHere is the output of the script:\n----------------------------------------------------------------------\n+ git version\ngit version 1.7.7.6\n+ DIR=temp.22366\n+ mkdir temp.22366\n+ cd temp.22366\n+ git init\nInitialized empty Git repository in /git-add-link/temp.22366/.git/\n+ git config core.worktree /\n+ git commit --allow-empty -m Empty.\n[master (root-commit) fb232e5] Empty.\n+ ABSOLUTE=/bin/awk\n+ ls -l /bin/awk\nlrwxrwxrwx. 1 root root 4 Nov  2  2012 /bin/awk -> gawk\n+ git add /bin/awk\n+ git status -uno\n# On branch master\n# Changes to be committed:\n#   (use \"git reset HEAD <file>...\" to unstage)\n#\n#\tnew file:   ../../bin/gawk\n#\n# Untracked files not listed (use -u option to show untracked files)\n+ git reset\n+ RELATIVE=../../bin/awk\n+ ls -l ../../bin/awk\nlrwxrwxrwx. 1 root root 4 Nov  2  2012 ../../bin/awk -> gawk\n+ git add ../../bin/awk\n+ git status -uno\n# On branch master\n# Changes to be committed:\n#   (use \"git reset HEAD <file>...\" to unstage)\n#\n#\tnew file:   ../../bin/awk\n#\n# Untracked files not listed (use -u option to show untracked files)\n----------------------------------------------------------------------\nI can't see any principle of operation of Git that would cause \"git\nadd /bin/awk\" and \"git add ../../bin/awk\" to be handled differently.\n\nDale\n"}]}