From cf4a669d86b2d1e7550798c8249bf1d0b1d10a46 Mon Sep 17 00:00:00 2001 From: "muks@6bded6d879d80c43cdf4893fabb785876eea0a7b" Date: Fri, 11 Dec 2020 01:56:38 +0000 Subject: [PATCH 1/3] --- ...to_copy_files___40__the_symbolic_links__41__.mdwn | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 doc/forum/Way_to_copy_files___40__the_symbolic_links__41__.mdwn diff --git a/doc/forum/Way_to_copy_files___40__the_symbolic_links__41__.mdwn b/doc/forum/Way_to_copy_files___40__the_symbolic_links__41__.mdwn new file mode 100644 index 0000000000..b397ea28ee --- /dev/null +++ b/doc/forum/Way_to_copy_files___40__the_symbolic_links__41__.mdwn @@ -0,0 +1,12 @@ +I'm using git-annex with the SHA256 backend. When I git annex add a file, it becomes a symbolic link and the real content goes in a file whose name includes the SHA256 hash. + +Suppose the original filename (which is a symbolic link now) is named A. I want to have another filename B point to A. In a non-annex directory I'd create a symbolic link B -> A or a hardlink B that is the same file as A. + +Within the git annex directory, I don't want to use another symbolic link B -> A -> keyfile. Instead, I want two symbolic links straight to the content: + +* B -> keyfile +* A -> keyfile + +This appears to be more elegant, and A or B can be independently unlinked without the other becoming a dangling link. It is also what git annex would do if A and B are added with the same content separately. I want a command that creates B: git annex ln A B + +Apologies if there is already such a git annex command. There doesn't seem to be a direct equivalent in cp's arguments or rsync's arguments to fixup the relative link path while copying it, and it needs a longer series of piped commands. As the link would be created within the annex directory, having git annex provide a single command to do it would be most useful. From 16f2fcd778629be8019fc0cd221bb46f99488fc0 Mon Sep 17 00:00:00 2001 From: "muks@6bded6d879d80c43cdf4893fabb785876eea0a7b" Date: Fri, 11 Dec 2020 02:18:30 +0000 Subject: [PATCH 2/3] Added a comment --- ..._1_5f452eeb652e1bbec54cddc3735a6d4a._comment | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 doc/forum/Way_to_copy_files___40__the_symbolic_links__41__/comment_1_5f452eeb652e1bbec54cddc3735a6d4a._comment diff --git a/doc/forum/Way_to_copy_files___40__the_symbolic_links__41__/comment_1_5f452eeb652e1bbec54cddc3735a6d4a._comment b/doc/forum/Way_to_copy_files___40__the_symbolic_links__41__/comment_1_5f452eeb652e1bbec54cddc3735a6d4a._comment new file mode 100644 index 0000000000..0ad2a90b27 --- /dev/null +++ b/doc/forum/Way_to_copy_files___40__the_symbolic_links__41__/comment_1_5f452eeb652e1bbec54cddc3735a6d4a._comment @@ -0,0 +1,17 @@ +[[!comment format=sh + username="muks@6bded6d879d80c43cdf4893fabb785876eea0a7b" + nickname="muks" + avatar="http://cdn.libravatar.org/avatar/2bb3204407446ec2adfe5c41be26cc1e" + subject="comment 1" + date="2020-12-11T02:18:29Z" + content=""" +# What I want is achieved by this longer command: + +ln -s $(realpath --relative-to=. $(readlink -m $FILE_SRC)) $FILE_DEST && \ + git add $FILE_DEST + +# Instead, a git annex command to perform the above with +# the following syntax would be useful: + +git annex ln $FILE_SRC $FILE_DEST +"""]] From e0780877d7bb6dd2463795eabf51475d5b749f7a Mon Sep 17 00:00:00 2001 From: kyle Date: Fri, 11 Dec 2020 15:29:26 +0000 Subject: [PATCH 3/3] Added a comment --- ..._56617a9d760e7528d7b30ed479e5070a._comment | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 doc/forum/Way_to_copy_files___40__the_symbolic_links__41__/comment_2_56617a9d760e7528d7b30ed479e5070a._comment diff --git a/doc/forum/Way_to_copy_files___40__the_symbolic_links__41__/comment_2_56617a9d760e7528d7b30ed479e5070a._comment b/doc/forum/Way_to_copy_files___40__the_symbolic_links__41__/comment_2_56617a9d760e7528d7b30ed479e5070a._comment new file mode 100644 index 0000000000..94e8bd1531 --- /dev/null +++ b/doc/forum/Way_to_copy_files___40__the_symbolic_links__41__/comment_2_56617a9d760e7528d7b30ed479e5070a._comment @@ -0,0 +1,28 @@ +[[!comment format=mdwn + username="kyle" + avatar="http://cdn.libravatar.org/avatar/7d6e85cde1422ad60607c87fa87c63f3" + subject="comment 2" + date="2020-12-11T15:29:26Z" + content=""" +> I want a command that creates B: git annex ln A B + +> Apologies if there is already such a git annex command. There +> doesn't seem to be a direct equivalent in cp's arguments or rsync's +> arguments to fixup the relative link path while copying it, and it +> needs a longer series of piped commands. + +I'm not aware of a git-annex command that does this, but you can just +copy the link and `git annex add` it. git-annex will fix up the +levels if needed. + +``` +$ cp -d d/foo.txt bar.txt +$ git annex add bar.txt + +$ git show :d/foo.txt +../.git/annex/objects/8Z/1J/SHA256-s4--b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c/SHA256-s4--b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c +$ git show :bar.txt +.git/annex/objects/8Z/1J/SHA256-s4--b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c/SHA256-s4--b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c +``` + +"""]]