* How to bypass the post-commit hook? @ 2007-12-30 15:12 Ping Yin 2007-12-30 21:50 ` Jan Hudec 0 siblings, 1 reply; 9+ messages in thread From: Ping Yin @ 2007-12-30 15:12 UTC (permalink / raw) To: Git Mailing List --no-verify can bypass pre-commit hook? Then how to bypass post-commit hook? Usually I want post-commit take effect. However, in the middle of git-rebase, i want to bypass post-commit when 'git-commit --amend' since my post-commit hooks will modify the working directory and so make following rebase troubesome. -- Ping Yin ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How to bypass the post-commit hook? 2007-12-30 15:12 How to bypass the post-commit hook? Ping Yin @ 2007-12-30 21:50 ` Jan Hudec [not found] ` <46dff0320712302108i61f3b868obb93f89c1c24062c@mail.gmail.com> 2007-12-31 9:50 ` Pascal Obry 0 siblings, 2 replies; 9+ messages in thread From: Jan Hudec @ 2007-12-30 21:50 UTC (permalink / raw) To: Ping Yin; +Cc: Git Mailing List [-- Attachment #1: Type: text/plain, Size: 710 bytes --] On Sun, Dec 30, 2007 at 23:12:12 +0800, Ping Yin wrote: > --no-verify can bypass pre-commit hook? Then how to bypass post-commit hook? > > Usually I want post-commit take effect. However, in the middle of > git-rebase, i want to bypass post-commit when 'git-commit --amend' > since my post-commit hooks will modify the working directory and so > make following rebase troubesome. There does not seem to be an option to do it, but you can always temporarily disable it (unset the executable permission on it). By the way, what is your post-commit hook doing anyway? Modifying the work tree *after* a commit does not sound like a common thing to do. -- Jan 'Bulb' Hudec <bulb@ucw.cz> [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <46dff0320712302108i61f3b868obb93f89c1c24062c@mail.gmail.com>]
* Re: How to bypass the post-commit hook? [not found] ` <46dff0320712302108i61f3b868obb93f89c1c24062c@mail.gmail.com> @ 2007-12-31 9:31 ` Jan Hudec [not found] ` <46dff0320712310222m64d86e95l1499a7ffb1fff65c@mail.gmail.com> 0 siblings, 1 reply; 9+ messages in thread From: Jan Hudec @ 2007-12-31 9:31 UTC (permalink / raw) To: Ping Yin; +Cc: Git Mailing List [-- Attachment #1: Type: text/plain, Size: 1795 bytes --] On Mon, Dec 31, 2007 at 13:08:05 +0800, Ping Yin wrote: > On Dec 31, 2007 5:50 AM, Jan Hudec <bulb@ucw.cz> wrote: > > > > On Sun, Dec 30, 2007 at 23:12:12 +0800, Ping Yin wrote: > > > --no-verify can bypass pre-commit hook? Then how to bypass post-commit hook? > > > > > > Usually I want post-commit take effect. However, in the middle of > > > git-rebase, i want to bypass post-commit when 'git-commit --amend' > > > since my post-commit hooks will modify the working directory and so > > > make following rebase troubesome. > > > > There does not seem to be an option to do it, but you can always temporarily > > disable it (unset the executable permission on it). > > > > By the way, what is your post-commit hook doing anyway? Modifying the work > > tree *after* a commit does not sound like a common thing to do. > > > I have already considered disabling hook temporarily, but it is a > little annoying. Well, I guess noone thought it would be useful to disable it. > I use post-commit because i don't find a better way to update imported > css version automatically > > $ cat foo.css > @import url(bar.css?57e708) > ... > > When i modify bar.css and then commit it ( with blob sha1 bf7059),I > use post-commit to modify foo.css > $ cat foo.css > @import url(bar.css?bf7059) > ... But that file is not versioned, is it? Because if it is, you want to commit it in the very same commit as bar.css and therefore want to do it in the *pre*-commit hook. Since obviously the foo.css wants to include the current version of bar.css, not the previous one. Note, that while you don't know the commit sha1 before the commit, you do know the *blob* sha1s. So you can do this change in pre-commit hook. -- Jan 'Bulb' Hudec <bulb@ucw.cz> [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <46dff0320712310222m64d86e95l1499a7ffb1fff65c@mail.gmail.com>]
* Re: How to bypass the post-commit hook? [not found] ` <46dff0320712310222m64d86e95l1499a7ffb1fff65c@mail.gmail.com> @ 2007-12-31 10:55 ` Jan Hudec 2007-12-31 13:26 ` Ping Yin 0 siblings, 1 reply; 9+ messages in thread From: Jan Hudec @ 2007-12-31 10:55 UTC (permalink / raw) To: Ping Yin; +Cc: Git Mailing List On Mon, Dec 31, 2007 at 18:22:37 +0800, Ping Yin wrote: > On Dec 31, 2007 5:31 PM, Jan Hudec <bulb@ucw.cz> wrote: > > On Mon, Dec 31, 2007 at 13:08:05 +0800, Ping Yin wrote: > > > On Dec 31, 2007 5:50 AM, Jan Hudec <bulb@ucw.cz> wrote: > > Well, I guess noone thought it would be useful to disable it. > > > > > I use post-commit because i don't find a better way to update imported > > > css version automatically > > > > > > $ cat foo.css > > > @import url(bar.css?57e708) > > > ... > > > > > > When i modify bar.css and then commit it ( with blob sha1 bf7059),I > > > use post-commit to modify foo.css > > > $ cat foo.css > > > @import url(bar.css?bf7059) > > > ... > > > > But that file is not versioned, is it? > > > No, bar.css is also versioned > > > Because if it is, you want to commit it in the very same commit as bar.css > > and therefore want to do it in the *pre*-commit hook. Since obviously the > > foo.css wants to include the current version of bar.css, not the previous > > one. > > If this happens, i have to commit twice (the last is amend) Therefore the refered commit is dropped on the floor and will be eventually expired. So using commit id of an amended commit was an error. > > Note, that while you don't know the commit sha1 before the commit, you do > > know the *blob* sha1s. So you can do this change in pre-commit hook. > > I chose post-commit because i used commit sha1 instead of blob sha1 as > file version in the first time, and now pre-commit seems better. One > more question, I use 'git ls-files' to fetch the blob sha1, so is the > got sha1 the same when pre-commit and post-commit? Yes, it should be. Commit might be preparing the index to commit under different name than default, but it will export GIT_INDEX_FILE environment variable to the pre-commit hook and git commands you call will know to take the index from there. Note, that you can -- and should -- add the foo.css to the commit. But the file might contain other changes in tree, that are not about to be commited, so prefered way would be to get the content from the index, modify that and update the index manually (with git update-index). -- Jan 'Bulb' Hudec <bulb@ucw.cz> ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How to bypass the post-commit hook? 2007-12-31 10:55 ` Jan Hudec @ 2007-12-31 13:26 ` Ping Yin 2007-12-31 17:05 ` Jan Hudec 0 siblings, 1 reply; 9+ messages in thread From: Ping Yin @ 2007-12-31 13:26 UTC (permalink / raw) To: Jan Hudec; +Cc: Git Mailing List On Dec 31, 2007 6:55 PM, Jan Hudec <bulb@ucw.cz> wrote: > On Mon, Dec 31, 2007 at 18:22:37 +0800, Ping Yin wrote: > > On Dec 31, 2007 5:31 PM, Jan Hudec <bulb@ucw.cz> wrote: > > > On Mon, Dec 31, 2007 at 13:08:05 +0800, Ping Yin wrote: > > > Note, that while you don't know the commit sha1 before the commit, you do > > > know the *blob* sha1s. So you can do this change in pre-commit hook. > > > > I chose post-commit because i used commit sha1 instead of blob sha1 as > > file version in the first time, and now pre-commit seems better. One > > more question, I use 'git ls-files' to fetch the blob sha1, so is the > > got sha1 the same when pre-commit and post-commit? > > Yes, it should be. > Good news. So pre-commit is actually the right choice. > > Note, that you can -- and should -- add the foo.css to the commit. But the > file might contain other changes in tree, that are not about to be commited, > so prefered way would be to get the content from the index, modify that and > update the index manually (with git update-index). If pre-commit has modified files to be commited, it will abort this commit and give a message to direct the user to commit again with/without the changed content. AFAIK, git add -i can add selected chunk to the index. As you said, can git-update-index also do this job? -- Ping Yin ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How to bypass the post-commit hook? 2007-12-31 13:26 ` Ping Yin @ 2007-12-31 17:05 ` Jan Hudec 2007-12-31 17:53 ` Ping Yin 0 siblings, 1 reply; 9+ messages in thread From: Jan Hudec @ 2007-12-31 17:05 UTC (permalink / raw) To: Ping Yin; +Cc: Git Mailing List On Mon, Dec 31, 2007 at 21:26:21 +0800, Ping Yin wrote: > On Dec 31, 2007 6:55 PM, Jan Hudec <bulb@ucw.cz> wrote: > > Note, that you can -- and should -- add the foo.css to the commit. But the > > file might contain other changes in tree, that are not about to be commited, > > so prefered way would be to get the content from the index, modify that and > > update the index manually (with git update-index). > > If pre-commit has modified files to be commited, it will abort this > commit and give a message to direct the user to commit again > with/without the changed content. > > AFAIK, git add -i can add selected chunk to the index. As you said, > can git-update-index also do this job? git update-index is the underlying plumbing for git add/git rm. However, you should change foo.css in index even if the working tree copy does not match it and is not selected for commit. Only way I see to do that is to prepare a patch and apply it to both the working tree (git apply) and to the index (git apply --cached). It will probably work for you without such finesse, you will just have to be aware of it's quirks. -- Jan 'Bulb' Hudec <bulb@ucw.cz> ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How to bypass the post-commit hook? 2007-12-31 17:05 ` Jan Hudec @ 2007-12-31 17:53 ` Ping Yin 0 siblings, 0 replies; 9+ messages in thread From: Ping Yin @ 2007-12-31 17:53 UTC (permalink / raw) To: Jan Hudec; +Cc: Git Mailing List On Jan 1, 2008 1:05 AM, Jan Hudec <bulb@ucw.cz> wrote: > On Mon, Dec 31, 2007 at 21:26:21 +0800, Ping Yin wrote: > > On Dec 31, 2007 6:55 PM, Jan Hudec <bulb@ucw.cz> wrote: > > > Note, that you can -- and should -- add the foo.css to the commit. But the > > > file might contain other changes in tree, that are not about to be commited, > > > so prefered way would be to get the content from the index, modify that and > > > update the index manually (with git update-index). > > > > If pre-commit has modified files to be commited, it will abort this > > commit and give a message to direct the user to commit again > > with/without the changed content. > > > > AFAIK, git add -i can add selected chunk to the index. As you said, > > can git-update-index also do this job? > > git update-index is the underlying plumbing for git add/git rm. > > However, you should change foo.css in index even if the working tree copy > does not match it and is not selected for commit. Only way I see to do that > is to prepare a patch and apply it to both the working tree (git apply) and > to the index (git apply --cached). > A little complicated-:). So my way is to abort the commit if pre-commit actually modified the files ( the working tree, not the index) to be commited, then 'git add -i' to add the changes introduced just by the pre-commit and 'git commit' again. -- Ping Yin ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How to bypass the post-commit hook? 2007-12-30 21:50 ` Jan Hudec [not found] ` <46dff0320712302108i61f3b868obb93f89c1c24062c@mail.gmail.com> @ 2007-12-31 9:50 ` Pascal Obry 2008-01-14 17:59 ` Jan Hudec 1 sibling, 1 reply; 9+ messages in thread From: Pascal Obry @ 2007-12-31 9:50 UTC (permalink / raw) To: Jan Hudec; +Cc: Ping Yin, Git Mailing List Jan Hudec a écrit : > By the way, what is your post-commit hook doing anyway? Modifying the work > tree *after* a commit does not sound like a common thing to do. Or just trigger a build via a built robot or record a commit information into an issue tracker... Pascal. -- --|------------------------------------------------------ --| Pascal Obry Team-Ada Member --| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE --|------------------------------------------------------ --| http://www.obry.net --| "The best way to travel is by means of imagination" --| --| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How to bypass the post-commit hook? 2007-12-31 9:50 ` Pascal Obry @ 2008-01-14 17:59 ` Jan Hudec 0 siblings, 0 replies; 9+ messages in thread From: Jan Hudec @ 2008-01-14 17:59 UTC (permalink / raw) To: Pascal Obry; +Cc: Ping Yin, Git Mailing List On Mon, Dec 31, 2007 at 10:50:27 +0100, Pascal Obry wrote: > Jan Hudec a écrit : > > By the way, what is your post-commit hook doing anyway? Modifying the work > > tree *after* a commit does not sound like a common thing to do. > > Or just trigger a build via a built robot or record a commit information > into an issue tracker... That's not a case of "modifying a work tree *after* a commit". There are many valid uses for post-commit hook and this is one of them. But like the others it does not modify versioned files. That was the issue discussed (and pre-commit indeed turned out a better match). -- Jan 'Bulb' Hudec <bulb@ucw.cz> ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2008-01-14 18:00 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2007-12-30 15:12 How to bypass the post-commit hook? Ping Yin 2007-12-30 21:50 ` Jan Hudec [not found] ` <46dff0320712302108i61f3b868obb93f89c1c24062c@mail.gmail.com> 2007-12-31 9:31 ` Jan Hudec [not found] ` <46dff0320712310222m64d86e95l1499a7ffb1fff65c@mail.gmail.com> 2007-12-31 10:55 ` Jan Hudec 2007-12-31 13:26 ` Ping Yin 2007-12-31 17:05 ` Jan Hudec 2007-12-31 17:53 ` Ping Yin 2007-12-31 9:50 ` Pascal Obry 2008-01-14 17:59 ` Jan Hudec
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).