{"thread":{"id":"41239","subject":"Add post-worktree-add hook?","startedAt":"2016-01-22T09:45:49Z","lastAt":"2016-01-22T17:28:57Z","messageCount":2,"participants":["Duy Nguyen","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"276538","messageId":"CACsJy8C9OELrkHZLzwoRx26AtzVvgouRA2+m0VH7GrJGSA8PCQ@mail.gmail.com","threadId":"41239","inReplyTo":null,"subject":"Add post-worktree-add hook?","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2016-01-22T09:45:49Z","receivedAt":"2016-01-22T09:45:49Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"I started moving my git work space to multi-worktree and found it\nannoying that every time I add a new worktree, my first step must be\ncopy my config.mak over. Room for improvement. I see three options:\n\n1) add an option in 'worktree add' to copy all untracked files from\ncurrent worktree over\n\nOnly fits when you keep your .gitignore uptodate or we may copy a lot\nof rubbish. Good for the lazies who don't want to write hooks though.\n\n2) improve post-checkout hook, pass something else to indicate the\nworktree add operation\n\nWe also pass the current working directory where 'worktree add' is\nexecuted, so the user can copy selected files from the \"source\"\nworktree if they want.\n\n3) add a new post-worktree-add hook\n\nPretty much like 2 except that we separate the two. But I don't see\nmuch point in adding this after reading that post-checkout hook is\nalso executed in git-clone.\n\nComments?\n-- \nDuy\n"},{"id":"276553","messageId":"xmqqy4bhv7za.fsf@gitster.mtv.corp.google.com","threadId":"41239","inReplyTo":"CACsJy8C9OELrkHZLzwoRx26AtzVvgouRA2+m0VH7GrJGSA8PCQ@mail.gmail.com","subject":"Re: Add post-worktree-add hook?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-01-22T17:28:57Z","receivedAt":"2016-01-22T17:28:57Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Duy Nguyen <pclouds@gmail.com> writes:\n\n> I started moving my git work space to multi-worktree and found it\n> annoying that every time I add a new worktree, my first step must be\n> copy my config.mak over. Room for improvement. I see three options:\n\n4) none of the above.\n\nEverybody should learn to think before uttering post-X hook the\nfollowing:\n\n * Is X an end user initiated action?\n\n * What does the hypothetical post-X hook need to decide what to do?\n   If it needs to change behaviour based on what X did, does it need\n   more than what it can get by observing its outcome (i.e. exit\n   status and what is left in the working tree and the repository)?\n\n * Does the hypothetical post-X hook need other end-user supplied\n   customization beyond what argument the end user gave to run X?\n\nThe answer to these questions would often reveal that post-X hook is\na bad idea and you are much better off with a wrapper script that\nruns X as the first thing (and the remainder can do different things\nbased on the outcome of X if you wanted it to).\n"}]}