Re: git-inject-tarball

Previous thread: [PATCH 4/6] git-describe: still prefer annotated tag under --all and --tags by Junio C Hamano on Tuesday, December 27, 2005 - 5:42 pm. (1 message)

Next thread: [PATCH] fix skipping merge-order test with NO_OPENSSL=1. by Gerrit Pape on Wednesday, December 28, 2005 - 4:25 am. (1 message)
From: Anand Kumria
Date: Tuesday, December 27, 2005 - 7:40 pm

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

-

From: Johannes Schindelin
Date: Wednesday, December 28, 2005 - 4:42 am

Hi,


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

-

From: Simon Richter
Date: Wednesday, December 28, 2005 - 8:51 am

Hi,


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
From: Johannes Schindelin
Date: Wednesday, December 28, 2005 - 9:18 am

Hi,


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

-

Previous thread: [PATCH 4/6] git-describe: still prefer annotated tag under --all and --tags by Junio C Hamano on Tuesday, December 27, 2005 - 5:42 pm. (1 message)

Next thread: [PATCH] fix skipping merge-order test with NO_OPENSSL=1. by Gerrit Pape on Wednesday, December 28, 2005 - 4:25 am. (1 message)