diff mbox series

[v2,3/3] doc: add documentation for the hide-refs hook

Message ID e737997eb31088a0ebe58c1db0e393a45170eabb.1660524865.git.gitgitgadget@gmail.com (mailing list archive)
State New, archived
Headers show
Series hide-refs: add hook to force hide refs | expand

Commit Message

孙超 Aug. 15, 2022, 12:54 a.m. UTC
From: Sun Chao <16657101987@163.com>

"git upload-pack" or "git recevie-pack" can use "hide-refs"
hook to filter the references during reference discovery phase.

Signed-off-by: Sun Chao <sunchao9@huawei.com>
---
 Documentation/githooks.txt | 48 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

Comments

Eric Sunshine Aug. 15, 2022, 4:12 a.m. UTC | #1
On Sun, Aug 14, 2022 at 8:56 PM Sun Chao via GitGitGadget
<gitgitgadget@gmail.com> wrote:
> "git upload-pack" or "git recevie-pack" can use "hide-refs"

s/recevie/receive/

> hook to filter the references during reference discovery phase.
>
> Signed-off-by: Sun Chao <sunchao9@huawei.com>
> ---
> diff --git a/Documentation/githooks.txt b/Documentation/githooks.txt
> @@ -249,6 +249,54 @@ If this hook exits with a non-zero status, `git push` will abort without
> +This hook would be invoked by 'git-receive-pack' and 'git-upload-pack'
> +during the reference discovery phase, each reference and will be filtered

s/and//

> +by this hook. The hook executes once with no arguments for each
> +'git-upload-pack' and 'git-receive-pack' process. Once the hook is invoked,
> +a version number and server process name ('uploadpack' or 'receive') will
> +send to it in pkt-line format, followed by a flush-pkt. The hook should
> +response with its version number.

s/response/respond/

> +During reference discovery phase, each reference will be filtered by this
> +hook. In the following example, the letter 'G' stands for 'git-receive-pack'
> +or 'git-upload-pack' and the letter 'H' stands for this hook. The hook
> +decides if the reference will be hidden or not, it sends result back in
> +pkt-line format protocol, a response "hide" the references will hide
> +to the client and can not fetch it even in protocol V2.
> +
> +       # Version negotiation
> +       G: PKT-LINE(version=1\0uploadpack)
> +       G: flush-pkt
> +       H: PKT-LINE(version=1)
> +       H: flush-pkt
> +
> +       # Send reference filter request to hook
> +       G: PKT-LINE(ref <refname>:<refnamefull>)
> +       G: flush-pkt
> +
> +       # Receive result from the hook.
> +       # Case 1: this reference is hidden
> +       H: PKT-LINE(hide)
> +       H: flush-pkt
> +
> +       # Case 2: this reference can be advertised
> +       H: flush-pkt
> +
> +To enable the `hide-refs` hook, we should config hiderefs with `force:`
> +option, eg:
> +
> +       git config --add transfer.hiderefs force:refs/prefix1/
> +       git config --add uploadpack.hiderefs force:!refs/prefix2/
> +
> +the `hide-refs` will be called during reference discovery phase and
> +check each matched reference, a 'hide' reponse means the reference will

s/reponse/response/

> +be hidden for its private data and even the `allowTipSHA1InWant` and

s/and even the/even if/

> +`allowReachableSHA1InWant` is set to true.

s/is/are/
孙超 Aug. 15, 2022, 2:49 p.m. UTC | #2
> On Aug 15, 2022, at 12:12, Eric Sunshine <sunshine@sunshineco.com> wrote:
> 
> On Sun, Aug 14, 2022 at 8:56 PM Sun Chao via GitGitGadget
> <gitgitgadget@gmail.com> wrote:
>> "git upload-pack" or "git recevie-pack" can use "hide-refs"
> 
> s/recevie/receive/
> 
>> hook to filter the references during reference discovery phase.
>> 
>> Signed-off-by: Sun Chao <sunchao9@huawei.com>
>> ---
>> diff --git a/Documentation/githooks.txt b/Documentation/githooks.txt
>> @@ -249,6 +249,54 @@ If this hook exits with a non-zero status, `git push` will abort without
>> +This hook would be invoked by 'git-receive-pack' and 'git-upload-pack'
>> +during the reference discovery phase, each reference and will be filtered
> 
> s/and//
> 
>> +by this hook. The hook executes once with no arguments for each
>> +'git-upload-pack' and 'git-receive-pack' process. Once the hook is invoked,
>> +a version number and server process name ('uploadpack' or 'receive') will
>> +send to it in pkt-line format, followed by a flush-pkt. The hook should
>> +response with its version number.
> 
> s/response/respond/
> 
>> +During reference discovery phase, each reference will be filtered by this
>> +hook. In the following example, the letter 'G' stands for 'git-receive-pack'
>> +or 'git-upload-pack' and the letter 'H' stands for this hook. The hook
>> +decides if the reference will be hidden or not, it sends result back in
>> +pkt-line format protocol, a response "hide" the references will hide
>> +to the client and can not fetch it even in protocol V2.
>> +
>> +       # Version negotiation
>> +       G: PKT-LINE(version=1\0uploadpack)
>> +       G: flush-pkt
>> +       H: PKT-LINE(version=1)
>> +       H: flush-pkt
>> +
>> +       # Send reference filter request to hook
>> +       G: PKT-LINE(ref <refname>:<refnamefull>)
>> +       G: flush-pkt
>> +
>> +       # Receive result from the hook.
>> +       # Case 1: this reference is hidden
>> +       H: PKT-LINE(hide)
>> +       H: flush-pkt
>> +
>> +       # Case 2: this reference can be advertised
>> +       H: flush-pkt
>> +
>> +To enable the `hide-refs` hook, we should config hiderefs with `force:`
>> +option, eg:
>> +
>> +       git config --add transfer.hiderefs force:refs/prefix1/
>> +       git config --add uploadpack.hiderefs force:!refs/prefix2/
>> +
>> +the `hide-refs` will be called during reference discovery phase and
>> +check each matched reference, a 'hide' reponse means the reference will
> 
> s/reponse/response/
> 
>> +be hidden for its private data and even the `allowTipSHA1InWant` and
> 
> s/and even the/even if/
> 
>> +`allowReachableSHA1InWant` is set to true.
> 
> s/is/are/
> 

thanks a lot ! I will update the patches right now.
Junio C Hamano Aug. 15, 2022, 4:02 p.m. UTC | #3
孙超 <16657101987@163.com> writes:

> thanks a lot ! I will update the patches right now.

Not "right now".

Instead of flooding the list with repeated "oops that was wrong"
updates, it may be more effective use of others' time to wait for
more feedback before acting on them, and to take time to proofread
the result of your updates before sending them out.

Thanks.
diff mbox series

Patch

diff --git a/Documentation/githooks.txt b/Documentation/githooks.txt
index a16e62bc8c8..df712903464 100644
--- a/Documentation/githooks.txt
+++ b/Documentation/githooks.txt
@@ -249,6 +249,54 @@  If this hook exits with a non-zero status, `git push` will abort without
 pushing anything.  Information about why the push is rejected may be sent
 to the user by writing to standard error.
 
+[[hide-refs]]
+hide-refs
+~~~~~~~~~
+
+This hook would be invoked by 'git-receive-pack' and 'git-upload-pack'
+during the reference discovery phase, each reference and will be filtered
+by this hook. The hook executes once with no arguments for each
+'git-upload-pack' and 'git-receive-pack' process. Once the hook is invoked,
+a version number and server process name ('uploadpack' or 'receive') will
+send to it in pkt-line format, followed by a flush-pkt. The hook should
+response with its version number.
+
+During reference discovery phase, each reference will be filtered by this
+hook. In the following example, the letter 'G' stands for 'git-receive-pack'
+or 'git-upload-pack' and the letter 'H' stands for this hook. The hook
+decides if the reference will be hidden or not, it sends result back in
+pkt-line format protocol, a response "hide" the references will hide
+to the client and can not fetch it even in protocol V2.
+
+	# Version negotiation
+	G: PKT-LINE(version=1\0uploadpack)
+	G: flush-pkt
+	H: PKT-LINE(version=1)
+	H: flush-pkt
+
+	# Send reference filter request to hook
+	G: PKT-LINE(ref <refname>:<refnamefull>)
+	G: flush-pkt
+
+	# Receive result from the hook.
+	# Case 1: this reference is hidden
+	H: PKT-LINE(hide)
+	H: flush-pkt
+
+	# Case 2: this reference can be advertised
+	H: flush-pkt
+
+To enable the `hide-refs` hook, we should config hiderefs with `force:`
+option, eg:
+
+	git config --add transfer.hiderefs force:refs/prefix1/
+	git config --add uploadpack.hiderefs force:!refs/prefix2/
+
+the `hide-refs` will be called during reference discovery phase and
+check each matched reference, a 'hide' reponse means the reference will
+be hidden for its private data and even the `allowTipSHA1InWant` and
+`allowReachableSHA1InWant` is set to true.
+
 [[pre-receive]]
 pre-receive
 ~~~~~~~~~~~