* git-inject-tarball
@ 2005-12-28 2:40 Anand Kumria
2005-12-28 11:42 ` git-inject-tarball Johannes Schindelin
0 siblings, 1 reply; 4+ messages in thread
From: Anand Kumria @ 2005-12-28 2:40 UTC (permalink / raw)
To: git
Hi,
In the Everyday commands[1], there is an example of of extracting a
tarball and then working with it. I'm finding that I'm doing this fairly
often -- I was just wondering if anyone had anything like a
'git-inject-tarball' script they'd written up.
Thanks,
Anand
[1]: http://www.kernel.org/pub/software/scm/git/docs/everyday.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: git-inject-tarball
2005-12-28 2:40 git-inject-tarball Anand Kumria
@ 2005-12-28 11:42 ` Johannes Schindelin
2005-12-28 15:51 ` git-inject-tarball Simon Richter
0 siblings, 1 reply; 4+ messages in thread
From: Johannes Schindelin @ 2005-12-28 11:42 UTC (permalink / raw)
To: Anand Kumria; +Cc: git
Hi,
On Wed, 28 Dec 2005, Anand Kumria wrote:
>
> Hi,
>
> In the Everyday commands[1], there is an example of of extracting a
> tarball and then working with it. I'm finding that I'm doing this fairly
> often -- I was just wondering if anyone had anything like a
> 'git-inject-tarball' script they'd written up.
Something like this?
-- snip --
#!/bin/sh
TARFILE="$1"
test -z "$TARFILE" && TARFILE=-
git-ls-files -z | xargs -0 rm
tar xvf "$TARFILE" | xargs git add
git-update-index --remove $(git-ls-files)
-- snap --
Notes:
- this updates the index to match the given tarfile, you still
have to commit yourself
- it does not handle compressed tarfiles (you have to do something
like "cat bla.tar.gz | gzip -d | sh git-untar.sh")
- it does not remove empty directories (i.e. if the current index
contains a file "a/b", and the tarfile does not, and the
directory "a" is now empty, this is not handled)
- usually, tarfiles contain files inside a subdirectory. There is
no facility to strip the subdirectory
Hth,
Dscho
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: git-inject-tarball
2005-12-28 11:42 ` git-inject-tarball Johannes Schindelin
@ 2005-12-28 15:51 ` Simon Richter
2005-12-28 16:18 ` git-inject-tarball Johannes Schindelin
0 siblings, 1 reply; 4+ messages in thread
From: Simon Richter @ 2005-12-28 15:51 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: Anand Kumria, git
[-- Attachment #1: Type: text/plain, Size: 425 bytes --]
Hi,
Johannes Schindelin wrote:
> Something like this?
> -- snip --
> #!/bin/sh
>
> TARFILE="$1"
> test -z "$TARFILE" && TARFILE=-
>
> git-ls-files -z | xargs -0 rm
> tar xvf "$TARFILE" | xargs git add
> git-update-index --remove $(git-ls-files)
> -- snap --
Well, the most important thing for such a tool IMO would be that it
wouldn't overwrite any uncommitted changes, so it's not as trivial as it
seems.
Simon
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 307 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: git-inject-tarball
2005-12-28 15:51 ` git-inject-tarball Simon Richter
@ 2005-12-28 16:18 ` Johannes Schindelin
0 siblings, 0 replies; 4+ messages in thread
From: Johannes Schindelin @ 2005-12-28 16:18 UTC (permalink / raw)
To: Simon Richter; +Cc: Anand Kumria, git
Hi,
On Wed, 28 Dec 2005, Simon Richter wrote:
> Well, the most important thing for such a tool IMO would be that it wouldn't
> overwrite any uncommitted changes, so it's not as trivial as it seems.
Ah, but that's easy:
test -z "$(git-diff-index --name-only HEAD)" || exit 1
(This is just the idea; you should also output an error message.)
Hth,
Dscho
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-12-28 16:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-28 2:40 git-inject-tarball Anand Kumria
2005-12-28 11:42 ` git-inject-tarball Johannes Schindelin
2005-12-28 15:51 ` git-inject-tarball Simon Richter
2005-12-28 16:18 ` git-inject-tarball Johannes Schindelin
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).