git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / Atom feed
* receive.denyCurrentBranch updateInstead issues when using separate git dir
@ 2020-11-21 13:58 David Alberto
  0 siblings, 0 replies; only message in thread
From: David Alberto @ 2020-11-21 13:58 UTC (permalink / raw)
  To: git

Hey there, I think I found a bug, it's a bit of an edge case when the
repository has a separate git dir. Here's the filled-in output of git
bugreport:

What did you do before the bug happened? (Steps to reproduce your issue)
The `receive.denyCurrentBranch updateInstead` configuration behaves
differently when cloning using a --separate-git-dir flag.

What did you expect to happen? (Expected behavior)
The documentation for `receive.denyCurrentBranch updateInstead` indicates
that the `push-to-checkout` hook should be configured to run
`git read-tree -u -m HEAD "$1"`, however, the tree still contains files
from the original commit. This only happens when the receiving repository
uses a separate git dir. When the .git dir is inside the repository it
updates the work tree correctly.

What happened instead? (Actual behavior)
The work tree still had files from the original commit when they should
have gotten deleted.

What's different between what you expected and what actually happened?
I was expecting the work tree to be updated after the push-to-checkout
hook ran git read-tree

Anything else you want to add:
I wrote this script to reproduce the issue. I tested it on 2.29.0,
v2.29.2-334-gfaefdd61ec, and v2.29.2-505-g04529851e5
```
#!/usr/bin/env bash

function create {
        git init --quiet one
        cd one
        touch file1
        git add file1
        git commit --quiet -am 'added file1'
        cd ..
}

function allow-updateInstead {
        cd two
        git config receive.denyCurrentBranch updateInstead
        echo 'git read-tree -u -m HEAD "$1"' > $(git rev-parse
--git-dir)/hooks/push-to-checkout
        chmod 755 $(git rev-parse --git-dir)/hooks/push-to-checkout
        cd ..
}

function push-changes {
        cd one
        touch file2
        git rm --quiet file1
        git add file2
        git commit --quiet -am 'removed file1, add file 2'
        git push --quiet ../two HEAD
}

function check-status {
        cd ../two
        git status
}

pushd $(mktemp -d)
create
git clone --quiet one two
allow-updateInstead
push-changes
echo
echo WITH REGULAR CLONE
check-status
echo GIT STATUS WAS EMPTY
echo
popd

pushd $(mktemp -d)
create
git clone --quiet --separate-git-dir two.git one two
allow-updateInstead
push-changes
echo
echo WITH SEPARATE GIT DIR CLONE
check-status
echo GIT STATUS WAS NOT EMPTY
echo
popd
```

[System Info]
git version:
git version 2.29.0
cpu: x86_64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
uname: Linux 4.4.0-1117-aws #131-Ubuntu SMP Tue Oct 6 20:45:33 UTC 2020 x86_64
compiler info: gnuc: 5.4
libc info: glibc: 2.23
$SHELL (typically, interactive shell): /bin/bash


[Enabled Hooks]
push-to-checkout

-- 
==============
David Montemayor

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-11-21 14:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-21 13:58 receive.denyCurrentBranch updateInstead issues when using separate git dir David Alberto

git@vger.kernel.org list mirror (unofficial, one of many)

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 git git/ https://public-inbox.org/git \
		git@vger.kernel.org
	public-inbox-index git

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.io/gmane.comp.version-control.git
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for the project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git