From: Kacper Kornet <kornet@camk.edu.pl>
To: git@vger.kernel.org
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [BUG] Shallow fetch can result in broken git repo
Date: Mon, 26 Aug 2013 02:22:02 +0200 [thread overview]
Message-ID: <20130826002202.GA26940@camk.edu.pl> (raw)
Starting from "6035d6a fetch-pack: prepare updated shallow file before
fetching the pack" the shallow fetches of commits with tags can result
in broken git repo. The following script illustrates the problem:
#!/bin/sh
mkdir repo1 repo2
cd repo1
git init
for i in `seq 1 3`; do
echo $i > foo
git add foo
git commit -m "Commit $i"
done
git tag tag HEAD~1
cd ../repo2
git init
git fetch --depth=2 ../repo1 master:branch
git fsck
The function fetch_pack in this case is called twice. During the
second called alternate_shallow_file contains "\0" (it is set to this
value by commit_lock_file(&shallow_lock) during first call of
fetch_pack). In the result the file .git/shallow, created during first
call to fetch_pack, is removed and the git repo ends with broken link.
The two possible fixes which I see are:
1) Replace back if (alternate_shallow_file) condition in fetch pack with
if (args->depth > 0)
2) alternate_shallow_file should be copy of shallow_lock.filename not a
reference to it
But I'm not able to determine by myself which one (if any) is a correct fix
to the problem.
--
Kacper
next reply other threads:[~2013-08-26 0:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-26 0:22 Kacper Kornet [this message]
2013-08-26 2:17 ` [PATCH] fetch-pack: do not remove .git/shallow file when --depth is not specified Nguyễn Thái Ngọc Duy
2013-08-26 6:09 ` 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=20130826002202.GA26940@camk.edu.pl \
--to=kornet@camk.edu.pl \
--cc=git@vger.kernel.org \
--cc=pclouds@gmail.com \
/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.