wecodemore / grunt-githooks

A Grunt plugin to help bind Grunt tasks to Git hooks
https://npmjs.org/package/grunt-githooks
MIT License
317 stars 24 forks source link

Does not work when .git is not a directory #25

Closed wszostak closed 8 years ago

wszostak commented 10 years ago

It is possible in Git that .git is not a directory but regular file.

When I create such a file with content:

 gitdir: /path/to/bare/repository/.git

, Git knows that its files are in different path.

grunt-githooks, however, does not follow this link and returns error:

Warning: Unable to create directory "/home/wszostak/projekty/NMS/nms/.git/hooks" (Error code: ENOTDIR). Use --force to continue.
franz-josef-kaiser commented 10 years ago

Where would the hooks directory then be? In the root?

wszostak commented 10 years ago

It can be anywhere.

This is example:

Assume that working copy is in: /home/user/repo/ and in this folder is file .git with gitdir: ../repositores/repo content. Then bare repository is in /home/user/repositories/repo. So hooks should be saved in /home/user/repositories/repo/hooks

franz-josef-kaiser commented 10 years ago

Are you talking about a setup where you have the current (any) repository and an additional bare repo at the same machine? Could you please provide some links or context to understand your scenario more easily? It's quite uncommon to treat two different repositories as something that lives in the same place.

wszostak commented 10 years ago

Here is example.

├── git-dir-outside
│   ├── branches
│   ├── COMMIT_EDITMSG
│   ├── config
│   ├── description
│   ├── HEAD
│   ├── hooks 
│   │   ├── applypatch-msg.sample
│   │   ├── commit-msg.sample
│   │   ├── post-update.sample
│   │   ├── pre-applypatch.sample
│   │   ├── pre-commit.sample
│   │   ├── prepare-commit-msg.sample
│   │   ├── pre-push.sample
│   │   ├── pre-rebase.sample
│   │   └── update.sample
│   ├── index
│   ├── info
│   │   └── exclude
│   ├── logs
│   │   ├── HEAD
│   │   └── refs
│   │       └── heads
│   │           └── master
│   ├── MERGE_RR
│   ├── objects
│   │   ├── 35
│   │   │   └── d12458f7e44e84bfb7e586dd79dd4a4a109e78
│   │   ├── 9d
│   │   │   └── aeafb9864cf43055ae93beb0afd6c7d144bfa4
│   │   ├── c1
│   │   │   └── 2d7c0ed49ad9c7aa938743ba6fdee54b6b7fe1
│   │   ├── info
│   │   └── pack
│   ├── refs
│   │   ├── heads
│   │   │   └── master
│   │   └── tags
│   └── rr-cache
└── work-tree
    ├── .git
    └── README.md

As you can see. .git is file. It contains only gitdir: ../git-dir-outside text. The git-dir is outside work tree.

franz-josef-kaiser commented 10 years ago

How would we know where the hooks folder is? Is there a reliable way? Some file to look at where we should point it to? Or would we need to recursively search the tree?

wszostak commented 10 years ago

if work-tree/.git is regular file, read it. It contains gitdir: followed by git repository path (gitdir: ../git-dir-outside). So in our example ../git-dir-outside/hooks is hooks dir.

franz-josef-kaiser commented 10 years ago

Ok. It would have been a bit simpler if you would have linked the documentation about it :palm_tree:

After reading into this, I found another possibility to set a git dir location outside the default location:

--separate-git-dir=<git dir>

In this StackOverflow answer, I found the way how you maybe set this up:

git --git-dir=/path/to/repo.git --work-tree=. init && echo "gitdir: /path/to/repo.git" > .git

Can you confirm this? To give you an idea why I am asking in that detail: Me or anyone else willing to jump in and help finding out what needs to change and where the changes need to be put, need to reproduce your setup somehow. So in short: If you can help documenting how to

  1. Reproduce your setup and
  2. Reproduce similar setups that produce an outside git location
  3. Sum up all possible ways on how to do that and reproduce them as well

then we are way faster to patch up a solution.

franz-josef-kaiser commented 10 years ago

@wszostak As it just came to my mind: have you ever tried the dest option? Did it simply fly below your radar? :)

franz-josef-kaiser commented 8 years ago

Closing as the needed info is missing since more than a year now.