git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: post-update to stash after push to non-bare current branch

From
NKNeal Kreitzinger <nkreitzinger@gmail.com>
Date
Jan 19, 2012, 21:48 UTC
Message-ID
<4F188FA2.1000209@gmail.com>
In-Reply-To
<7vboq0ld5e.fsf@alter.siamese.dyndns.org>
On 1/18/2012 7:00 PM, Junio C Hamano wrote:
Show 11 quoted lines
> 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

Previous: Junio C HamanoNext: Neal Kreitzinger
Message 7 of 10 in “post-update to stash after push to non-bare current branch”
  1. Neal KreitzingerJan 18, 2012
  2. Neal KreitzingerJan 18, 2012
  3. Neal KreitzingerJan 18, 2012
  4. Junio C HamanoJan 18, 2012
  5. Neal KreitzingerJan 19, 2012
  6. Junio C HamanoJan 19, 2012
  7. Neal KreitzingerJan 19, 2012
  8. Neal KreitzingerJan 21, 2012
  9. Junio C HamanoJan 21, 2012
  10. Neal KreitzingerJan 21, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.