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 15:05:14 -0800 [thread overview]
Message-ID: <xmqqpm9pcu6t.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:
> This test looks good to me. Let's also not forget about the doc fixes. I
> don't think there's much urgency to get this into v2.40,
Doc? Meaning
<file> can be "-" to mean the standard output (for writing)
or the standard input (for reading)
or something?
Given that the other three subcommands also take <file>
'git bundle' create [-q | --quiet | --progress | --all-progress] ...
[--version=<version>] <file> <git-rev-list-args>
'git bundle' verify [-q | --quiet] <file>
'git bundle' list-heads <file> [<refname>...]
'git bundle' unbundle [--progress] <file> [<refname>...]
but read_bundle_header() function all three calls begins like so:
int read_bundle_header(const char *path, struct bundle_header *header)
{
int fd = open(path, O_RDONLY);
if (fd < 0)
return error(_("could not open '%s'"), path);
return read_bundle_header_fd(fd, header, path);
}
this function needs to be fixed first ;-)
Of course none of these is urgent for the upcoming 2.40 ;-).
> but I can put
> it together in the next day or three.
Thanks. Just for reference, here is what I have (just a log
message, the patch is the same and does not support input yet).
----- >8 -----
Subject: [PATCH] bundle: don't blindly apply prefix_filename() to "-"
A user can specify a filename to a command from the command line,
either as the value given to a command line option, or a command
line argument. When it is given as a relative filename, in the
user's mind, it is relative to the directory "git" was started from,
but by the time the filename is used, "git" would almost always have
chdir()'ed up to the root level of the working tree.
The given filename, if it is relative, needs to be prefixed with the
path to the current directory, and it typically is done by calling
prefix_filename() helper function. For commands that can also take
"-" to use the standard input or the standard output, however, this
needs to be done with care.
"git bundle create" uses the next word on the command line as the
output filename, and can take "-" to mean "write to the standard
output". It blindly called prefix_filename(), so running it in a
subdirectory did not quite work as expected.
Introduce a new helper, prefix_filename_except_for_dash(), and use
it to help "git bundle create" codepath.
Reported-by: Michael Henry
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
abspath.c | 7 +++++++
builtin/bundle.c | 2 +-
cache.h | 3 +++
parse-options.c | 4 ++++
t/t6020-bundle-misc.sh | 11 +++++++++++
5 files changed, 26 insertions(+), 1 deletion(-)
next prev parent reply other threads:[~2023-03-03 23:05 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 [this message]
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
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=xmqqpm9pcu6t.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).