From: Junio C Hamano <gitster@pobox.com>
To: Christoph Duelli <duelli@melosgmbh.de>
Cc: Johannes Sixt <j.sixt@viscovery.net>,
spearce@spearce.org, git@vger.kernel.org
Subject: Re: Is a given file known to git?
Date: Tue, 11 Mar 2008 02:45:08 -0700 [thread overview]
Message-ID: <7vy78pbnmj.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <47D65074.4000505@melosgmbh.de> (Christoph Duelli's message of "Tue, 11 Mar 2008 10:27:16 +0100")
Christoph Duelli <duelli@melosgmbh.de> writes:
> Yes, thank you, Johannes and Shawn, this works.
> (A bit slow, though: with this test enabled my script takes 77 secs;
> without it it takes 0.3 secs. The time is spent in 9000 calls to the
> above test (the rev-parse version). (ok, the fact that there is a Perl
> system call around it might take some time, too).)
>
> [For the record:
> Shawn's ls-files variant takes: 148 secs
> Shawn's cat-file variant takes: 251 secs
> Time taken by time; roughly half user, half system.
> ]
>
> As this script won't run often, that not too big a deal.
I suspect that you asked a wrong question. If the original question were
"I have a git managed project whose tip has about 8000 paths in it, and I
have 9000 paths that may or may not belong to the tip. How do I find the
paths that are not part of the tip" (or "How do I find the ones that are
part of the tip"), the answer would have been quite different.
git ls-files | sort >known
(or "git ls-tree --name-only -r HEAD | sort >known")
$list_your_paths_one_per_line | sort | comm known -
would compare the set of paths in the index (or HEAD) and the set of the
paths you are interested in, and give you the list of ones that are only
present in one side, the other, or both. Say "comm -13" instead of "comm"
if you are only interested in untracked ones, and say "comm -12" if you
are only interested in tracked ones. Since you are working inside Perl,
probably you would not pipe to sort/comm but do the comm part yourself, I
would imagine.
It is as if you asked "how do I add one to a given number", without saying
that "I have 9000 paths and I want to repeatedly add one for each path I
have", people taught you the answer to your original question, and you
ended up looping "n := n + 1" 9000 times. If you told them the real
problem you were trying to solve upfront, they would have taught you how
to multiply instead ;-).
prev parent reply other threads:[~2008-03-11 9:46 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
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 [this message]
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=7vy78pbnmj.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=duelli@melosgmbh.de \
--cc=git@vger.kernel.org \
--cc=j.sixt@viscovery.net \
--cc=spearce@spearce.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).