From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: Gated Merge?
Date: Thu, 11 Feb 2016 14:06:55 -0800 [thread overview]
Message-ID: <xmqqvb5uvr40.fsf@gitster.mtv.corp.google.com> (raw)
I wish there were a way to let me annotate a commit with a statement
like this:
* When merging a branch that does not have me in it into a trunk
that already has me, do this extra check on the result of the
merge before allowing it to be recorded.
For example, suppose there is a topic that changes all instances of
this
__attribute__((format(printf, X, Y)))
into a new macro FORMAT_PRINTF(X, Y). With such a facility, I can
annotate the commit at the tip of that series to define an extra
check:
! git diff HEAD | grep '^+.*__attribute__((format(printf'
which would prevent me from merging a topic that introduces a new
instance of the printf-format attribute that is spelled in an
old-fashioned way.
In this particular example, it might be even better if the facility
allowed me to declare something like this instead:
* When merging a branch that does not have me in it into a trunk
that already has me, do this extra processing on the result of
the merge before recording it.
The difference between them is the "extra processing" part. For
this example, it would be something that is built around:
perl -p -e '
s{__attribute__\(\(format\(\s*printf,\s*(\d+),\s*(\d+)\)\)\)}
{FORMAT_PRINTF($1, $2)}gx
'
to update the old-fashioned one to use the new macro, and the result
would become an evil merge.
To realize this, there are low-hanging-fruit building blocks that
are trivial:
- Such an annotation can be made as a note attached to the commit
in question;
- Such a check can be done in pre-commit hook;
- Such a pre-commit hook can iterate over this set of commits
DIFF=$(git rev-list --left-right HEAD...MERGE_HEAD)
collect these Merge Gate annotations from the commit appears on
the left hand side (e.g. only exists on the trunk that a side
branch is about to be merged in), and run them.
But the last one feels very costly, and I suspect that there must be
a better way to do this. I do not think we want the "what to do"
part (i.e. checking new lines for __attribute__ in the first
example, or rewriting new lines that has __attribute_ in the second
example) to be in git-core; that clearly is outside the scope of the
plumbing. But the part that finds these "annotations", especially
if we can come up with a fast implementation that may be hard to
script, may be a good addition to the plumbing command set.
Thoughts?
next reply other threads:[~2016-02-11 22:07 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-11 22:06 Junio C Hamano [this message]
2016-02-11 22:42 ` Gated Merge? Andrew Ardill
2016-02-11 23:53 ` Stefan Beller
2016-02-12 17:44 ` Junio C Hamano
2016-02-12 19:00 ` Jeff King
2016-02-12 19:06 ` Junio C Hamano
2016-02-12 19:26 ` Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqvb5uvr40.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.