{"thread":{"id":"29507","subject":"rebase -i reword runs pre-commit hook with curious results","startedAt":"2012-02-01T21:50:49Z","lastAt":"2012-02-02T16:39:55Z","messageCount":3,"participants":["Neal Kreitzinger","Andrew Wong"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"183501","messageId":"jgcc3q$mvl$1@dough.gmane.org","threadId":"29507","inReplyTo":null,"subject":"rebase -i reword runs pre-commit hook with curious results","fromName":"Neal Kreitzinger","fromEmail":"neal@rsss.com","sentAt":"2012-02-01T21:50:49Z","receivedAt":"2012-02-01T21:50:49Z","isPatch":false,"sender":{"key":"neal@rsss.com","avatar":null},"body":"I'm confused on why and/or how interactive rebase runs the pre-commit hook \nwhen doing the reword command for commit (a).  My pre-commit hook does \nkeyword expansion on the worktree copy of the modified index files and then \nre-adds them to effect a user-date-stamp when committed.  However, the \nuser-date-stamps don't get updated when reword runs the pre-commit hook. \nIOW, the pre-commit hook does not get the same results as if I were doing a \ncommandline git-commit of a modified index.  I suppose reword is protecting \nthe preservation of all the contents of commit (a) except the commit message \nwhich makes sense, but I don't understand how it goes about doing this while \nstill attempting to somehow honor the pre-commit hook.  (git 1.7.1)\n\nv/r,\nneal \n"},{"id":"183545","messageId":"4F2A2286.3090808@sohovfx.com","threadId":"29507","inReplyTo":"jgcc3q$mvl$1@dough.gmane.org","subject":"Re: rebase -i reword runs pre-commit hook with curious results","fromName":"Andrew Wong","fromEmail":"andrew.w@sohovfx.com","sentAt":"2012-02-02T05:43:34Z","receivedAt":"2012-02-02T05:43:34Z","isPatch":false,"sender":{"key":"andrew.w@sohovfx.com","avatar":null},"body":"On 12-02-01 4:50 PM, Neal Kreitzinger wrote:\n> I'm confused on why and/or how interactive rebase runs the pre-commit hook\n> when doing the reword command for commit (a).\nWhen you do a \"reword\" in \"rebase -i\", it basically does a \"cherry-pick\" \nof that commit first, then it does a \"commit --amend\". And your \npre-commit hook should've been run during the amend.\n> IOW, the pre-commit hook does not get the same results as if I were doing a\n> commandline git-commit of a modified index.\nDoes your pre-commit hook work when doing a \"commit --amend\"? I'm not \nsure if you can actually modify the author (or committer) date from \ninside a pre-commit hook.\n"},{"id":"183613","messageId":"4F2ABC5B.2030608@gmail.com","threadId":"29507","inReplyTo":"4F2A2286.3090808@sohovfx.com","subject":"Re: rebase -i reword runs pre-commit hook with curious results","fromName":"Neal Kreitzinger","fromEmail":"nkreitzinger@gmail.com","sentAt":"2012-02-02T16:39:55Z","receivedAt":"2012-02-02T16:39:55Z","isPatch":false,"sender":{"key":"nkreitzinger@gmail.com","avatar":null},"body":"On 2/1/2012 11:43 PM, Andrew Wong wrote:\n> On 12-02-01 4:50 PM, Neal Kreitzinger wrote:\n>> I'm confused on why and/or how interactive rebase runs the pre-commit\n>> hook\n>> when doing the reword command for commit (a).\n> When you do a \"reword\" in \"rebase -i\", it basically does a \"cherry-pick\"\n> of that commit first, then it does a \"commit --amend\". And your\n> pre-commit hook should've been run during the amend.\n>> IOW, the pre-commit hook does not get the same results as if I were\n>> doing a\n>> commandline git-commit of a modified index.\n> Does your pre-commit hook work when doing a \"commit --amend\"? I'm not\n> sure if you can actually modify the author (or committer) date from\n> inside a pre-commit hook.\n(We have a comment on \"line 1\" in our source with $User:$ $Date:$ \nkeywords that the pre-commit hooks expands to insert \"whoami\" and \"date\" \nvalues to effect a user-datestamp at commit time.  We do this to enforce \nconflicts on same-file edits.)  Now that I understand that the \ncherry-pick takes place first to effect the transfer of the tree content \nand then a subsequent git-commit --amend of \"no changes\" takes place to \neffect the reword opportunity, the behavior makes sense now.  (We use \ngit-commit --amend to reword commit messages also.)  The pre-commit hook \nruns prior to commit message editor just like commandline git-commit \n--amend (and plain git-commit).\n\nthanks!\n\nv/r,\nneal\n"}]}