Message ID | 1402538099-7200-1-git-send-email-computersforpeace@gmail.com |
---|---|
State | Accepted |
Headers | show |
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 <computersforpeace@gmail.com> > --- > 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
Looking at my own patch again... On Thu, Jul 3, 2014 at 5:49 PM, Jeremy Kerr <jk@ozlabs.org> wrote: ... >> Signed-off-by: Brian Norris <computersforpeace@gmail.com> >> --- >> 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
On second (third?) thought... On Thu, Jul 3, 2014 at 5:56 PM, Brian Norris <computersforpeace@gmail.com> wrote: > On Thu, Jul 3, 2014 at 5:49 PM, Jeremy Kerr <jk@ozlabs.org> 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
also sprach Jeremy Kerr <jk@ozlabs.org> [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.
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
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
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
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 <computersforpeace@gmail.com> --- tools/post-receive.hook | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)