git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: Michael Henry <git@drmikehenry.com>, git@vger.kernel.org
Subject: Re: `git bundle create -` may not write to `stdout`
Date: Fri, 03 Mar 2023 17:14:37 -0800	[thread overview]
Message-ID: <xmqqa60tco76.fsf@gitster.g> (raw)
In-Reply-To: <ZAJ6oI3clNH2O3R7@coredump.intra.peff.net> (Jeff King's message of "Fri, 3 Mar 2023 17:54:24 -0500")

Jeff King <peff@peff.net> writes:

> (I do still think we don't want to push it down into prefix_filename(),
> because it gets used for paths and pathspecs given raw on the command
> line. It does make me wonder if there are places where OPT_FILENAME() is
> doing the wrong thing).

To be quite honest, I had the opposite reaction ;-)  At least for
OPT_FILENAME() thing, I think it is well known that you should work
around with "git cmd --opt ./-" if you do mean a file whose name
happens to be a single dash.  Teaching prefix_filename() the same
trick does not look _too_ bad.

There is a problem that commands that use prefix_filename() may not
be prepared to read from the standard input or write to the standard
output.  For some such callers it may be just the matter of
replacing an unconditional open() with

	-	fd = open(filename, O_RDONLY);
	+	if (!strcmp(filename, "-"))
	+		fd = 0;
	+	else
	+		fd = open(filename, O_RDONLY);

or something, but if some callers have fundamental reasons why they
do not want to work with the standard input, it may make sense to
treat "-" as a normal filename, and for them, blindly prefixing the
leading directory name would be much better than special casing "-".

So, I dunno.



  parent reply	other threads:[~2023-03-04  1:16 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-25 12:58 `git bundle create -` may not write to `stdout` Michael Henry
2023-02-26 23:16 ` Jeff King
2023-03-03 22:31   ` Junio C Hamano
2023-03-03 22:54     ` Jeff King
2023-03-03 23:05       ` Junio C Hamano
2023-03-04  1:28         ` Jeff King
2023-03-04  1:46           ` Jeff King
2023-03-04 10:22             ` [PATCH 0/5] handling "-" as stdin/stdout in git bundle Jeff King
2023-03-04 10:26               ` [PATCH 1/5] bundle: let "-" mean stdin for reading operations Jeff King
2023-03-04 10:26               ` [PATCH 2/5] bundle: document handling of "-" as stdin Jeff King
2023-03-04 10:27               ` [PATCH 3/5] bundle: don't blindly apply prefix_filename() to "-" Jeff King
2023-03-04 10:31               ` [PATCH 4/5] parse-options: consistently allocate memory in fix_filename() Jeff King
2023-03-04 10:31               ` [PATCH 5/5] parse-options: use prefix_filename_except_for_dash() helper Jeff King
2023-03-04 10:55               ` [RFC/PATCH] bundle: turn on --all-progress-implied by default Jeff King
2023-03-06  3:44                 ` Robin H. Johnson
2023-03-06  5:38                   ` Jeff King
2023-03-06  9:25                     ` Jeff King
2023-03-06 17:41                 ` Junio C Hamano
2023-03-06 17:34             ` `git bundle create -` may not write to `stdout` Junio C Hamano
2023-03-04  1:14       ` Junio C Hamano [this message]
2023-03-04  1:43         ` Jeff King
2023-03-03 23:59     ` Michael Henry
2023-03-04  2:22       ` Jeff King
2023-03-04 10:08         ` Michael Henry

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=xmqqa60tco76.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@drmikehenry.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).