{"thread":{"id":"54686","subject":"receive.denyCurrentBranch updateInstead issues when using separate git dir","startedAt":"2020-11-21T13:58:47Z","lastAt":"2020-11-21T13:58:47Z","messageCount":1,"participants":["David Alberto"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"410458","messageId":"CALUYcvvcBrgbu=OjgHSygKL+ibj3AA1oi7a6FWZEmWoiRdcAqQ@mail.gmail.com","threadId":"54686","inReplyTo":null,"subject":"receive.denyCurrentBranch updateInstead issues when using separate git dir","fromName":"David Alberto","fromEmail":"dalbertom@gmail.com","sentAt":"2020-11-21T13:58:12Z","receivedAt":"2020-11-21T13:58:47Z","isPatch":false,"sender":{"key":"dalbertom@gmail.com","avatar":null},"body":"Hey there, I think I found a bug, it's a bit of an edge case when the\nrepository has a separate git dir. Here's the filled-in output of git\nbugreport:\n\nWhat did you do before the bug happened? (Steps to reproduce your issue)\nThe `receive.denyCurrentBranch updateInstead` configuration behaves\ndifferently when cloning using a --separate-git-dir flag.\n\nWhat did you expect to happen? (Expected behavior)\nThe documentation for `receive.denyCurrentBranch updateInstead` indicates\nthat the `push-to-checkout` hook should be configured to run\n`git read-tree -u -m HEAD \"$1\"`, however, the tree still contains files\nfrom the original commit. This only happens when the receiving repository\nuses a separate git dir. When the .git dir is inside the repository it\nupdates the work tree correctly.\n\nWhat happened instead? (Actual behavior)\nThe work tree still had files from the original commit when they should\nhave gotten deleted.\n\nWhat's different between what you expected and what actually happened?\nI was expecting the work tree to be updated after the push-to-checkout\nhook ran git read-tree\n\nAnything else you want to add:\nI wrote this script to reproduce the issue. I tested it on 2.29.0,\nv2.29.2-334-gfaefdd61ec, and v2.29.2-505-g04529851e5\n```\n#!/usr/bin/env bash\n\nfunction create {\n        git init --quiet one\n        cd one\n        touch file1\n        git add file1\n        git commit --quiet -am 'added file1'\n        cd ..\n}\n\nfunction allow-updateInstead {\n        cd two\n        git config receive.denyCurrentBranch updateInstead\n        echo 'git read-tree -u -m HEAD \"$1\"' > $(git rev-parse\n--git-dir)/hooks/push-to-checkout\n        chmod 755 $(git rev-parse --git-dir)/hooks/push-to-checkout\n        cd ..\n}\n\nfunction push-changes {\n        cd one\n        touch file2\n        git rm --quiet file1\n        git add file2\n        git commit --quiet -am 'removed file1, add file 2'\n        git push --quiet ../two HEAD\n}\n\nfunction check-status {\n        cd ../two\n        git status\n}\n\npushd $(mktemp -d)\ncreate\ngit clone --quiet one two\nallow-updateInstead\npush-changes\necho\necho WITH REGULAR CLONE\ncheck-status\necho GIT STATUS WAS EMPTY\necho\npopd\n\npushd $(mktemp -d)\ncreate\ngit clone --quiet --separate-git-dir two.git one two\nallow-updateInstead\npush-changes\necho\necho WITH SEPARATE GIT DIR CLONE\ncheck-status\necho GIT STATUS WAS NOT EMPTY\necho\npopd\n```\n\n[System Info]\ngit version:\ngit version 2.29.0\ncpu: x86_64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nuname: Linux 4.4.0-1117-aws #131-Ubuntu SMP Tue Oct 6 20:45:33 UTC 2020 x86_64\ncompiler info: gnuc: 5.4\nlibc info: glibc: 2.23\n$SHELL (typically, interactive shell): /bin/bash\n\n\n[Enabled Hooks]\npush-to-checkout\n\n-- \n==============\nDavid Montemayor\n"}]}