From: Junio C Hamano <gitster@pobox.com>
To: Gerrit Pape <pape@smarden.org>
Cc: git@vger.kernel.org
Subject: Re: [PATCH/selftest] hash-object: don't rely on order of --stdin, -w arguments
Date: Wed, 13 Feb 2008 15:25:11 -0800 [thread overview]
Message-ID: <7v8x1oo2w8.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <20080213224941.18121.qmail@c0fdbb95c1b5f1.315fe32.mid.smarden.org> (Gerrit Pape's message of "Wed, 13 Feb 2008 22:49:41 +0000")
Gerrit Pape <pape@smarden.org> writes:
> Fix 'git hash-object --stdin -w' to actually write the object, just as
> 'git hash-object -w --stdin' does.
>
> Reported by Josh Triplett through
> http://bugs.debian.org/464432
>
> Signed-off-by: Gerrit Pape <pape@smarden.org>
Thanks. I think the patch itself is a good fix to the old
design mistake we made.
However, I would _really_ like to see something like the
following mentioned in the proposed commit log message for
discussion:
This regresses the use case of running:
$ git hash-object --stdin Makefile <cache.h
to obtain hash values for cache.h and then Makefile. It
used to report the object names in order, but now it always
processes --stdin at the end. It is not an issue if
everything is file (i.e. "git hash-object cache.h Makefile"
is an easy replacement), but if existing scripts used the
option to read from a pipe, this might become problematic.
Similarly, when typing from terminal:
$ git hash-object --stdin --stdin
foo
^D
bar
^D
used to work, but not anymore. The latter however should
not be something we need to worry about. It is an insane
usage.
Granted, we _should have_ prevented such insane usages (the
second one is definitely insane and not so useful, and the first
one is but to a much lessor degree). We _should have_ forced
scripted users to do these with two separate invocations of "git
hash-object", by refusing more than one --stdin and --stdin with
filename on the command line. But we didn't, and this earlier
design mistake has already been in the field for a long time.
People may have been depending on the existing misbehaviour.
So I am Ok with the patch, and I strongly suspect that we should
even detect more than one --stdin and --stdin with filename on
the command line to reject the usage your saner version behaves
differently from before, instead of accepting and silently doing
an unexpected thing.
But at the same time I would really like our commit messages,
and Release Notes that is based on these commit messages, to be
_candid_ about our previous mistakes and the incompatibility we
are incurring to the existing users.
> +test_expect_success \
> + 'git hash-object -w --stdin saves the object' \
> + 'echo foo | git hash-object -w --stdin &&
> + test -r .git/objects/25/7cc5642cb1a054f08cc83f2d943e56fd3ebe99 &&
> + rm -f .git/objects/25/7cc5642cb1a054f08cc83f2d943e56fd3ebe99'
I'd feel better if tests outside t0000 did not hardcode the
actual values, like this:
obname=$(echo foo | git hash-object -w --stdin) &&
ob=$(expr "$obname" : "\(..\)") &&
name=$(expr "$obname" : "..\(.*\)") &&
test -f ".git/objects/$ob/$name"
next prev parent reply other threads:[~2008-02-13 23:26 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-13 19:03 [PATCH] hash-object: don't rely on order of --stdin, -w arguments Gerrit Pape
2008-02-13 19:50 ` Junio C Hamano
2008-02-13 22:49 ` [PATCH/selftest] " Gerrit Pape
2008-02-13 23:25 ` Junio C Hamano [this message]
2008-02-14 20:13 ` [PATCH] hash-object: cleanup handling of command line options Gerrit Pape
2008-02-15 17:31 ` Junio C Hamano
2008-02-21 10:06 ` Gerrit Pape
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=7v8x1oo2w8.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=pape@smarden.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).