From 5fe3a5f7e9ea811d332af739cbe1c3f2837c06ec Mon Sep 17 00:00:00 2001 From: "https://www.google.com/accounts/o8/id?id=AItOawnWvnTWY6LrcPB4BzYEBn5mRTpNhg5EtEg" Date: Thu, 15 Jan 2015 16:15:21 +0000 Subject: Added a comment --- ...ent_4_bfb4758fdb2a4afafd9c4d45de5c5c6b._comment | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 doc/forum/how_to_prevent_accidentally_running___96__git_add__96____63__/comment_4_bfb4758fdb2a4afafd9c4d45de5c5c6b._comment diff --git a/doc/forum/how_to_prevent_accidentally_running___96__git_add__96____63__/comment_4_bfb4758fdb2a4afafd9c4d45de5c5c6b._comment b/doc/forum/how_to_prevent_accidentally_running___96__git_add__96____63__/comment_4_bfb4758fdb2a4afafd9c4d45de5c5c6b._comment new file mode 100644 index 000000000..de2a279a7 --- /dev/null +++ b/doc/forum/how_to_prevent_accidentally_running___96__git_add__96____63__/comment_4_bfb4758fdb2a4afafd9c4d45de5c5c6b._comment @@ -0,0 +1,28 @@ +[[!comment format=mdwn + username="https://www.google.com/accounts/o8/id?id=AItOawnWvnTWY6LrcPB4BzYEBn5mRTpNhg5EtEg" + nickname="Bence" + subject="comment 4" + date="2015-01-15T16:15:21Z" + content=""" +Based on the above, I'm using this script in the `pre-commit` hook. + +It gets the staged files and checks if they are links or not. If a file being committed is not a link (maybe it was added with `git add filename` ???), the script aborts the commit. + + #!/bin/sh + + # Don't allow files to be added to the normal repo. + stagedfiles=$(git diff --cached --name-only); + echo \"$stagedfiles\" | while IFS= read -r file; do + if [ ! -L \"$file\" ]; then + echo \"[Error] The file \\"$file\\" should not be added to the repo.\"; + echo \"#Remove from the index and add with git-annex:\"; + echo \"\$ git rm --cached \\"$file\\" && git annex add \\"$file\\"\"; + exit 1; + #else + # echo \"OK : $file\"; + fi; + done; + + # automatically configured by git-annex + git annex pre-commit . +"""]] -- cgit v1.2.3