git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / 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

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).