Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
615 views
in Technique[技术] by (71.8m points)

git - "Index-pack failed"

upon cloning a git repository, I get an error message that I can't quite grasp.

$ git clone [email protected]:group07
Initialized empty Git repository in /cygdrive/C/Users/Martin Bigler/p2/group07/.
remote: Counting objects: 2269, done.
remote: Compressing objects: 100% (1936/1936), done.
git: 'index-pack' is not a git-command. See 'git --help'.

What could possibly cause this behavior?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Is this similar to ticket 269?

git index-pack isn't a built-in in git.exe, so git.exe needs to find git-index-pack.exe in $GIT_EXEC_PATH (which should usually be "/libexec/git-core/"). Do you have "/libexec/git-core/git-index-pack.exe"?

Because if it is, this is the server which causes the error, not the locally installed git doing the push.

You can try logging interactively and check index-pack is available:

$ ssh git#***.com@***.com
Enter passphrase for key '/c/Users/***/.ssh/id_rsa':
Last login: Tue Feb  9 13:48:32 2010 from ***
-bash-3.2$ git version
git version 1.6.1
-bash-3.2$ git-index-pack
usage: git index-pack [-v] [-o <index-file>] [{ ---keep | --keep=<msg> }] [--strict] 
{ <pack-file> | --stdin [--fix-thin] [<pack-file>] }

That test prompted the following answer:

Your git-index-pack is found when logging in interactively.
But apparently not when you do not log in interactively.
That suggests that you adjusted your PATH appropriately in $HOME/.profile or $HOME/.bash_profile, but not in HOME/.bashrc

And the conclusion:

My solution is:

ssh user@server
cp .bash_profile .bashrc

Note that with Git 2.25.2 (March 2020), the index-pack code now diagnoses a bad input packstream that records the same object twice when it is used as delta base; the code used to declare a software bug when encountering such an input, but it is an input error.

See commit a217810 (03 Feb 2020) by Jeff King (peff).
(Merged by Junio C Hamano -- gitster -- in commit 7b029eb, 14 Feb 2020)

index-pack: downgrade twice-resolved REF_DELTA to die()

Signed-off-by: Jeff King

When we're resolving a REF_DELTA, we compare-and-swap its type from REF_DELTA to whatever real type the base object has, as discussed in ab791dd138 ("index-pack: fix race condition with duplicate bases", 2014-08-29, Git v2.2.0-rc0 -- merge).
If the old type wasn't a REF_DELTA, we consider that a BUG(). But as discussed in that commit, we might see this case whenever we try to resolve an object twice, which may happen because we have multiple copies of the base object.

So this isn't a bug at all, but rather a sign that the input pack is broken. And indeed, this case is triggered already in t5309.5 and t5309.6, which create packs with delta cycles and duplicate bases. But we never noticed because those tests are marked expect_failure.

Those tests were added by b2ef3d9ebb ("test index-pack on packs with recoverable delta cycles", 2013-08-23, Git v1.8.5-rc0 -- merge listed in batch #4), which was leaving the door open for cases that we theoretically could handle.
And when we see an already-resolved object like this, in theory we could keep going after confirming that the previously resolved child->real_type matches base->obj->real_type.

But:

  • enforcing the "only resolve once" rule here saves us from an infinite loop in other parts of the code.
    If we keep going, then the delta cycle in t5309.5 causes us to loop infinitely, as find_ref_delta_children() doesn't realize which objects have already been resolved.
    So there would be more changes needed to make this case work, and in the meantime we'd be worse off.

  • any pack that triggers this is broken anyway.
    It either has a duplicate base object, or it has a cycle which causes us to bring in a duplicate via --fix-thin.
    In either case, we'd end up rejecting the pack in write_idx_file(), which also detects duplicates.

So the tests have little value in documenting what we could be doing (and have been neglected for 6+ years).
Let's switch them to confirming that we handle this case cleanly (and switch out the BUG() for a more informative die() so that we do so).


With Git 2.30 (Q1 2021), Processes that access packdata while the .idx file gets removed (e.g. while repacking) did not fail or fall back gracefully as they could.

See commit 506ec2f, commit c8a45eb (25 Nov 2020) by Taylor Blau (ttaylorr).
(Merged by Junio C Hamano -- gitster -- in commit 6bac6a1, 08 Dec 2020)

packfile.c: protect against disappearing indexes

Co-authored-by: Jeff King
Signed-off-by: Taylor Blau

In 17c35c8969 ("packfile: skip loading index if in multi-pack-index", 2018-07-12, Git v2.20.0-rc0 -- merge listed in batch #1) we stopped loading the .idx file for packs that are contained within a multi-pack index.

This saves us the effort of loading an .idx and doing some lightweight validity checks by way of 'packfile.c:load_idx()', but introduces a race between processes that need to load the index (e.g., to generate a reverse index) and processes that can delete the index.

For example, running the following in your shell:

$ git init repo && cd repo
$ git commit --allow-empty -m 'base'
$ git repack -ad && git multi-pack-index write  

followed by:

$ rm -f .git/objects/pack/pack-*.idx
$ git rev-parse HEAD | git cat-file --batch-check='%(objectsize:disk)'  

will result in a segfault prior to this patch.

What's happening here is that we notice that the pack is in the multi-pack index, and so don't check that it still has a .idx.
When we then try and load that index to generate a reverse index, we don't have it, so the call to 'find_pack_revindex()' in 'packfile.c:packed_object_info()' returns NULL, and then dereferencing it causes a segfault.

Of course, we don't ever expect someone to remove the index file by hand, or to be in a state where we never wrote it to begin with (yet find that pack in the multi-pack-index). But, this can happen in a timing race with 'git repack -ad'(man), which removes all existing packs after writing a new pack containing all of their objects.

Avoid this by reverting the hunk of 17c35c8969 which stops loading the index when the pack is contained in a MIDX.
This makes the latter half of 17c35c8969 useless, since we'll always have a non-NULL 'p->index_data', in which case that if statement isn't guarding anything.

These two together effectively revert 17c35c8969, and avoid the race explained above.


With Git 2.31 (Q1 2021), introduce an on-disk file to record revindex for packdata, which traditionally was always created on the fly and only in-core.

See commit 6885cd7 (28 Jan 2021), and commit ec8e776, commit e8c58f8, commit 35a8a35, commit 1615c56, commit c977334, commit e37d0b8, commit 84d5449, commit 8ef50d9, commit 2f4ba2a (25 Jan 2021) by Taylor Blau (ttaylorr).
(Merged by <a href="https://github.com/gitster" rel="nofoll


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...