Re: [git-users] Re: Need sine help on Git hooks
Yeah I kept my hook in $Git_dir/hooks and made the file as executable I have written code to check the latest commit message enforce with jira ticket otherwise push should reject. On Dec 7, 2016 6:27 PM, "Konstantin Khomoutov" < flatw...@users.sourceforge.net> wrote: On Wed, 7 Dec 2016 17:34:27 +0530 Mrudula Varimaduguwrote: > Still not working. > I tried by keeping die("Kaboom!\n"); in the pre-receive file. > but still it pushed my commit, it didn't fail. > see the output below when I tried individually ./pre-receive it > printed Kaboom and it came out, but when I try to push it didnt. > > $ ./pre-receive > Kaboom! [...] > $ git add gitHooks/pre-receive > $ git commit -m "hook test" > $ git push origin feature/DD-157-pre-recieve-hook-to-force-jira-ticket [...] I'm not sure I follow. What's the point of committing a hook file and then pushing it out? Hooks are enabled in the remote repository -- that one which receives the push. Enabling a hook amounts of linking/creating a file with the name matching that of the hook under a special directory in the repository's "Git directory"; let's cite the entry section from the "githooks" manual page: | Hooks are little scripts you can place in $GIT_DIR/hooks | directory to trigger action at certain points. When git init is run, | a handful of example hooks are copied into the hooks directory of the | new repository, but by default they are all disabled. To enable a | hook, rename it by removing its .sample suffix. | | Note It is also a requirement for a given hook to be executable. | However - in a freshly initialized repository - the .sample files are | executable by default. Are you sure you do with your hook what's written there? Do you understand how hooks work? [...] -- You received this message because you are subscribed to the Google Groups "Git for human beings" group. To unsubscribe from this group and stop receiving emails from it, send an email to git-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [git-users] Re: Need sine help on Git hooks
On Wed, 7 Dec 2016 17:34:27 +0530 Mrudula Varimaduguwrote: > Still not working. > I tried by keeping die("Kaboom!\n"); in the pre-receive file. > but still it pushed my commit, it didn't fail. > see the output below when I tried individually ./pre-receive it > printed Kaboom and it came out, but when I try to push it didnt. > > $ ./pre-receive > Kaboom! [...] > $ git add gitHooks/pre-receive > $ git commit -m "hook test" > $ git push origin feature/DD-157-pre-recieve-hook-to-force-jira-ticket [...] I'm not sure I follow. What's the point of committing a hook file and then pushing it out? Hooks are enabled in the remote repository -- that one which receives the push. Enabling a hook amounts of linking/creating a file with the name matching that of the hook under a special directory in the repository's "Git directory"; let's cite the entry section from the "githooks" manual page: | Hooks are little scripts you can place in $GIT_DIR/hooks | directory to trigger action at certain points. When git init is run, | a handful of example hooks are copied into the hooks directory of the | new repository, but by default they are all disabled. To enable a | hook, rename it by removing its .sample suffix. | | Note It is also a requirement for a given hook to be executable. | However - in a freshly initialized repository - the .sample files are | executable by default. Are you sure you do with your hook what's written there? Do you understand how hooks work? [...] -- You received this message because you are subscribed to the Google Groups "Git for human beings" group. To unsubscribe from this group and stop receiving emails from it, send an email to git-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [git-users] Re: Need sine help on Git hooks
Hi Still not working. I tried by keeping die("Kaboom!\n"); in the pre-receive file. but still it pushed my commit, it didn't fail. see the output below when I tried individually ./pre-receive it printed Kaboom and it came out, but when I try to push it didnt. $ ./pre-receive Kaboom! mvari (GIT_DIR!) $ cd ../.. mvari $ git add gitHooks/pre-receive mvari $ git commit -m "hook test" [feature/DD-157-pre-recieve-hook-to-force-jira-ticket 2341484] hook test Committer: Mrudula VariYour name and email address were configured automatically based on your username and hostname. Please check that they are accurate. You can suppress this message by setting them explicitly: git config --global user.name "Your Name" git config --global user.email y...@example.com After doing this, you may fix the identity used for this commit with: git commit --amend --reset-author 1 file changed, 1 insertion(+) mvari $ git push origin feature/DD-157-pre-recieve-hook-to-force-jira-ticket Counting objects: 4, done. Delta compression using up to 2 threads. Compressing objects: 100% (4/4), done. Writing objects: 100% (4/4), 376 bytes | 0 bytes/s, done. Total 4 (delta 3), reused 0 (delta 0) remote: remote: Create pull request for feature/DD-157-pre-recieve-hook-to-force-jira-ticket: remote: https://bitbucket.fitchratings.com/projects/FRC/repos/fitchgroup_confluence_cookbook/compare/commits?sourceBranch=refs/heads/feature/DD-157-pre-recieve-hook-to-force-jira-ticket remote: To https://bitbucket.fitchratings.com/scm/frc/fitchgroup_confluence_cookbook.git 03d020d..2341484 feature/DD-157-pre-recieve-hook-to-force-jira-ticket -> feature/DD-157-pre-recieve-hook-to-force-jira-ticket mvari $ On Wed, Dec 7, 2016 at 5:04 PM, Konstantin Khomoutov < flatw...@users.sourceforge.net> wrote: > On Wed, 7 Dec 2016 02:58:22 -0800 (PST) > mrudula.varimad...@gmail.com wrote: > > > I tried the below, > > when I am individually running ./pre-receive its working, but when I > > try to push even If am not giving jirs issue its pushing to remote. > > Please help me on this > > Good to know you actually tried to solve it; congrats with this! > > The way to debug such things out is to start small: in the end, you > want your hook to fail the push operation? OK, let's just test > that: what happens if you put > > die("Kaboom!\n"); > > right after the shebang line (that "#!/usr/bin/perl" thing)? > > As you can see, it should do two things: > > 1) Write "Kaboom" + LF to the standard error stream. > 2) Die with code 255 preventing Git from carrying out its task. > > If it will still not work, you have a problem actually enabling your > hook; or something else preventing it from running. > > If it works, you have an error in the script's logic. > > All in all, let's try what I suggested first and see what happens. > > > > > #!/usr/bin/perl > > > > # Force JIRA ticket in commit messages > > > > my $errors = 0; > > > > chomp(my @commits = `git rev-parse --abbrev-ref HEAD`); > > if ($?) { > > warn "git rev-list $old..$new failed\n"; > > ++$errors, next; > > } > > > > foreach my $sha1 (@commits) { > > my $msg = `git cat-file commit $sha1`; > > if ($?) { > > warn "git cat-file commit $sha1 failed"; > > ++$errors, next; > > } > > > > $msg =~ s/\A.+? ^$ \s+//smx; > > unless ($msg =~ /^[A-Z]+-[0-9]/) { > > warn "The git commit message for $sha1\n"; > > warn "must be prepended with a valid JIRA key.\n"; > > warn "Use CAPS for the project key.\n"; > > warn "For example:\n"; > > warn "KEY-123: $msg\n"; > > warn "Use \"git commit --amend -m\" to fix the message or\n"; > > warn "\"git rebase\" if you are pushing multiple commits.\n"; > > > > ++$errors, next; > > } > > } > > > > > > exit $errors == 0 ? 0 : 1; > [...] > > -- You received this message because you are subscribed to the Google Groups "Git for human beings" group. To unsubscribe from this group and stop receiving emails from it, send an email to git-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [git-users] Re: Need sine help on Git hooks
On Wed, 7 Dec 2016 02:58:22 -0800 (PST) mrudula.varimad...@gmail.com wrote: > I tried the below, > when I am individually running ./pre-receive its working, but when I > try to push even If am not giving jirs issue its pushing to remote. > Please help me on this Good to know you actually tried to solve it; congrats with this! The way to debug such things out is to start small: in the end, you want your hook to fail the push operation? OK, let's just test that: what happens if you put die("Kaboom!\n"); right after the shebang line (that "#!/usr/bin/perl" thing)? As you can see, it should do two things: 1) Write "Kaboom" + LF to the standard error stream. 2) Die with code 255 preventing Git from carrying out its task. If it will still not work, you have a problem actually enabling your hook; or something else preventing it from running. If it works, you have an error in the script's logic. All in all, let's try what I suggested first and see what happens. > > #!/usr/bin/perl > > # Force JIRA ticket in commit messages > > my $errors = 0; > > chomp(my @commits = `git rev-parse --abbrev-ref HEAD`); > if ($?) { > warn "git rev-list $old..$new failed\n"; > ++$errors, next; > } > > foreach my $sha1 (@commits) { > my $msg = `git cat-file commit $sha1`; > if ($?) { > warn "git cat-file commit $sha1 failed"; > ++$errors, next; > } > > $msg =~ s/\A.+? ^$ \s+//smx; > unless ($msg =~ /^[A-Z]+-[0-9]/) { > warn "The git commit message for $sha1\n"; > warn "must be prepended with a valid JIRA key.\n"; > warn "Use CAPS for the project key.\n"; > warn "For example:\n"; > warn "KEY-123: $msg\n"; > warn "Use \"git commit --amend -m\" to fix the message or\n"; > warn "\"git rebase\" if you are pushing multiple commits.\n"; > > ++$errors, next; > } > } > > > exit $errors == 0 ? 0 : 1; [...] -- You received this message because you are subscribed to the Google Groups "Git for human beings" group. To unsubscribe from this group and stop receiving emails from it, send an email to git-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [git-users] Re: Need sine help on Git hooks
I tried the below, when I am individually running ./pre-receive its working, but when I try to push even If am not giving jirs issue its pushing to remote. Please help me on this #!/usr/bin/perl # Force JIRA ticket in commit messages my $errors = 0; chomp(my @commits = `git rev-parse --abbrev-ref HEAD`); if ($?) { warn "git rev-list $old..$new failed\n"; ++$errors, next; } foreach my $sha1 (@commits) { my $msg = `git cat-file commit $sha1`; if ($?) { warn "git cat-file commit $sha1 failed"; ++$errors, next; } $msg =~ s/\A.+? ^$ \s+//smx; unless ($msg =~ /^[A-Z]+-[0-9]/) { warn "The git commit message for $sha1\n"; warn "must be prepended with a valid JIRA key.\n"; warn "Use CAPS for the project key.\n"; warn "For example:\n"; warn "KEY-123: $msg\n"; warn "Use \"git commit --amend -m\" to fix the message or\n"; warn "\"git rebase\" if you are pushing multiple commits.\n"; ++$errors, next; } } exit $errors == 0 ? 0 : 1; On Wednesday, December 7, 2016 at 4:05:20 PM UTC+5:30, Konstantin Khomoutov wrote: > > On Wed, 7 Dec 2016 02:27:12 -0800 (PST) > mrudula.v...@gmail.com wrote: > > > I am looking for this code. > > Can you provide me the full script/code after doing this changes > > No. I don't have any. > > But what have you tried [1] before asking for it? > > 1. http://whathaveyoutried.com > > > On Thursday, September 5, 2013 at 3:32:27 PM UTC+5:30, Konstantin > > Khomoutov wrote: > > > > > > On Wed, 4 Sep 2013 11:39:21 -0700 (PDT) > > > Lingwrote: > > > > > > > Thanks Konstantin, Yes I tried git log $newname $(git merge-base > > > > $oldname $newname) and it works fine. > > > > > > That is not quite correct a call -- the proper one is > > > > > > git log $newname ^$basename > > > > > > or, expanded, > > > > > > git log $newname ^$(git merge-base $oldname $newname) > > > > > > Notice the "^" character in front of the second commit -- it's > > > meaning is to exclude all commits reachable from the following > > > revision specification from the set of commits defined by the first > > > revision specification. > > > > > > See the "Specifying Ranges" section of the gitrevisions manual [1]. > > > > > > I, indeed, did not use "^" for the $basename argument in my > > > previous e-mail to this thread (from which you seem to have finally > > > copied the code), as I was in a hurry. My apologies for confusion. > > > > > > 1. > > > https://www.kernel.org/pub/software/scm/git/docs/gitrevisions.html > > > > -- You received this message because you are subscribed to the Google Groups "Git for human beings" group. To unsubscribe from this group and stop receiving emails from it, send an email to git-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [git-users] Re: Need sine help on Git hooks
On Wed, 7 Dec 2016 02:27:12 -0800 (PST) mrudula.varimad...@gmail.com wrote: > I am looking for this code. > Can you provide me the full script/code after doing this changes No. I don't have any. But what have you tried [1] before asking for it? 1. http://whathaveyoutried.com > On Thursday, September 5, 2013 at 3:32:27 PM UTC+5:30, Konstantin > Khomoutov wrote: > > > > On Wed, 4 Sep 2013 11:39:21 -0700 (PDT) > > Lingwrote: > > > > > Thanks Konstantin, Yes I tried git log $newname $(git merge-base > > > $oldname $newname) and it works fine. > > > > That is not quite correct a call -- the proper one is > > > > git log $newname ^$basename > > > > or, expanded, > > > > git log $newname ^$(git merge-base $oldname $newname) > > > > Notice the "^" character in front of the second commit -- it's > > meaning is to exclude all commits reachable from the following > > revision specification from the set of commits defined by the first > > revision specification. > > > > See the "Specifying Ranges" section of the gitrevisions manual [1]. > > > > I, indeed, did not use "^" for the $basename argument in my > > previous e-mail to this thread (from which you seem to have finally > > copied the code), as I was in a hurry. My apologies for confusion. > > > > 1. > > https://www.kernel.org/pub/software/scm/git/docs/gitrevisions.html > > -- You received this message because you are subscribed to the Google Groups "Git for human beings" group. To unsubscribe from this group and stop receiving emails from it, send an email to git-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [git-users] Re: Need sine help on Git hooks
Hi I am looking for this code. Can you provide me the full script/code after doing this changes On Thursday, September 5, 2013 at 3:32:27 PM UTC+5:30, Konstantin Khomoutov wrote: > > On Wed, 4 Sep 2013 11:39:21 -0700 (PDT) > Lingwrote: > > > Thanks Konstantin, Yes I tried git log $newname $(git merge-base > > $oldname $newname) and it works fine. > > That is not quite correct a call -- the proper one is > > git log $newname ^$basename > > or, expanded, > > git log $newname ^$(git merge-base $oldname $newname) > > Notice the "^" character in front of the second commit -- it's meaning > is to exclude all commits reachable from the following revision > specification from the set of commits defined by the first revision > specification. > > See the "Specifying Ranges" section of the gitrevisions manual [1]. > > I, indeed, did not use "^" for the $basename argument in my previous > e-mail to this thread (from which you seem to have finally copied the > code), as I was in a hurry. My apologies for confusion. > > 1. https://www.kernel.org/pub/software/scm/git/docs/gitrevisions.html > -- You received this message because you are subscribed to the Google Groups "Git for human beings" group. To unsubscribe from this group and stop receiving emails from it, send an email to git-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [git-users] Re: Need sine help on Git hooks
On Wed, 4 Sep 2013 11:39:21 -0700 (PDT) Ling oylf1...@gmail.com wrote: Thanks Konstantin, Yes I tried git log $newname $(git merge-base $oldname $newname) and it works fine. That is not quite correct a call -- the proper one is git log $newname ^$basename or, expanded, git log $newname ^$(git merge-base $oldname $newname) Notice the ^ character in front of the second commit -- it's meaning is to exclude all commits reachable from the following revision specification from the set of commits defined by the first revision specification. See the Specifying Ranges section of the gitrevisions manual [1]. I, indeed, did not use ^ for the $basename argument in my previous e-mail to this thread (from which you seem to have finally copied the code), as I was in a hurry. My apologies for confusion. 1. https://www.kernel.org/pub/software/scm/git/docs/gitrevisions.html -- You received this message because you are subscribed to the Google Groups Git for human beings group. To unsubscribe from this group and stop receiving emails from it, send an email to git-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[git-users] Re: Need sine help on Git hooks
Thanks Thomas, And yes I had read this and also I tried with git log but this won't works since git log is only created after the push, which means it won't compare the new push comment, it only compare the previous pushed comment to trigger the hooks. since what I need is trigger the hooks when new push comment not meet my prerequisites. Thanks Lingfei On Wednesday, September 4, 2013 2:52:15 AM UTC-4, Thomas Ferris Nicolaisen wrote: On Tuesday, September 3, 2013 10:34:38 PM UTC+2, Ling wrote: Hello, I'm kinds of new on Git and now we are trying to get the hooks enabled into one of our server repository, what we want this hooks doing is to prevent when local users that push the changes from their local repo to server repo, we need to first check the commit comments to see if it include some specific words, (i.e. 999). so what I tried is created an update hooks with compare the git log, but looks like this won't works correctly since this is only check the previous pushed comments. so I believe I will need to use pre-receive hook, but here is my quesiton? What is the basic flow for pre-receive hook for me to compare the local push commets with server existing comments? You're looking for the pre-receive or update hook. Read through http://git-scm.com/book/en/Customizing-Git-Git-Hooks#Server-Side-Hooks Here's an example showing inspection of the commit message: http://stackoverflow.com/questions/2524101/git-how-do-we-verify-commit-messages-for-a-push -- You received this message because you are subscribed to the Google Groups Git for human beings group. To unsubscribe from this group and stop receiving emails from it, send an email to git-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[git-users] Re: Need sine help on Git hooks
Thanks Thomas, And yes I had read this and also I tried with git log but this won't works since git log is only created after the push, which means it won't compare the new push comment, it only compare the previous pushed comment to trigger the hooks. since what I need is trigger the hooks when new push comment not meet my prerequisites. Thanks Ling On Wednesday, September 4, 2013 2:52:15 AM UTC-4, Thomas Ferris Nicolaisen wrote: On Tuesday, September 3, 2013 10:34:38 PM UTC+2, Ling wrote: Hello, I'm kinds of new on Git and now we are trying to get the hooks enabled into one of our server repository, what we want this hooks doing is to prevent when local users that push the changes from their local repo to server repo, we need to first check the commit comments to see if it include some specific words, (i.e. 999). so what I tried is created an update hooks with compare the git log, but looks like this won't works correctly since this is only check the previous pushed comments. so I believe I will need to use pre-receive hook, but here is my quesiton? What is the basic flow for pre-receive hook for me to compare the local push commets with server existing comments? You're looking for the pre-receive or update hook. Read through http://git-scm.com/book/en/Customizing-Git-Git-Hooks#Server-Side-Hooks Here's an example showing inspection of the commit message: http://stackoverflow.com/questions/2524101/git-how-do-we-verify-commit-messages-for-a-push -- You received this message because you are subscribed to the Google Groups Git for human beings group. To unsubscribe from this group and stop receiving emails from it, send an email to git-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[git-users] Re: Need sine help on Git hooks
On Wednesday, September 4, 2013 1:31:26 PM UTC+2, Ling wrote: Thanks Thomas, And yes I had read this and also I tried with git log but this won't works since git log is only created after the push, which means it won't compare the new push comment, it only compare the previous pushed comment to trigger the hooks. since what I need is trigger the hooks when new push comment not meet my prerequisites. Thanks Ling I'm not really sure what you mean. Can you share with us the hook you currently have and an example of where the behavior is unexpected? -- You received this message because you are subscribed to the Google Groups Git for human beings group. To unsubscribe from this group and stop receiving emails from it, send an email to git-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[git-users] Re: Need sine help on Git hooks
Hello Thomas, for example: This is the example hooks from http://stackoverflow.com/questions/2524101/git-how-do-we-verify-commit-messages-for-a-push that I tired: #!/bin/bash long_subject=$(git show master..Lingfei_test2 --pretty=format:%s | line | line | egrep 999) #long_subject=$(git log --pretty=tformat:%s | line | egrep 999) if [ -z $long_subject ]; then echo error: commit subject's comments not include '999' echo $long_subject exit 1 fi But when I tested on my local repo and tried to push the new changes into the server repo, and this update hooks is only check the previous commit comments since either git show/git log the latest commit comments is always the previous one that I pushed. Not sure if this is clear? and what I want is compare the new commit push comments to check if the comments are meet prerequisites, (let's say if the commit comments include '999', then the push success, else exit). Thanks Ling On Wednesday, September 4, 2013 7:39:41 AM UTC-4, Thomas Ferris Nicolaisen wrote: On Wednesday, September 4, 2013 1:31:26 PM UTC+2, Ling wrote: Thanks Thomas, And yes I had read this and also I tried with git log but this won't works since git log is only created after the push, which means it won't compare the new push comment, it only compare the previous pushed comment to trigger the hooks. since what I need is trigger the hooks when new push comment not meet my prerequisites. Thanks Ling I'm not really sure what you mean. Can you share with us the hook you currently have and an example of where the behavior is unexpected? -- You received this message because you are subscribed to the Google Groups Git for human beings group. To unsubscribe from this group and stop receiving emails from it, send an email to git-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [git-users] Re: Need sine help on Git hooks
On Wed, 4 Sep 2013 16:59:14 +0400 Konstantin Khomoutov flatw...@users.sourceforge.net wrote: [...] For each ref to be updated: 1) Call `git merge-base $oldname $newname` -- this will give you the name of a commit which is common between the old and the new state of the ref. In the simplest case -- a fast-forward of the ref this will be the old tip commit of that ref ($oldname here), in a more complex case, where a user did a forced push which replaced some (or all) of the ref's history, this will be the nearest (to the prospective new tip) commit which won't be replaced, and this means its log message has already been checked at some point back in time. 2) Having obtained this base commit, call git rev-list $newname ^$basename [...] 3) Iterate over the generated list, calling git cat-file -p $sha1name [...] I've just tried, and `git log $newname ^$basename` just did the right thing, so if you are okay with a coarse-grained approach, checking each ref reduces to grepping the output of git log $newname $(git merge-base $oldname $newname) (possibly further instrumented with approptiate --format command-line option). -- You received this message because you are subscribed to the Google Groups Git for human beings group. To unsubscribe from this group and stop receiving emails from it, send an email to git-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [git-users] Re: Need sine help on Git hooks
Thanks Konstantin and quesiton? you mean git log $newname ^$basename, and is the $newname $basename are: newname is the after pushed refs/heads/Lingfei_test2? and basename is before pushed: refs/heads/Lingfei_test2? Thanks Lingfei On Wednesday, September 4, 2013 9:36:10 AM UTC-4, Konstantin Khomoutov wrote: On Wed, 4 Sep 2013 16:59:14 +0400 Konstantin Khomoutov flat...@users.sourceforge.net javascript: wrote: [...] For each ref to be updated: 1) Call `git merge-base $oldname $newname` -- this will give you the name of a commit which is common between the old and the new state of the ref. In the simplest case -- a fast-forward of the ref this will be the old tip commit of that ref ($oldname here), in a more complex case, where a user did a forced push which replaced some (or all) of the ref's history, this will be the nearest (to the prospective new tip) commit which won't be replaced, and this means its log message has already been checked at some point back in time. 2) Having obtained this base commit, call git rev-list $newname ^$basename [...] 3) Iterate over the generated list, calling git cat-file -p $sha1name [...] I've just tried, and `git log $newname ^$basename` just did the right thing, so if you are okay with a coarse-grained approach, checking each ref reduces to grepping the output of git log $newname $(git merge-base $oldname $newname) (possibly further instrumented with approptiate --format command-line option). -- You received this message because you are subscribed to the Google Groups Git for human beings group. To unsubscribe from this group and stop receiving emails from it, send an email to git-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [git-users] Re: Need sine help on Git hooks
On Wed, 4 Sep 2013 07:15:43 -0700 (PDT) Ling oylf1...@gmail.com wrote: I think what we want to have a hook that on the server repository to prevent the local pushes, so I think if we using git log on the server repo, this won't protect us Why? Using a pre-receive hook to check what has been pushed is the right way to go: as I have written in my first mail to this thread, it suffices to quit the hook with a non-zero exit code to make the push operation abort; everything you'll write to the standard output stream of a process executing as this hook will be delivered to the pushing client (and supposedly shown there). since git log is only created after local pushes, right? No. The git log does not exist. A Git repository is a directed acyclic graph (DAG) of interliked commits; this graph has several named entry points which are named refs -- these are branches and tags. Each ref points to a commit object, and each commit object references one or more parent commit objects -- thus forming a DAG. The `git log` program takes a revision specification which tells it which commits it should select from the whole DAG, it then traverses this selection of commits (this process might be controlled by various command-line options passed to `git log`) and outputs certain information about each commit as it walks. Let's reiterate: there's no such thing as a log -- it's a purely synthetic thing which is produced by `git log` each time you call it, and what it produces depends heavily on the command-line arguments used to call `git log`. and also since when our developers clone the repo to theri locals, and hooks won't be cloned, so we need to have a way to check each developers push to protect our server repo to have the correct codes. So do you have any suggestion on how we can have this ? You're on the right track. The problem is that you seem to just have bypassed all the text I've written in my mail, without analysing it and possibly refining your question, and asked the same questions again for the third time. This is not at all constructive. -- You received this message because you are subscribed to the Google Groups Git for human beings group. To unsubscribe from this group and stop receiving emails from it, send an email to git-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [git-users] Re: Need sine help on Git hooks
On Wed, 4 Sep 2013 06:50:47 -0700 (PDT) Ling oylf1...@gmail.com wrote: Thanks Konstantin and quesiton? you mean git log $newname ^$basename, and is the $newname $basename are: newname is the after pushed refs/heads/Lingfei_test2? and basename is before pushed: refs/heads/Lingfei_test2? No, $newname and $oldname are the SHA-1 names of the prospective new commit for the ref being updated, and its current tip commit, respectively. Did you read the githooks manual page? It tells in clear simple words how a pre-receive hook is passed the information about which refs are about to be updated by the current push operation, and how. That's what you're supposed to parse and use. $basename is the the SHA-1 name of the commit obtained by the call `git merge-base $oldname $newname`. -- You received this message because you are subscribed to the Google Groups Git for human beings group. To unsubscribe from this group and stop receiving emails from it, send an email to git-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [git-users] Re: Need sine help on Git hooks
Thanks Konstantin, Yes I tried git log $newname $(git merge-base $oldname $newname) and it works fine. Thanks Ling On Wednesday, September 4, 2013 10:55:41 AM UTC-4, Konstantin Khomoutov wrote: On Wed, 4 Sep 2013 06:50:47 -0700 (PDT) Ling oylf...@gmail.com javascript: wrote: Thanks Konstantin and quesiton? you mean git log $newname ^$basename, and is the $newname $basename are: newname is the after pushed refs/heads/Lingfei_test2? and basename is before pushed: refs/heads/Lingfei_test2? No, $newname and $oldname are the SHA-1 names of the prospective new commit for the ref being updated, and its current tip commit, respectively. Did you read the githooks manual page? It tells in clear simple words how a pre-receive hook is passed the information about which refs are about to be updated by the current push operation, and how. That's what you're supposed to parse and use. $basename is the the SHA-1 name of the commit obtained by the call `git merge-base $oldname $newname`. -- You received this message because you are subscribed to the Google Groups Git for human beings group. To unsubscribe from this group and stop receiving emails from it, send an email to git-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.