{"thread":{"id":"26455","subject":"Advices to imlement update hook","startedAt":"2011-02-09T16:27:07Z","lastAt":"2011-02-10T13:24:49Z","messageCount":6,"participants":["Francis Moreau","Johannes Sixt","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"160770","messageId":"AANLkTimdsCgNBAnJmnzGj3M3Q4RPb==fiWu1+ZQhWenO@mail.gmail.com","threadId":"26455","inReplyTo":null,"subject":"Advices to imlement update hook","fromName":"Francis Moreau","fromEmail":"francis.moro@gmail.com","sentAt":"2011-02-09T16:27:07Z","receivedAt":"2011-02-09T16:27:07Z","isPatch":false,"sender":{"key":"francis.moro@gmail.com","avatar":null},"body":"Hi !\n\nI'd like to restrict access to one of my repos: the project tracked by\nit has several directories: a/ b/ c/ and I'd like to allow only\nmodifications happen in b/ directory.\n\nI'm planning to use git hooks, not sure which one I should use: if the\ncheck should happen at the commit or push time or both.\n\nFor now I'm going to use the update hook, so it will happen when pushing.\n\nNow the question is: what is the best way to do this ?\n\nI'm planning to use something equivalent to \"git-diff-tree oldref\nnewref | { grep -v b || exit 1; }\" but doesn't look like the best git\nway.\n\nBTW, from the git-diff-tree manpage:\n\n\t<path>...\n\t    If provided, the results are limited to a subset of\n\t    files matching one of these prefix strings. i.e., file\n\t    matches /^<pattern1>|<pattern2>|.../ Note that this\n\t    parameter does not provide any wildcard or regexp\n\t    features.\n\nWhat does it mean exactly ? what does 'pattern' word mean if wildcard\nor regexp is not supported ?\nI also tried:\n\n   git diff-tree <oldref> <newref> -- ^b || exit 1\n\nbut it doesn't work.\n\nCould anybody give me some advices ?\n\nThanks\n-- \nFrancis\n"},{"id":"160771","messageId":"4D52C2FA.2030103@viscovery.net","threadId":"26455","inReplyTo":"AANLkTimdsCgNBAnJmnzGj3M3Q4RPb==fiWu1+ZQhWenO@mail.gmail.com","subject":"Re: Advices to imlement update hook","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2011-02-09T16:38:18Z","receivedAt":"2011-02-09T16:38:18Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 2/9/2011 17:27, schrieb Francis Moreau:\n> Hi !\n> \n> I'd like to restrict access to one of my repos: the project tracked by\n> it has several directories: a/ b/ c/ and I'd like to allow only\n> modifications happen in b/ directory.\n> \n> I'm planning to use git hooks, not sure which one I should use: if the\n> check should happen at the commit or push time or both.\n> \n> For now I'm going to use the update hook, so it will happen when pushing.\n> \n> Now the question is: what is the best way to do this ?\n> \n> I'm planning to use something equivalent to \"git-diff-tree oldref\n> newref | { grep -v b || exit 1; }\" but doesn't look like the best git\n> way.\n> \n> BTW, from the git-diff-tree manpage:\n> \n> \t<path>...\n> \t    If provided, the results are limited to a subset of\n> \t    files matching one of these prefix strings. i.e., file\n> \t    matches /^<pattern1>|<pattern2>|.../ Note that this\n> \t    parameter does not provide any wildcard or regexp\n> \t    features.\n> \n> What does it mean exactly ? what does 'pattern' word mean if wildcard\n> or regexp is not supported ?\n> I also tried:\n> \n>    git diff-tree <oldref> <newref> -- ^b || exit 1\n> \n> but it doesn't work.\n\n  git diff-tree --quiet <oldref> <newref> -- b\n"},{"id":"160772","messageId":"4D52C403.30501@viscovery.net","threadId":"26455","inReplyTo":"4D52C2FA.2030103@viscovery.net","subject":"Re: Advices to imlement update hook","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2011-02-09T16:42:43Z","receivedAt":"2011-02-09T16:42:43Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"[Sorry, sent too early - fat fingers :-(]\n\nAm 2/9/2011 17:38, schrieb Johannes Sixt:\n> Am 2/9/2011 17:27, schrieb Francis Moreau:\n>> Hi !\n>>\n>> I'd like to restrict access to one of my repos: the project tracked by\n>> it has several directories: a/ b/ c/ and I'd like to allow only\n>> modifications happen in b/ directory.\n>>\n>> I'm planning to use git hooks, not sure which one I should use: if the\n>> check should happen at the commit or push time or both.\n...\n>> I also tried:\n>>\n>>    git diff-tree <oldref> <newref> -- ^b || exit 1\n>>\n>> but it doesn't work.\n> \n>   git diff-tree --quiet <oldref> <newref> -- b\n\nshould do it; it sets the exit code.\n\nBut don't you also want to inspect all commits between oldref and newref?\nSomeone could have modified the directory, and then reverted the\nmodification in a later commit. If these commits arrive in a single push,\nthe above code wouldn't notice this.\n\n-- Hannes\n"},{"id":"160773","messageId":"AANLkTik=Xw3b1i-AranJtfngOsfLvEDSzrMq3jKTy-Yy@mail.gmail.com","threadId":"26455","inReplyTo":"4D52C403.30501@viscovery.net","subject":"Re: Advices to imlement update hook","fromName":"Francis Moreau","fromEmail":"francis.moro@gmail.com","sentAt":"2011-02-09T16:51:24Z","receivedAt":"2011-02-09T16:51:24Z","isPatch":false,"sender":{"key":"francis.moro@gmail.com","avatar":null},"body":"On Wed, Feb 9, 2011 at 5:42 PM, Johannes Sixt <j.sixt@viscovery.net> wrote:\n> [Sorry, sent too early - fat fingers :-(]\n>\n> Am 2/9/2011 17:38, schrieb Johannes Sixt:\n>> Am 2/9/2011 17:27, schrieb Francis Moreau:\n>>> Hi !\n>>>\n>>> I'd like to restrict access to one of my repos: the project tracked by\n>>> it has several directories: a/ b/ c/ and I'd like to allow only\n>>> modifications happen in b/ directory.\n>>>\n>>> I'm planning to use git hooks, not sure which one I should use: if the\n>>> check should happen at the commit or push time or both.\n> ...\n>>> I also tried:\n>>>\n>>>    git diff-tree <oldref> <newref> -- ^b || exit 1\n>>>\n>>> but it doesn't work.\n>>\n>>   git diff-tree --quiet <oldref> <newref> -- b\n>\n> should do it; it sets the exit code.\n\nbut does that work if a commit modify b/ and another directory ?\n\n> But don't you also want to inspect all commits between oldref and newref?\n\nYes I want to inspect all commits in the range.\n\n> Someone could have modified the directory, and then reverted the\n> modification in a later commit. If these commits arrive in a single push,\n> the above code wouldn't notice this.\n\nI agree but I thought that git diff-tree would list all changes made\nbetween the 2 refs.\n\nThanks\n-- \nFrancis\n"},{"id":"160775","messageId":"20110209170535.GA5254@sigill.intra.peff.net","threadId":"26455","inReplyTo":"AANLkTik=Xw3b1i-AranJtfngOsfLvEDSzrMq3jKTy-Yy@mail.gmail.com","subject":"Re: Advices to imlement update hook","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-02-09T17:05:35Z","receivedAt":"2011-02-09T17:05:35Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Feb 09, 2011 at 05:51:24PM +0100, Francis Moreau wrote:\n\n> >>>    git diff-tree <oldref> <newref> -- ^b || exit 1\n> >>>\n> >>> but it doesn't work.\n> >>\n> >>   git diff-tree --quiet <oldref> <newref> -- b\n> >\n> > should do it; it sets the exit code.\n> \n> but does that work if a commit modify b/ and another directory ?\n\nNo, it just looks for commits that modified b. There is currently no way\nto specify a path to say \"commit that did not modify b\". You need to\ncheck the output of:\n\n  git rev-list | git diff-tree --stdin -m --name-only\n\nwhich should list all paths modified by all commits. And then you can\neither blacklist or whitelist as appropriate (note that the names can be\nquoted; you might want to look at the \"-z\" option and do your\nlist-checking in perl).\n\n> > But don't you also want to inspect all commits between oldref and newref?\n> \n> Yes I want to inspect all commits in the range.\n\nsee above.\n\n> > Someone could have modified the directory, and then reverted the\n> > modification in a later commit. If these commits arrive in a single push,\n> > the above code wouldn't notice this.\n> \n> I agree but I thought that git diff-tree would list all changes made\n> between the 2 refs.\n\nBetween the two endpoints. It won't even look at the commits in the\nmiddle, so as long as a later middle commit reverts the change of an\nearlier middle commit, the endpoints won't be affected.\n\n-Peff\n"},{"id":"160822","messageId":"AANLkTin0p77wd3dOdF6h3+Gw7vphj=CTvn0UUtRwf5un@mail.gmail.com","threadId":"26455","inReplyTo":"20110209170535.GA5254@sigill.intra.peff.net","subject":"Re: Advices to imlement update hook","fromName":"Francis Moreau","fromEmail":"francis.moro@gmail.com","sentAt":"2011-02-10T13:24:49Z","receivedAt":"2011-02-10T13:24:49Z","isPatch":false,"sender":{"key":"francis.moro@gmail.com","avatar":null},"body":"Hello,\n\nOn Wed, Feb 9, 2011 at 6:05 PM, Jeff King <peff@peff.net> wrote:\n> On Wed, Feb 09, 2011 at 05:51:24PM +0100, Francis Moreau wrote:\n>\n>> >>>    git diff-tree <oldref> <newref> -- ^b || exit 1\n>> >>>\n>> >>> but it doesn't work.\n>> >>\n>> >>   git diff-tree --quiet <oldref> <newref> -- b\n>> >\n>> > should do it; it sets the exit code.\n>>\n>> but does that work if a commit modify b/ and another directory ?\n>\n> No, it just looks for commits that modified b. There is currently no way\n> to specify a path to say \"commit that did not modify b\". You need to\n> check the output of:\n>\n>  git rev-list | git diff-tree --stdin -m --name-only\n>\n> which should list all paths modified by all commits. And then you can\n> either blacklist or whitelist as appropriate (note that the names can be\n> quoted; you might want to look at the \"-z\" option and do your\n> list-checking in perl).\n>\n>> > But don't you also want to inspect all commits between oldref and newref?\n>>\n>> Yes I want to inspect all commits in the range.\n>\n> see above.\n>\n>> > Someone could have modified the directory, and then reverted the\n>> > modification in a later commit. If these commits arrive in a single push,\n>> > the above code wouldn't notice this.\n>>\n>> I agree but I thought that git diff-tree would list all changes made\n>> between the 2 refs.\n>\n> Between the two endpoints. It won't even look at the commits in the\n> middle, so as long as a later middle commit reverts the change of an\n> earlier middle commit, the endpoints won't be affected.\n\nOh, I see. I undestand why the git-rev-list is needed now.\n\nThanks for your help !\n-- \nFrancis\n"}]}