Using xargs with git
xargs -0
means to use only null bytes to separate input records, and include newline characters and other whitespace in the input. You're going to have a newline at the end of the revision output there, which head
and cut
will leave there, and which will be included in the argument given to git
. Git doesn't like that. I think you've edited the newline out of the error message, but it is actually a part of the message here and what's causing your problem.
Removing -0
makes your command work for me. Given the input you're generating, the default newline-separated behaviour of xargs
is safe.
You don't really need to use -I {}
in this case either — git
is quite happy to have the revision as the last argument, but I guess you're using it for practice's sake. By default, xargs
just puts the arguments at the very end of the given command (unlike find -exec
, which uses the {}
substitution).
You're also doing a bit much work, though, with your cut
. Git is more than capable of arranging its output in a format you can use with xargs
. Using the --pretty=tformat...
option we can make it spit out just the SHA1 hashes, one per line:
git log --author=jim --grep="patch" --pretty=tformat:'%H'
will output all the hashes of matching commits in your repository, one per line. --pretty
sets the output formatting; tformat
means to put a newline at the end of every hash; '%H' means the hash.
You can pipe that into xargs, and since the entire input is "clean" [a-f0-9] you can use it with the default line-separation
Genadinik
Updated on September 18, 2022Comments
-
Genadinik over 1 year
I am reading instructions here: http://developer.android.com/training/in-app-billing/test-iab-app.html
and it says to upload your app (which I did) and then I would be able to create billing items for it. But I do not see a way to create the items for users to purchase. Could someone please list the steps to do that?
Thank you!
-
Jim almost 10 yearsBut why doesn't the first version without
-0
and without-I
work? -
Michael Homer almost 10 years
xargs
doesn't use{}
for substitution. That'sfind
.xargs
just puts them at the end by default, unless you use-I
.