Re: [PATCH] post-receive: exclude commits from the patch update step
Hi Jeremy, On Mon, Jul 14, 2014 at 10:57:38AM +0800, Jeremy Kerr wrote: > > Actually, I think the rev-parse serves as a little extra parameter > > checking. Unless someone can pin a good reason one way or the other, > > I'll stick with my original patch as I sent it. And I've been testing > > that version for a few weeks now. > > OK, just did some testing with that: it looks like the rev-parse will > barf to stderr if EXCLUDE is empty. Should we do this conditionally? Really? What version of git? If I run either of these, I get no output, with a 'success' return status: git rev-parse git rev-parse --not $ git --version git version 1.9.1 > Or, given that we're essentially doing an exclude on ${1} there, > how about we just add any excludes to the rev-list instead? Something > like: > > EXCLUDES=(refs/heads/upstream) > > [...] > > update_patches() > { > local cnt; cnt=0 > include=${2} > excludes=(${1} ${EXCLUDES[@]}) > revs="$include ${excludes[@]/#/^}" Wow, so we're really going full-on bash! I suppose that works. Or you could more simply write: revs="${2} --not ${1} ${EXCLUDES}" > for rev in $(git rev-list --no-merges --reverse $revs); do > [...] But whatever works for you; yours (or my modification of it) looks better than my original, I think. I just thought I'd toss my patch out there, since I needed a solution personally. Regards, Brian ___ Patchwork mailing list Patchwork@lists.ozlabs.org https://lists.ozlabs.org/listinfo/patchwork
Re: [PATCH] post-receive: exclude commits from the patch update step
Hi Brian, > Actually, I think the rev-parse serves as a little extra parameter > checking. Unless someone can pin a good reason one way or the other, > I'll stick with my original patch as I sent it. And I've been testing > that version for a few weeks now. OK, just did some testing with that: it looks like the rev-parse will barf to stderr if EXCLUDE is empty. Should we do this conditionally? Or, given that we're essentially doing an exclude on ${1} there, how about we just add any excludes to the rev-list instead? Something like: EXCLUDES=(refs/heads/upstream) [...] update_patches() { local cnt; cnt=0 include=${2} excludes=(${1} ${EXCLUDES[@]}) revs="$include ${excludes[@]/#/^}" for rev in $(git rev-list --no-merges --reverse $revs); do [...] Cheers, Jeremy ___ Patchwork mailing list Patchwork@lists.ozlabs.org https://lists.ozlabs.org/listinfo/patchwork
Re: [PATCH] post-receive: exclude commits from the patch update step
also sprach Jeremy Kerr [2014-07-04 02:49 +0200]: > Martin - how does this look? Tbh, my mind is elsewhere, but thanks for checking in. I am happy for you guys to work out anything that improves scripts I have written. Unless licenced, explicitly, consider them under whatever licence the project is in. -- @martinkrafft | http://madduck.net/ | http://two.sentenc.es/ i stopped fighting my inner demons.. we're all on the same side now. spamtraps: madduck.bo...@madduck.net digital_signature_gpg.asc Description: Digital signature (see http://martin-krafft.net/gpg/sig-policy/999bbcc4/current) ___ Patchwork mailing list Patchwork@lists.ozlabs.org https://lists.ozlabs.org/listinfo/patchwork
Re: [PATCH] post-receive: exclude commits from the patch update step
On second (third?) thought... On Thu, Jul 3, 2014 at 5:56 PM, Brian Norris wrote: > On Thu, Jul 3, 2014 at 5:49 PM, Jeremy Kerr wrote: > ... >>> @@ -39,7 +45,8 @@ set_patch_state() >>> update_patches() >>> { >>> local cnt; cnt=0 >>> - for rev in $(git rev-list --no-merges --reverse ${1}..${2}); do >>> + for rev in $(git rev-parse --not ${EXCLUDE} | >>> + git rev-list --stdin --no-merges --reverse ${1}..${2}); do > > I think I can probably combine the rev-parse and rev-list to avoid the > extra pipe: > > git rev-list --no-merges --reverse ${1}..${2} --not ${EXCLUDE} > > I'll test and resend, if that looks OK. Actually, I think the rev-parse serves as a little extra parameter checking. Unless someone can pin a good reason one way or the other, I'll stick with my original patch as I sent it. And I've been testing that version for a few weeks now. Brian ___ Patchwork mailing list Patchwork@lists.ozlabs.org https://lists.ozlabs.org/listinfo/patchwork
Re: [PATCH] post-receive: exclude commits from the patch update step
Looking at my own patch again... On Thu, Jul 3, 2014 at 5:49 PM, Jeremy Kerr wrote: ... >> Signed-off-by: Brian Norris >> --- >> tools/post-receive.hook | 9 - >> 1 file changed, 8 insertions(+), 1 deletion(-) >> >> diff --git a/tools/post-receive.hook b/tools/post-receive.hook >> index 4fb741d3ea98..a38522e22f35 100755 >> --- a/tools/post-receive.hook >> +++ b/tools/post-receive.hook >> @@ -8,6 +8,12 @@ set -eu >> >> #TODO: the state map should really live in the repo's git-config >> STATE_MAP="refs/heads/master:Accepted" >> +# >> +# ignore all commits already present in these refs >> +# e.g., >> +# EXCLUDE="refs/heads/upstream refs/heads/other-project" >> +# >> +EXCLUDE="" >> >> PWDIR=/srv/patchwork/apps/patchwork >> >> @@ -39,7 +45,8 @@ set_patch_state() >> update_patches() >> { >> local cnt; cnt=0 >> - for rev in $(git rev-list --no-merges --reverse ${1}..${2}); do >> + for rev in $(git rev-parse --not ${EXCLUDE} | >> + git rev-list --stdin --no-merges --reverse ${1}..${2}); do I think I can probably combine the rev-parse and rev-list to avoid the extra pipe: git rev-list --no-merges --reverse ${1}..${2} --not ${EXCLUDE} I'll test and resend, if that looks OK. >> if [ "$do_exit" = 1 ]; then >> echo "I: exiting..." >&2 >> break >> Brian ___ Patchwork mailing list Patchwork@lists.ozlabs.org https://lists.ozlabs.org/listinfo/patchwork
Re: [PATCH] post-receive: exclude commits from the patch update step
Hi Brian, When merging upstream work related to other projects into your own project repository, you probably don't want to check for (and try to update) the status on every change-set in the merge. So add a list of references (branches, tags, commits, etc.) whose commits should be ignored in the patch update step. This could be used, for example, to set: EXCLUDE="refs/heads/upstream" Then when you're ready to merge in new upstream code, you first update the 'upstream' branch before pushing your own. This looks good to me, but I'd like to get Martin's OK, as he's the author of this script. Martin - how does this look? Signed-off-by: Brian Norris --- tools/post-receive.hook | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/post-receive.hook b/tools/post-receive.hook index 4fb741d3ea98..a38522e22f35 100755 --- a/tools/post-receive.hook +++ b/tools/post-receive.hook @@ -8,6 +8,12 @@ set -eu #TODO: the state map should really live in the repo's git-config STATE_MAP="refs/heads/master:Accepted" +# +# ignore all commits already present in these refs +# e.g., +# EXCLUDE="refs/heads/upstream refs/heads/other-project" +# +EXCLUDE="" PWDIR=/srv/patchwork/apps/patchwork @@ -39,7 +45,8 @@ set_patch_state() update_patches() { local cnt; cnt=0 - for rev in $(git rev-list --no-merges --reverse ${1}..${2}); do + for rev in $(git rev-parse --not ${EXCLUDE} | + git rev-list --stdin --no-merges --reverse ${1}..${2}); do if [ "$do_exit" = 1 ]; then echo "I: exiting..." >&2 break Cheers, Jeremy ___ Patchwork mailing list Patchwork@lists.ozlabs.org https://lists.ozlabs.org/listinfo/patchwork
[PATCH] post-receive: exclude commits from the patch update step
When merging upstream work related to other projects into your own project repository, you probably don't want to check for (and try to update) the status on every change-set in the merge. So add a list of references (branches, tags, commits, etc.) whose commits should be ignored in the patch update step. This could be used, for example, to set: EXCLUDE="refs/heads/upstream" Then when you're ready to merge in new upstream code, you first update the 'upstream' branch before pushing your own. Signed-off-by: Brian Norris --- tools/post-receive.hook | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/post-receive.hook b/tools/post-receive.hook index 4fb741d3ea98..a38522e22f35 100755 --- a/tools/post-receive.hook +++ b/tools/post-receive.hook @@ -8,6 +8,12 @@ set -eu #TODO: the state map should really live in the repo's git-config STATE_MAP="refs/heads/master:Accepted" +# +# ignore all commits already present in these refs +# e.g., +# EXCLUDE="refs/heads/upstream refs/heads/other-project" +# +EXCLUDE="" PWDIR=/srv/patchwork/apps/patchwork @@ -39,7 +45,8 @@ set_patch_state() update_patches() { local cnt; cnt=0 - for rev in $(git rev-list --no-merges --reverse ${1}..${2}); do + for rev in $(git rev-parse --not ${EXCLUDE} | + git rev-list --stdin --no-merges --reverse ${1}..${2}); do if [ "$do_exit" = 1 ]; then echo "I: exiting..." >&2 break -- 1.9.1 ___ Patchwork mailing list Patchwork@lists.ozlabs.org https://lists.ozlabs.org/listinfo/patchwork