diff options
author | https://www.google.com/accounts/o8/id?id=AItOawnWvnTWY6LrcPB4BzYEBn5mRTpNhg5EtEg <Bence@web> | 2015-01-15 16:15:21 +0000 |
---|---|---|
committer | admin <admin@branchable.com> | 2015-01-15 16:15:21 +0000 |
commit | 5fe3a5f7e9ea811d332af739cbe1c3f2837c06ec (patch) | |
tree | 5d9c845dcfe8d1ba23047705197dc1a63fe3455e | |
parent | ec134d07b5dda19528f59d770edd51839cc673f7 (diff) |
Added a comment
-rw-r--r-- | doc/forum/how_to_prevent_accidentally_running___96__git_add__96____63__/comment_4_bfb4758fdb2a4afafd9c4d45de5c5c6b._comment | 28 |
1 files changed, 28 insertions, 0 deletions
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 . +"""]] |