From: Jonathan Nieder <jrnieder@gmail.com>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] write_index: optionally allow broken null sha1s
Date: Sat, 24 Aug 2013 23:15:00 -0700 [thread overview]
Message-ID: <20130825061500.GR2882@elie.Belkin> (raw)
In-Reply-To: <20130824013310.GA9343@sigill.intra.peff.net>
Hi,
Jeff King wrote:
> ---
> I was tempted to not involve filter-branch in this commit at all, and
> instead require the user to manually invoke
>
> GIT_ALLOW_NULL_SHA1=1 git filter-branch ...
>
> to perform such a filter. That would be slightly safer, but requires
> some specialized knowledge from the user (and advice on using
> filter-branch to remove such entries already exists on places like
> stackoverflow, and this patch makes it Just Work on recent versions of
> git).
The above few paragraphs explained the most mysterious part of the
patch to me. I think they would be fine to include in the commit
message.
[...]
> --- a/read-cache.c
> +++ b/read-cache.c
> @@ -1817,8 +1817,17 @@ int write_index(struct index_state *istate, int newfd)
> continue;
> if (!ce_uptodate(ce) && is_racy_timestamp(istate, ce))
> ce_smudge_racily_clean_entry(ce);
> - if (is_null_sha1(ce->sha1))
> - return error("cache entry has null sha1: %s", ce->name);
> + if (is_null_sha1(ce->sha1)) {
> + static const char msg[] = "cache entry has null sha1: %s";
> + static int allow = -1;
> +
> + if (allow < 0)
> + allow = git_env_bool("GIT_ALLOW_NULL_SHA1", 0);
> + if (allow)
> + warning(msg, ce->name);
> + else
> + return error(msg, ce->name);
> + }
Makes sense.
[...]
> --- /dev/null
> +++ b/t/t7009-filter-branch-null-sha1.sh
> @@ -0,0 +1,54 @@
> +#!/bin/sh
> +
> +test_description='filter-branch removal of trees with null sha1'
> +. ./test-lib.sh
> +
> +test_expect_success 'create base commits' '
> + test_commit one &&
> + test_commit two &&
> + test_commit three
> +'
> +
> +test_expect_success 'create a commit with a bogus null sha1 in the tree' '
> + test_tick &&
> + tree=$(
> + {
> + git ls-tree HEAD &&
> + printf "160000 commit $_z40\\tbroken"
> + } | git mktree
> + ) &&
To avoid pipes involving git commands, since they can losing the exit
status (and hence information about whether git crashed):
{
git ls-tree HEAD &&
echo "160000 commit $_z40 broken"
} >listing &&
echo "add broken entry" >msg &&
tree=$(git mktree <listing) &&
test_tick &&
commit=$(git commit-tree "$tree" -p HEAD <msg) &&
git update-ref HEAD "$commit"
The rest looks good.
Thanks,
Jonathan
next prev parent reply other threads:[~2013-08-25 6:15 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-24 1:33 [PATCH] write_index: optionally allow broken null sha1s Jeff King
2013-08-25 6:15 ` Jonathan Nieder [this message]
2013-08-25 9:58 ` [PATCHv2] " Jeff King
2013-08-25 19:54 ` Jonathan Nieder
2013-08-26 6:03 ` Junio C Hamano
2013-08-26 14:31 ` Jeff King
2013-08-26 16:02 ` Junio C Hamano
2013-08-26 21:36 ` Jeff King
2013-08-26 14:27 ` Jeff King
2013-08-26 17:35 ` Jonathan Nieder
2013-08-26 21:20 ` Jeff King
2013-08-27 3:46 ` Junio C Hamano
2013-08-27 20:41 ` [PATCHv3] " Jeff King
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=20130825061500.GR2882@elie.Belkin \
--to=jrnieder@gmail.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
/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).