From: Junio C Hamano <gitster@pobox.com>
To: <carlos.duclos@nokia.com>
Cc: <git@vger.kernel.org>
Subject: Re: [PATCH v3] git-archive: Add new option "--output" to write archive to a file instead of stdout.
Date: Tue, 17 Feb 2009 10:38:38 -0800 [thread overview]
Message-ID: <7v7i3o6h8x.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: 599636D7828020419E3AB2DE5CCC8130036BF8B1D6@NOK-EUMSG-02.mgdnok.nokia.com
<carlos.duclos@nokia.com> writes:
> 4. Didn't change the tests, it never hurts to have many tests :-)
It actually hurts me a lot. I run every tests before pushing out the
integration results, and duplicated tests costs me a lot without adding
much value to the process.
> From b68d40dca34d45e2535c50879cce62e3b24a2f30 Mon Sep 17 00:00:00 2001
> From: Carlos Manuel Duclos Vergara <carlos.duclos@nokia.com>
> Date: Mon, 16 Feb 2009 18:20:25 +0100
> Subject: [PATCH] git-archive: Add new option "--output" to write archive to a file instead of stdout.
Very long line that you can be a bit creative to shorten. E.g.
git-archive: add --output=<file> to send output to a file instead of stdout
Because anything you are adding is new, people can tell that --word is an
option from the context, and people who are reading "git log" output know
that archive command traditionally writes to standard output.
> When archiving a repository there is no way to specify a file as output. This patch adds a new option "--output" that redirects the output to a file instead of stdout.
Very long line I can wrap locally so this by itself is not a grave enough
offence to ask you to fix and resubmit, but I'm asking you to redo the
tests anyway, so please wrap this while at it.
Needs a sign-off.
> diff --git a/archive.c b/archive.c
> index e6de039..e6af4ec 100644
> --- a/archive.c
> +++ b/archive.c
> @@ -239,6 +239,23 @@ static void parse_treeish_arg(const char **argv,
> ar_args->time = archive_time;
> }
>
> +static void create_output_file(const char *output_file)
> +{
> + int output_fd = open(output_file, O_CREAT | O_WRONLY | O_TRUNC, 0666);
> + if (output_fd < 0)
> + die("could not create archive file: %s ", output_file);
> + if (output_fd != 1)
> + if (dup2(output_fd, 1) < 0) {
> + /*
> + * dup2 closes output_fd on success, if something
> + * goes wrong we close output_fd here to avoid
> + * problems.
> + */
> + close(output_fd);
> + die("could not redirect output");
The comment and close() are probably unnecessary, as you will die()
immediately.
> +test_expect_success 'tar archive output redirected' '
> +
> + git archive --format=tar --output=test.tar HEAD &&
> + ( mkdir untarred2 && cd untarred2 && "$TAR" -xf ../test.tar )
> +
> + test_cmp sample untarred2/sample
> +
> +'
I agree with René that the test should just create the same archive twice,
with or without --output=, and compare the output.
To protect your patch from future changes that may do something funny to
only one side of the codepath, which is not even very likely knowing the
structure of the code, I'd recommend doing two tests, one for --format=tar
and another for --format=zip.
Also you do not have to introduce an inconsistent way to give option to
"tar" like the above (note that "tar xf" is the preferred traditional
notation, not "tar -xf", in this script).
Other than that, I think this is ready for 'next'.
next prev parent reply other threads:[~2009-02-17 18:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-17 9:42 [PATCH v3] git-archive: Add new option "--output" to write archive to a file instead of stdout carlos.duclos
2009-02-17 18:38 ` Junio C Hamano [this message]
2009-02-17 22:59 ` René Scharfe
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=7v7i3o6h8x.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=carlos.duclos@nokia.com \
--cc=git@vger.kernel.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).