* post-update to stash after push to non-bare current branch @ 2012-01-18 17:53 Neal Kreitzinger 2012-01-18 18:33 ` Neal Kreitzinger 0 siblings, 1 reply; 10+ messages in thread From: Neal Kreitzinger @ 2012-01-18 17:53 UTC (permalink / raw) To: git We use the worktree of git-repos as the webroot for virtual hosts assigned to ports so we can directly test changes to dev and test git-repos. We have some developers who want to develop offline on laptops and push to these non-bare repos so they can test their changes. My plan is to set receive.denyCurrentBranch = warn, and then use the post-update hook on the remote non-bare to do a stash of the worktree and index. My assumption is that post-update hook only executes after a successful push. Correct? I only want to stash the non-bare remote work-tree and index after a successful push to it (effectively doing a git-reset --hard, but also keeping any changes to the worktree/index of the non-bare remote as a safety in case someone does directly make uncommitted changes on the non-bare remote.) v/r, neal ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: post-update to stash after push to non-bare current branch 2012-01-18 17:53 post-update to stash after push to non-bare current branch Neal Kreitzinger @ 2012-01-18 18:33 ` Neal Kreitzinger 2012-01-18 18:51 ` Neal Kreitzinger 0 siblings, 1 reply; 10+ messages in thread From: Neal Kreitzinger @ 2012-01-18 18:33 UTC (permalink / raw) To: Neal Kreitzinger; +Cc: git On 1/18/2012 11:53 AM, Neal Kreitzinger wrote: > We use the worktree of git-repos as the webroot for virtual hosts assigned > to ports so we can directly test changes to dev and test git-repos. We have > some developers who want to develop offline on laptops and push to these > non-bare repos so they can test their changes. My plan is to set > receive.denyCurrentBranch = warn, and then use the post-update hook on the > remote non-bare to do a stash of the worktree and index. My assumption is > that post-update hook only executes after a successful push. Correct? I > only want to stash the non-bare remote work-tree and index after a > successful push to it (effectively doing a git-reset --hard, but also > keeping any changes to the worktree/index of the non-bare remote as a safety > in case someone does directly make uncommitted changes on the non-bare > remote.) > If I manually run git-stash on the non-bare remote after pushing to it from a clone (receive.denyCurrentBranch=warn) it works as expected and leaves the worktree and index matching the new HEAD. However, when post-update runs the git-stash is leaves the worktree dirty. (git 1.7.1) v/r, neal ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: post-update to stash after push to non-bare current branch 2012-01-18 18:33 ` Neal Kreitzinger @ 2012-01-18 18:51 ` Neal Kreitzinger 2012-01-18 22:38 ` Junio C Hamano 0 siblings, 1 reply; 10+ messages in thread From: Neal Kreitzinger @ 2012-01-18 18:51 UTC (permalink / raw) Cc: Neal Kreitzinger, git On 1/18/2012 12:33 PM, Neal Kreitzinger wrote: > On 1/18/2012 11:53 AM, Neal Kreitzinger wrote: >> We use the worktree of git-repos as the webroot for virtual hosts >> assigned >> to ports so we can directly test changes to dev and test git-repos. We >> have >> some developers who want to develop offline on laptops and push to these >> non-bare repos so they can test their changes. My plan is to set >> receive.denyCurrentBranch = warn, and then use the post-update hook on >> the >> remote non-bare to do a stash of the worktree and index. My assumption is >> that post-update hook only executes after a successful push. Correct? I >> only want to stash the non-bare remote work-tree and index after a >> successful push to it (effectively doing a git-reset --hard, but also >> keeping any changes to the worktree/index of the non-bare remote as a >> safety >> in case someone does directly make uncommitted changes on the non-bare >> remote.) >> > If I manually run git-stash on the non-bare remote after pushing to it > from a clone (receive.denyCurrentBranch=warn) it works as expected and > leaves the worktree and index matching the new HEAD. However, when > post-update runs the git-stash is leaves the worktree dirty. (git 1.7.1) > hooks/post-update was: git stash save echo "worktree+index of non-bare remote current branch stashed for safety" it created the stash and echoed the message. However, as stated earlier, the worktree is still dirty. I then manually run git-reset --hard and that makes it clean (worktree, index, HEAD match). However, if I add that to the hook it still leaves dirty worktree (index matches HEAD, but worktree doesn't match index) hooks/post-update is: git stash save echo "worktree+index of non-bare remote current branch stashed for safety" git reset --hard echo "git-reset --hard on current remote branch to ensure clean state" message is echoed, but git-reset --hard does not appear to have really worked. (git 1.7.1) v/r, neal ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: post-update to stash after push to non-bare current branch 2012-01-18 18:51 ` Neal Kreitzinger @ 2012-01-18 22:38 ` Junio C Hamano 2012-01-19 0:32 ` Neal Kreitzinger 0 siblings, 1 reply; 10+ messages in thread From: Junio C Hamano @ 2012-01-18 22:38 UTC (permalink / raw) To: Neal Kreitzinger; +Cc: Neal Kreitzinger, git Neal Kreitzinger <nkreitzinger@gmail.com> writes: > hooks/post-update is: > > git stash save > echo "worktree+index of non-bare remote current branch stashed for safety" > git reset --hard > echo "git-reset --hard on current remote branch to ensure clean state" > > message is echoed, but git-reset --hard does not appear to have really > worked. (git 1.7.1) Have you checked where in the filesystem hierarchy that script is run (hint: pwd)? Also it is unclear why you keep saying "stash". What kind of changes are you expecting to be saved to the stash? Will they be changes that are not source controlled that you would rather not to see? In other words, after running "stash" every time somebody pushes and having accumulated many stash entries, when do you plan to pop these stashed changes? I would have expect that such a repository to reject a push if the working tree is dirty, and run checkout in post-update, though. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: post-update to stash after push to non-bare current branch 2012-01-18 22:38 ` Junio C Hamano @ 2012-01-19 0:32 ` Neal Kreitzinger 2012-01-19 1:00 ` Junio C Hamano 0 siblings, 1 reply; 10+ messages in thread From: Neal Kreitzinger @ 2012-01-19 0:32 UTC (permalink / raw) To: Junio C Hamano; +Cc: Neal Kreitzinger, git On 1/18/2012 4:38 PM, Junio C Hamano wrote: > Neal Kreitzinger<nkreitzinger@gmail.com> writes: > >> hooks/post-update is: >> >> git stash save >> echo "worktree+index of non-bare remote current branch stashed for safety" >> git reset --hard >> echo "git-reset --hard on current remote branch to ensure clean state" >> >> message is echoed, but git-reset --hard does not appear to have really >> worked. (git 1.7.1) > > Have you checked where in the filesystem hierarchy that script is run > (hint: pwd)? > echo pwd in post-update echoes /path/WORKTREE/.git in git-push stdout. > Also it is unclear why you keep saying "stash". What kind of changes are > you expecting to be saved to the stash? Will they be changes that are not > source controlled that you would rather not to see? In other words, after > running "stash" every time somebody pushes and having accumulated many > stash entries, when do you plan to pop these stashed changes? > good point. rejection of dirty worktree is a cleaner safety. > I would have expect that such a repository to reject a push if the working > tree is dirty, and run checkout in post-update, though. > 'git-checkout -f' works manually, but in post-update hook it leaves behind dirty worktree, ie. index and HEAD match, but worktree still matches HEAD@{1}. This is the same undesired result git-stash and git-reset --hard leave behind when executed in post-update hook. v/r, neal ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: post-update to stash after push to non-bare current branch 2012-01-19 0:32 ` Neal Kreitzinger @ 2012-01-19 1:00 ` Junio C Hamano 2012-01-19 21:48 ` Neal Kreitzinger 0 siblings, 1 reply; 10+ messages in thread From: Junio C Hamano @ 2012-01-19 1:00 UTC (permalink / raw) To: Neal Kreitzinger; +Cc: Neal Kreitzinger, git Neal Kreitzinger <nkreitzinger@gmail.com> writes: >> Have you checked where in the filesystem hierarchy that script is run >> (hint: pwd)? >> > echo pwd in post-update echoes /path/WORKTREE/.git in git-push stdout. > ... > 'git-checkout -f' works manually, but in post-update hook... Stronger hint. Did you run "git checkout -f" in /path/WORKTREE/.git to back that "works manually" claim? ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: post-update to stash after push to non-bare current branch 2012-01-19 1:00 ` Junio C Hamano @ 2012-01-19 21:48 ` Neal Kreitzinger 2012-01-21 0:13 ` Neal Kreitzinger 0 siblings, 1 reply; 10+ messages in thread From: Neal Kreitzinger @ 2012-01-19 21:48 UTC (permalink / raw) To: Junio C Hamano; +Cc: Neal Kreitzinger, git On 1/18/2012 7:00 PM, Junio C Hamano wrote: > Neal Kreitzinger<nkreitzinger@gmail.com> writes: > >>> Have you checked where in the filesystem hierarchy that script is run >>> (hint: pwd)? >>> >> echo pwd in post-update echoes /path/WORKTREE/.git in git-push stdout. >> ... >> 'git-checkout -f' works manually, but in post-update hook... > > Stronger hint. Did you run "git checkout -f" in /path/WORKTREE/.git to > back that "works manually" claim? (Manual behavior): If pwd is WORKTREE/ then git-checkout has correct effect, ie. worktree, index, and HEAD match. If pwd is WORKTREE/.git/ then git-checkout complains 'must be run in a worktree' and has no effect. (post-update hook behavior): If pwd is WORKTREE/.git/ then git-push verbage does not complain, and git-checkout exits zero status but has incorrect effect, ie. index and HEAD match, but worktree matches HEAD@{1}. If pwd is WORKTREE/ then git-push complains 'not a git repository', and git-checkout exits non-zero status and has no effect, ie. worktree and index match HEAD@{1}. Evidence: (post-update hook script): MYPWD=`pwd` echo $MYPWD pushd /home/neal/FSNMSTHTML MYPWD=`pwd` echo $MYPWD git checkout -f HEAD if [ $? -ne 0 ]; then echo "error on checkout!" else echo "checkout HEAD to non-bare remote current branch after push" fi echo $MYPWD popd MYPWD=`pwd` echo $MYPWD (git-push verbage): $ git push origin HEAD Counting objects: 9, done. Delta compression using up to 8 threads. Compressing objects: 100% (5/5), done. Writing objects: 100% (5/5), 462 bytes, done. Total 5 (delta 4), reused 0 (delta 0) Unpacking objects: 100% (5/5), done. remote: warning: updating the current branch remote: /home/neal/FSNMSTHTML/.git remote: ~/FSNMSTHTML ~/FSNMSTHTML/.git remote: /home/neal/FSNMSTHTML remote: fatal: Not a git repository: '.' remote: error on checkout! remote: /home/neal/FSNMSTHTML remote: ~/FSNMSTHTML/.git remote: /home/neal/FSNMSTHTML/.git To file:///home/neal/FSNMSTHTML cee9269..34dc5a9 HEAD -> master v/r, neal ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: post-update to stash after push to non-bare current branch 2012-01-19 21:48 ` Neal Kreitzinger @ 2012-01-21 0:13 ` Neal Kreitzinger 2012-01-21 0:16 ` Junio C Hamano 0 siblings, 1 reply; 10+ messages in thread From: Neal Kreitzinger @ 2012-01-21 0:13 UTC (permalink / raw) Cc: Neal Kreitzinger, git On 1/19/2012 3:48 PM, Neal Kreitzinger wrote: > On 1/18/2012 7:00 PM, Junio C Hamano wrote: >> Neal Kreitzinger<nkreitzinger@gmail.com> writes: >> >>>> Have you checked where in the filesystem hierarchy that script >>>> is run (hint: pwd)? >>>> >>> echo pwd in post-update echoes /path/WORKTREE/.git in git-push >>> stdout. ... 'git-checkout -f' works manually, but in post-update >>> hook... >> >> Stronger hint. Did you run "git checkout -f" in >> /path/WORKTREE/.git to back that "works manually" claim? > > (Manual behavior): If pwd is WORKTREE/ then git-checkout has correct > effect, ie. worktree, index, and HEAD match. If pwd is > WORKTREE/.git/ then git-checkout complains 'must be run in a > worktree' and has no effect. > > (post-update hook behavior): If pwd is WORKTREE/.git/ then git-push > verbage does not complain, and git-checkout exits zero status but > has incorrect effect, ie. index and HEAD match, but worktree matches > HEAD@{1}. If pwd is WORKTREE/ then git-push complains 'not a git > repository', and git-checkout exits non-zero status and has no > effect, ie. worktree and index match HEAD@{1}. > > Evidence: > > (post-update hook script): MYPWD=`pwd` echo $MYPWD pushd > /home/neal/FSNMSTHTML MYPWD=`pwd` echo $MYPWD git checkout -f HEAD > if [ $? -ne 0 ]; then echo "error on checkout!" else echo "checkout > HEAD to non-bare remote current branch after push" fi echo $MYPWD > popd MYPWD=`pwd` echo $MYPWD > > (git-push verbage): $ git push origin HEAD Counting objects: 9, done. > Delta compression using up to 8 threads. Compressing objects: 100% > (5/5), done. Writing objects: 100% (5/5), 462 bytes, done. Total 5 > (delta 4), reused 0 (delta 0) Unpacking objects: 100% (5/5), done. > remote: warning: updating the current branch remote: > /home/neal/FSNMSTHTML/.git remote: ~/FSNMSTHTML ~/FSNMSTHTML/.git > remote: /home/neal/FSNMSTHTML remote: fatal: Not a git repository: > '.' remote: error on checkout! remote: /home/neal/FSNMSTHTML remote: > ~/FSNMSTHTML/.git remote: /home/neal/FSNMSTHTML/.git To > file:///home/neal/FSNMSTHTML cee9269..34dc5a9 HEAD -> master > To get this to work I had to learn more about shell scripting and export the GIT_WORK_TREE git environment variable. (post-update hook): export GIT_WORK_TREE=/home/neal/FSNMSTHTML git checkout -f HEAD for more info see this stackoverflow thread http://stackoverflow.com/questions/6635018/reuse-git-work-tree-in-post-receive-hook-to-rm-a-few-files v/r, neal ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: post-update to stash after push to non-bare current branch 2012-01-21 0:13 ` Neal Kreitzinger @ 2012-01-21 0:16 ` Junio C Hamano 2012-01-21 0:35 ` Neal Kreitzinger 0 siblings, 1 reply; 10+ messages in thread From: Junio C Hamano @ 2012-01-21 0:16 UTC (permalink / raw) To: Neal Kreitzinger Neal Kreitzinger <nkreitzinger@gmail.com> writes: > To get this to work I had to learn more about shell scripting and export > the GIT_WORK_TREE git environment variable. > > (post-update hook): > export GIT_WORK_TREE=/home/neal/FSNMSTHTML > git checkout -f HEAD Hmm, I thought "cd .. && git checkout -f HEAD" (or "git reset --hard") would have worked. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: post-update to stash after push to non-bare current branch 2012-01-21 0:16 ` Junio C Hamano @ 2012-01-21 0:35 ` Neal Kreitzinger 0 siblings, 0 replies; 10+ messages in thread From: Neal Kreitzinger @ 2012-01-21 0:35 UTC (permalink / raw) To: Junio C Hamano On 1/20/2012 6:16 PM, Junio C Hamano wrote: > Neal Kreitzinger<nkreitzinger@gmail.com> writes: > >> To get this to work I had to learn more about shell scripting and export >> the GIT_WORK_TREE git environment variable. >> >> (post-update hook): >> export GIT_WORK_TREE=/home/neal/FSNMSTHTML >> git checkout -f HEAD > > > Hmm, I thought "cd ..&& git checkout -f HEAD" (or "git reset --hard") > would have worked. Ok, I just tried that for the first time and it complained "not a git repository: '.'" because it looks like that caused GIT_DIR to no longer point to WORKTREE/.git but instead to WORKTREE/ because GIT_DIR is set to '.' in the post-update script's environment as indicated in this thread: http://stackoverflow.com/questions/6635018/reuse-git-work-tree-in-post-receive-hook-to-rm-a-few-files v/r, neal ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2012-01-21 0:36 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-01-18 17:53 post-update to stash after push to non-bare current branch Neal Kreitzinger 2012-01-18 18:33 ` Neal Kreitzinger 2012-01-18 18:51 ` Neal Kreitzinger 2012-01-18 22:38 ` Junio C Hamano 2012-01-19 0:32 ` Neal Kreitzinger 2012-01-19 1:00 ` Junio C Hamano 2012-01-19 21:48 ` Neal Kreitzinger 2012-01-21 0:13 ` Neal Kreitzinger 2012-01-21 0:16 ` Junio C Hamano 2012-01-21 0:35 ` Neal Kreitzinger
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 NNTP newsgroup(s).