From: "Shawn O. Pearce" <spearce@spearce.org>
To: Christoph Duelli <duelli@melosgmbh.de>
Cc: git@vger.kernel.org
Subject: Re: Is a given file known to git?
Date: Tue, 11 Mar 2008 03:24:12 -0400 [thread overview]
Message-ID: <20080311072412.GP8410@spearce.org> (raw)
In-Reply-To: <47D6317D.7030700@melosgmbh.de>
Christoph Duelli <duelli@melosgmbh.de> wrote:
> Given a repository and a path p to a file in it:
> Is it possible (how?) to detect (in a bash script) if the file pointed
> to by p is "known" to git?
> Something along the line:
> if `git knows p?
> then
> ...
> fi
Depends on your definition of "known to git". You can look at
the current index, which may have files newly added but not yet
committed:
if test $(git ls-files "$p" | wc -l) -gt 0
then
...
fi
you can look at a specific committed state too:
if git cat-file -e "$commit:$p" 2>/dev/null
then
...
fi
where $commit can be any tree-ish, so a tag, a branch, a commit,
the symbolic-ref HEAD... etc.
--
Shawn.
next prev parent reply other threads:[~2008-03-11 7:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-11 7:15 Is a given file known to git? Christoph Duelli
2008-03-11 7:24 ` Shawn O. Pearce [this message]
2008-03-11 7:38 ` Johannes Sixt
2008-03-11 9:27 ` Christoph Duelli
2008-03-11 9:36 ` Johannes Sixt
2008-03-11 9:41 ` Christoph Duelli
2008-03-11 9:45 ` Junio C Hamano
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=20080311072412.GP8410@spearce.org \
--to=spearce@spearce.org \
--cc=duelli@melosgmbh.de \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.