git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Soham Mehta <soham@box.net>
To: git@vger.kernel.org
Subject: git checkout -f: What am I missing?
Date: Thu, 14 Jan 2010 13:16:12 -0800	[thread overview]
Message-ID: <4B4F899C.7070800@box.net> (raw)

Hi,

I have a situation with git that I'm trying to understand:

Description:
1) GIT_DIR is set to /path/to/repo/.git
2) Repository is /not /a bare repo, and all files are nicely checked-out 
in /path/to/repo/
3) Somebody pushes to that repo using ssh (any branch, checked-out or not)
4) Default post-receive hook runs (it is the only one +x) which sends 
out an email 
(http://repo.or.cz/w/git.git/blob/HEAD:/contrib/hooks/post-receive-email)
5) After it is done sending the email, I put "git checkout -f", at the 
end in the same file, in case someone pushes to a checked-out branch

Problem:
It runs "checkout -f" as if inside .git directory, instead of on the 
parent. i.e. it gets all files from the parent and writes them inside 
.git. Parent is left untouched.

Some more info:
0) We don't have GIT_DIR set in the environment. The hook does a 
rev-parse to find it.
1) echo of $GIT_DIR right before the checkout -f line gives a "." .
2) It works as expected if I do this:  cd /path/to/repo && git 
--git-dir=/path/to/repo/.git/ checkout -f

What I do know:
1) Pushing to a checked-out branch is not a git best-practice, and some 
git behavior is undefined in that case. We already have plans to go away 
from that.
2) Git tends to like full path names instead of relative ones

Can someone help me understand this behavior?

Thanks.
-Soham

             reply	other threads:[~2010-01-14 21:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-14 21:16 Soham Mehta [this message]
2010-01-15 15:28 ` git checkout -f: What am I missing? Michael J Gruber
     [not found]   ` <4B60B2CF.10401@box.net>
2010-01-28 10:27     ` Michael J Gruber

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=4B4F899C.7070800@box.net \
    --to=soham@box.net \
    --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.
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).