git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Torsten Bögershausen" <tboegi@web.de>
Cc: git@vger.kernel.org,  ps@pks.im
Subject: Re: Problems with t6011
Date: Tue, 06 May 2025 14:18:33 -0700	[thread overview]
Message-ID: <xmqqa57ph1zq.fsf@gitster.g> (raw)
In-Reply-To: <71fcb24d-55e3-40bb-9368-5b47aa180993@web.de> ("Torsten Bögershausen"'s message of "Tue, 6 May 2025 14:32:04 +0200")

Torsten Bögershausen <tboegi@web.de> writes:

> Hej Patrick,
> in case you have a second:
> the mv command here needs a "-f" to overwrite
> read-only files:
>
> --- a/t/t6011-rev-list-with-bad-commit.sh
> +++ b/t/t6011-rev-list-with-bad-commit.sh
> @@ -39,7 +39,7 @@ test_expect_success 'corrupt second commit object' '
>         for p in .git/objects/pack/*.pack
>         do
>                 sed "s/second commit/socond commit/" "$p" >"$p.munged" &&
> -               mv "$p.munged" "$p" ||
> +               mv -f "$p.munged" "$p" ||
>                 return 1

Looking at the remainder of cdbdc6bf (t: refactor tests depending on
Perl substitution operator, 2025-04-03), the commit that introduced
these lines, it seems that the prevailing pattern was:

	chmod +w "$packfile" &&
	perl -pe "regexp" "$packfile" >"$packfile.munged" &&
	mv "packfile.munged" $packfile"

but the original for this loop used "perl -i.bak -pe" that dealt
with read-only input just fine, wihtout the need for a separate
"mv".

So the lack of "-f" indeed is a bug in that "refactor" commit.

I would be more worried about using "sed" on clearly non-text files,
which technically is undefined operation, and I strongly suspect
that it was the reason why we used Perl to munge files that are
clearly binary, like the packfiles, in the first place.



  reply	other threads:[~2025-05-06 21:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-06 12:32 Problems with t6011 Torsten Bögershausen
2025-05-06 21:18 ` Junio C Hamano [this message]
2025-05-06 22:48 ` [PATCH] t6011: fix misconversion from perl to sed Junio C Hamano
2025-05-07  4:57   ` Patrick Steinhardt
2025-05-07 15:29     ` 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=xmqqa57ph1zq.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=ps@pks.im \
    --cc=tboegi@web.de \
    /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).