Re: Running 'git worktree add' in 'pre-commit' hook

2019-05-16 Thread Jeff King
On Thu, May 16, 2019 at 09:02:06PM -0400, Eric Sunshine wrote: > On Thu, May 16, 2019 at 8:19 PM Jeff King wrote: > > On Thu, May 16, 2019 at 07:16:54PM -0400, Eric Sunshine wrote: > > > Is there > > > any existing code in Git for doing the relative fixups you mention for > > > other Git environm

Re: Running 'git worktree add' in 'pre-commit' hook

2019-05-16 Thread Eric Sunshine
On Thu, May 16, 2019 at 8:19 PM Jeff King wrote: > On Thu, May 16, 2019 at 07:16:54PM -0400, Eric Sunshine wrote: > > Is there > > any existing code in Git for doing the relative fixups you mention for > > other Git environment variables? > > You can assign local_repo_env to child_process.env (or

Re: Running 'git worktree add' in 'pre-commit' hook

2019-05-16 Thread Jeff King
On Thu, May 16, 2019 at 07:16:54PM -0400, Eric Sunshine wrote: > On Thu, May 16, 2019 at 6:17 PM Jeff King wrote: > > On Thu, May 16, 2019 at 06:25:24PM +0700, Duy Nguyen wrote: > > > So you probably can still make it work by backing up $GIT_INDEX_FILE > > > (in case you need it), then unset it b

Re: Running 'git worktree add' in 'pre-commit' hook

2019-05-16 Thread Eric Sunshine
On Thu, May 16, 2019 at 6:17 PM Jeff King wrote: > On Thu, May 16, 2019 at 06:25:24PM +0700, Duy Nguyen wrote: > > So you probably can still make it work by backing up $GIT_INDEX_FILE > > (in case you need it), then unset it before you use "git worktree" (or > > cd to it if you keep a permanent se

Re: Running 'git worktree add' in 'pre-commit' hook

2019-05-16 Thread Jeff King
On Thu, May 16, 2019 at 06:25:24PM +0700, Duy Nguyen wrote: > > Is it forbidden to call this command from a hook? > > pre-commit hook sets GIT_INDEX_FILE to this "index.lock" so you have > the latest index content (which is not the same as from > $GIT_DIR/index). This variable will interfere with

Re: Running 'git worktree add' in 'pre-commit' hook

2019-05-16 Thread Duy Nguyen
On Thu, May 16, 2019 at 7:15 PM Eric Sunshine wrote: > > On Thu, May 16, 2019 at 7:42 AM Duy Nguyen wrote: > > On Thu, May 16, 2019 at 6:33 PM Eric Sunshine > > wrote: > > > You run afoul of it in other situations, as well. For instance, say > > > you have your index file in a non-standard loca

Re: Running 'git worktree add' in 'pre-commit' hook

2019-05-16 Thread Eric Sunshine
On Thu, May 16, 2019 at 7:42 AM Duy Nguyen wrote: > On Thu, May 16, 2019 at 6:33 PM Eric Sunshine wrote: > > You run afoul of it in other situations, as well. For instance, say > > you have your index file in a non-standard location: > > > > $ export GIT_INDEX_FILE=../storage/index > > $

Re: Running 'git worktree add' in 'pre-commit' hook

2019-05-16 Thread Eric Sunshine
On Thu, May 16, 2019 at 7:45 AM Duy Nguyen wrote: > On Thu, May 16, 2019 at 6:39 PM Eric Sunshine wrote: > > Thinking more clearly on it, a better fix might be for git-worktree to > > deal with this itself, converting such a path to absolute before > > cd'ing to the new worktree directory (or som

Re: Running 'git worktree add' in 'pre-commit' hook

2019-05-16 Thread Eric Sunshine
On Thu, May 16, 2019 at 7:25 AM Duy Nguyen wrote: > pre-commit hook sets GIT_INDEX_FILE to this "index.lock" so you have > the latest index content (which is not the same as from > $GIT_DIR/index). This variable will interfere with any commands that > work on a different worktree. I think that th

Re: Running 'git worktree add' in 'pre-commit' hook

2019-05-16 Thread Duy Nguyen
On Thu, May 16, 2019 at 6:39 PM Eric Sunshine wrote: > > On Thu, May 16, 2019 at 7:33 AM Eric Sunshine wrote: > > I researched this also and concluded that it's a bug in git-commit. > > You run afoul of it in other situations, as well. For instance, say > > you have your index file in a non-stand

Re: Running 'git worktree add' in 'pre-commit' hook

2019-05-16 Thread Duy Nguyen
On Thu, May 16, 2019 at 6:33 PM Eric Sunshine wrote: > I researched this also and concluded that it's a bug in git-commit. > You run afoul of it in other situations, as well. For instance, say > you have your index file in a non-standard location: > > $ export GIT_INDEX_FILE=../storage/index >

Re: Running 'git worktree add' in 'pre-commit' hook

2019-05-16 Thread Eric Sunshine
On Thu, May 16, 2019 at 7:33 AM Eric Sunshine wrote: > I researched this also and concluded that it's a bug in git-commit. > You run afoul of it in other situations, as well. For instance, say > you have your index file in a non-standard location: > > $ export GIT_INDEX_FILE=../storage/index >

Re: Running 'git worktree add' in 'pre-commit' hook

2019-05-16 Thread Eric Sunshine
On Thu, May 16, 2019 at 7:25 AM Duy Nguyen wrote: > pre-commit hook sets GIT_INDEX_FILE to this "index.lock" so you have > the latest index content (which is not the same as from > $GIT_DIR/index). This variable will interfere with any commands that > work on a different worktree. > > So you proba

Re: Running 'git worktree add' in 'pre-commit' hook

2019-05-16 Thread Duy Nguyen
On Tue, May 14, 2019 at 9:53 PM Cosmin Polifronie wrote: > > Hello! I am trying to run 'git worktree add HEAD' in the > 'pre-commit' hook, more specifically in a Python script that is being > called from the hook. When doing so, I am greeted with the following > error: > > On Windows 10: > Prepar

Re: Running 'git worktree add' in 'pre-commit' hook

2019-05-15 Thread Cosmin Polifronie
Hello Bryan, My project contains a Gradle build that is dependent on a configuration found in a file called build.gradle. What I need to do is run Gradle with a proper build.gradle file, meaning: if a new build.gradle is staged, I will use that for my Gradle build, if not I will use the latest app

Re: Running 'git worktree add' in 'pre-commit' hook

2019-05-14 Thread Bryan Turner
On Tue, May 14, 2019 at 7:53 AM Cosmin Polifronie wrote: > > Hello! I am trying to run 'git worktree add HEAD' in the > 'pre-commit' hook, more specifically in a Python script that is being > called from the hook. When doing so, I am greeted with the following > error: > > On Windows 10: > Prepar

Running 'git worktree add' in 'pre-commit' hook

2019-05-14 Thread Cosmin Polifronie
Hello! I am trying to run 'git worktree add HEAD' in the 'pre-commit' hook, more specifically in a Python script that is being called from the hook. When doing so, I am greeted with the following error: On Windows 10: Preparing worktree (detached HEAD cbfef18) fatal: Unable to create 'C:/Users/me