Re: [RFC/PATCH v2 3/3] Add 'update-branch' hook

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Felipe Contreras <felipe.contreras@xxxxxxxxx> writes:

> This hook is invoked before a branch is updated, either when a branch is
> created or updated with 'git branch', or when it's rebased with 'git
> rebase'.  It receives three parameters; the name of the branch, the
> SHA-1 of the latest commit, and the SHA-1 of the first commit of the
> branch.
>
> When a branch is created the first and last commits of the branch are
> the same, however when a branch is rebased they are not. If the SHA-1 of
> the first commit of the branch is not available (e.g. git reset) a null
> SHA-1 (40 zeroes) would be passed.
>
> The hook exit status can be used to deny the branch update.
>
> It can be used to verify the validity of branch names, and also to keep
> track of the origin point of a branch, which is otherwise not possible
> to find out [1].

Please call it pre-update-branch at least, unless you want to make
sure that time spent on others in the discussion thread for the
previous round becomes wasted.

> +update-branch
> +~~~~~~~~~~~~~
> +
> +This hook is invoked before a branch is updated, either when a branch is
> +created or updated with 'git branch', or when it's rebased with 'git rebase'.

Does "git checkout -B aBranch" count?

Does "git reset $there" count?

I guess "git commit" or "git merge" on a branch to advance its tip
in a usual way would not count (and I can think of good reasons why
they should not count), but it is only a weak "guess".  The above
two lines does not give readers enough hint to determine if "branch
and rebase will be the only two and no other command will ever
trigger" or "branch and rebase are only examples---for others, guess
on your own" (and if the latter, enough clue to use in guessing).
I cannot guess if "git fetch $there $that:refs/heads/master" should
trigger the hook, for example.

To put it another way.

How does one, who is adding a new command that causes a branch tip
to be updated, to decide if it should trigger this hook?  What are
the common things among commands that can update branch tips that
this hook gets called that are missing from commands that update
branch tips that this hook does not get called?
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]