On Mon, Aug 06, 2018 at 10:02:06PM -0700, William Steele wrote:
> Trying to execute git archive from an ant target and make it part of a
> deploy script—I am unable to get it to operate. Any assistance would be
> greatly appreciated.
>
>
> If I were to enter the command at the command line, it would be: git
> archive -o update.zip HEAD $(git diff --name-only HEAD^)
>
> When I make this an ant target:
>
>
>
>
>
>
>
>
>
>
>
The problem is that the $(command [args]) construct is the so-called
"command substitution" of a (POSIX) shell. That is, when you call
(broken into two lines to fit the message's width)
git archive -o /some/path/to/zip/deploy_changes.zip \
HEAD $(git diff --name-only HEAD^)
by hand, the shell first takes the text between the "$(" and the closing
")", executes it as a command, and replaces the whole "$(...)" thing
with the text that command printed into its standard output stream while
running. Then the shell executes the resulting command "as is".
The end result is that if that `git diff ...` encantation would print,
say, three file names, the command to be executed by the shell would be
git archive -o .../foo.zip HEAD file1 file2 file3
So, back to your problem. Your "Ant" thing — whatever it may be —
supposedly implements a special "target" tailored specifically to
execute Git commands, but it obviously call Git directly, not via a
shell, and hence that
$(git diff --name-only HEAD^)
thing gets passed to Git literally, as is.
There are at least two ways to solve this.
I'm not familiar with Ant so the first one will be a wild guess.
1. If Ant has a way to execute a command, collect its output
and use it as argument(s) to pass to another command, that's the
way to go: you first run `git diff ...` as a separate command,
collect its output and then instruct Ant to use that output
as the rest of arguments to call `git archive`.
2. Use the second approach with the "exec" action but make Ant
call the shell.
Something like this should do:
The action would call the shell and then pass it _a shell script_
to execute specified as a single parameter to its "-c" option.
--
You received this message because you are subscribed to the Google Groups "Git
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.