I want to use something like the following command to create a tarball to deploy:
tar cjvf ~/deploy.tar.bz2 `git diff --name-only 0abc 1def`
The inner git diff command produces a list of files with relative including the relative path when i run it separately.
I'm running into two problems though, I need to be able to auto escape spaces in the output, so tar doesn't complain about files containing spaces and when the tar does get created, all the files have a duplicate 'hidden file' preceded by a '.' that don't show up with ls -al. These are OSX specific metafiles as noted by kch.
Anyway, does anyone know of the solution to these problems, or is there just a plain easier way to script this?
Why do not use
--files-from=FILE
or-T FILE
option of tar, where FILE can be '-' to signify standard input?You shouldn't have problem with spaces or tabs in filenames, or with single quotes, or backquotes, or backslashes (I think your solution would have problems with single quote "'" in filename). You might have problem with newlines in filenames, just like in IFS solution.
Here's another, more elegant solution that works around escaping spaces in the filenames
As jpalecek pointed out, one wold not want to run "tar -c..." multiple times, it's better to use -r.
The hidden dot-files, are they dot-underscore-files?
If for file
foo
you have another._foo
, and you're on a Mac, the dot-underscore file is where the file resource fork / metadata is kept.As for the git output, might try piping it through
sed
orperl
for quoting. I believexargs
could help here too.If size doesn't matter you could use git archive.
I'm not sure if it's possible to create a tarball containing only the differences between two commits.
You can try
or try the same thing using sed, or
Note that there is only a single newline in IFS.
However, if the name of your files contain newlines, you're doomed.
I settled on the following solution with sed.