My project has the following structure
/project/config.mk
/project/dir1/config.mk -> ../config.mk
/project/dir2/config.mk -> ../config.mk
When I used diff
to create the patch file, the /project/config.mk
was done correctly, but the two symbolic links got some problems. They were both treated as new files, the diff sections were the whole content of the config.mk
file. I tried to find a diff
option to disable following symbolic link, but there is no such option available. Any suggestions are appreciated.
As Overbose's suggestion, I create this script. It works. Thank everyone for taking time answering.
#!/bin/sh -v
ori_dir=$1
new_dir=$2
patch_file=./patch_file
if [ -f ${patch_file} ]
then
rm ${patch_file}
fi
ori_files=`cd ${ori_dir} ; find ./ -type f ! -type l`
for i in ${ori_files} ; do
if [ -f ${ori_dir}/$i ]
then
if [ -f ${new_dir}/$i ]
then
diff -rup ${ori_dir}/$i ${new_dir}/$i >> ${patch_file}
fi
fi
done
To dereference a symbolic link means to follow the link to the target file rather than work with the link itself. When you dereference a symbolic link, you end up with a pointer to the file (the filename of the target file). The term no-dereference is a double negative: It means reference.
Git does not follow symbolic links when accessing a . gitignore file in the working tree. This keeps behavior consistent when the file is accessed from the index or a tree versus from the filesystem.
Using the rm Command We know the rm command can delete files and directories. Additionally, we can use this command to delete symbolic links. As the output above shows, We have successfully deleted fileLink. The syntaxes of deleting a symbolic link and a file are the same.
A symbolic link has its own inode number. When you create a symbolic link, you create a new physical file with its own inode number, as shown in Figure 1. Because a symbolic link refers to a file by its path name rather than by its inode number, a symbolic link can refer to files in other mounted file systems.
In GNU diff v3.3 there is now an option --no-dereference that does the trick
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With