git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Neal Kreitzinger <nkreitzinger@gmail.com>
To: unlisted-recipients:; (no To-header on input)
Cc: Neal Kreitzinger <neal@rsss.com>, git@vger.kernel.org
Subject: Re: post-update to stash after push to non-bare current branch
Date: Fri, 20 Jan 2012 18:13:05 -0600	[thread overview]
Message-ID: <4F1A0311.30502@gmail.com> (raw)
In-Reply-To: <4F188FA2.1000209@gmail.com>

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

  reply	other threads:[~2012-01-21  0:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2012-01-21  0:16               ` Junio C Hamano
2012-01-21  0:35                 ` Neal Kreitzinger

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F1A0311.30502@gmail.com \
    --to=nkreitzinger@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=neal@rsss.com \
    /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.
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).