receive.denyCurrentBranch updateInstead issues when using separate git dir

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

 



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



[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]

  Powered by Linux