From: David Alberto <dalbertom@gmail.com>
To: git@vger.kernel.org
Subject: receive.denyCurrentBranch updateInstead issues when using separate git dir
Date: Sat, 21 Nov 2020 08:58:12 -0500 [thread overview]
Message-ID: <CALUYcvvcBrgbu=OjgHSygKL+ibj3AA1oi7a6FWZEmWoiRdcAqQ@mail.gmail.com> (raw)
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
reply other threads:[~2020-11-21 14:00 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CALUYcvvcBrgbu=OjgHSygKL+ibj3AA1oi7a6FWZEmWoiRdcAqQ@mail.gmail.com' \
--to=dalbertom@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).