From: Nikolaj Shurkaev <snnicky@gmail.com>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org
Subject: Re: git log -z doesn't separate commits with NULs
Date: Thu, 23 Feb 2012 15:17:37 +0300 [thread overview]
Message-ID: <4F462E61.4020203@gmail.com> (raw)
In-Reply-To: <20120223102426.GB2912@sigill.intra.peff.net>
Hello.
Thank you very much for your tips. They really helped me. I was trying
to create patches that would affect only some given files or folders. By
this moment I have the following:
GeneratePatches.sh
---------------------
#!/bin/bash
#parameter 1 - <since>..<to>
#parameter 2 - path to file
git log -z --reverse --format=email --patch "$1" -- "$2" | xargs --null
--max-args=1 ./CreatePatchFile.sh
---------------------
and CreatePatchFile.sh
---------------------
#!/bin/bash
myPatchNumber=$(ls ./*-patch.patch 2>/dev/null | wc -l)
let "myPatchNumber += 1"
patchFile="./"$(printf "%04d" $myPatchNumber)"-patch.patch"
echo "$@" > "$patchFile"
---------------------
I call
./GeneratePatches.sh HEAD~3..HEAD SomePath
and that produces something very similar to what I want.
Perhaps there is a better way to do that.
Thank you once again.
---
Best regards,
Nikolaj
23.02.2012 13:24, Jeff King пишет:
> On Thu, Feb 23, 2012 at 12:14:23PM +0300, Nikolaj Shurkaev wrote:
>
>> I wanted to generate several files with some statistics using "git
>> log -z" command.
>> I did something like this:
>> git log -z --patch HEAD~10..HEAD -- SomePathHere | xargs -0
>> --max-chars=1000000 ~/1.sh
> I'm not sure what "1.sh" is expecting to take as input, but that will
> feed entire commits, including their commit message and entire diff, to
> the script on its command line.
>
> That seems like an awkward interface, but we don't really know what your
> script intends to do. Maybe it is worth sharing the contents of the
> script.
>
>> If I put echo "started" into the file ~/1.sh I see that the file is
>> called only once instead of multiple times.
> Yes. The point of xargs is usually to cram as many arguments into each
> invocation of "1.sh" as possible, splitting into multiple invocations
> only when we hit the argument-list memory limit that the OS imposes.
>
> If you want xargs to give each argument its own invocation of the
> script, use "xargs -n1".
>
>> I'm newbie to xargs, thus I tested with and that worked as I expected.
>> find . -type f -print0 | xargs -0 ./1.sh
>> That produced a lost of "started" lines.
> If you instrument your 1.sh more[1], you will find that is not executing
> once per file, but rather getting a large chunk of files per invocation.
>
> [1] Try adding: echo "got args: $*"
>
>> Thus I suspect there is a but in git log -z command and that doesn't
>> "Separate the commits with NULs instead of with new newlines." as
>> promised in the documents.
> You could verify that assertion by looking at the output. Try piping
> your "git log" command through "cat -A | less". When I try it, I see a
> NUL between each commit (cat -A will show it as "^@").
>
> -Peff
>
next prev parent reply other threads:[~2012-02-23 12:17 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-23 9:14 git log -z doesn't separate commits with NULs Nikolaj Shurkaev
2012-02-23 10:02 ` Luke Diamand
2012-02-23 10:27 ` Jeff King
2012-02-23 10:17 ` Johannes Sixt
2012-02-23 12:11 ` Nikolaj Shurkaev
2012-02-23 10:24 ` Jeff King
2012-02-23 12:17 ` Nikolaj Shurkaev [this message]
2012-02-23 13:15 ` Jakub Narebski
2012-02-23 13:48 ` Nikolaj Shurkaev
2012-02-23 19:34 ` Jeff King
2012-02-23 20:07 ` Junio C Hamano
2012-02-24 9:21 ` Nikolaj Shurkaev
2012-02-24 9:52 ` Jeff King
2012-02-24 20:03 ` Junio C Hamano
2012-02-24 20:46 ` Jeff King
2012-02-24 21:14 ` Junio C Hamano
2012-02-24 21:16 ` Jeff King
2012-03-03 13:41 ` Nikolaj Shurkaev
2012-02-24 22:11 ` Jakub Narebski
2012-02-24 22:27 ` Junio C Hamano
2012-02-23 10:35 ` Andreas Schwab
2012-02-23 12:19 ` Nikolaj Shurkaev
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=4F462E61.4020203@gmail.com \
--to=snnicky@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.