threads / discuss / 314

git add / update-cache --add fails.

Subject: git add / update-cache --add fails.

## tl;dr

14 messages between Apr 25, 2005 and Apr 28, 2005.

replies: 13people: 8as markdown or json

Rhys Hardwick· Apr 25, 2005, 21:26 UTC · lore
Hello people,

I get these errors when trying to add a new file to the directory. I pulled the latest version today, and the day before yesterdays version had the same problem (using git-pasky)

rhys@metatron:~/repo/learning.repo$ update-cache --add w1d4p1.c fatal: Unable to add w1d4p1.c to database rhys@metatron:~/repo/learning.repo$ git add w1d4p1.c fatal: Unable to add w1d4p1.c to database rhys@metatron:~/repo/learning.repo$

Any ideas?
Rhys
Rhys Hardwick· Apr 25, 2005, 21:52 UTC · re: Rhys Hardwick · lore

Re: git add / update-cache --add fails.

Sorry about previous email.
Just to clarify, the latest version of git to be merged with pasky is:
4e03aae5feb2e3fd2f543796ca3d3e8aa86c02dc

I have tried rebooting, and looking at a few sources, and nothing has helped. It's interesting noone else has had the same problem.

Rhys
Chris Wedgwood· Apr 25, 2005, 22:09 UTC · re: Rhys Hardwick · lore

Re: git add / update-cache --add fails.

On Mon, Apr 25, 2005 at 10:52:05PM +0100, Rhys Hardwick wrote:
> I have tried rebooting, and looking at a few sources, and nothing
> has helped.  It's interesting noone else has had the same problem.
why would a reboot help?
Linus Torvalds· Apr 26, 2005, 00:47 UTC · re: Rhys Hardwick · lore

Re: git add / update-cache --add fails.

On Mon, 25 Apr 2005, Rhys Hardwick wrote:
Show 6 quoted lines
> 
> Just to clarify, the latest version of git to be merged with pasky is:
> 
> 4e03aae5feb2e3fd2f543796ca3d3e8aa86c02dc
> 
> I have tried rebooting
[ somebody has been using windows for too long ;]

Just do an "strace update-cache --add xxxxx", that often gives a clue. Also, "ltrace" is a wonderful tool at times.

update-cache will be unhappy if the file is unreadable, for example. But it will also be unhappy if it cannot create the sha1 hashed object file, which can happen if the permissions on the object directories are screwed up or similar.

I think these things should generally show up as a sore thumb in an strace.

		Linus
Rhys Hardwick· Apr 26, 2005, 06:26 UTC · re: Linus Torvalds · lore

Re: git add / update-cache --add fails.

That may be true! I changed to linux full time only about 8 months ago, but haven't looked back.

Ok strace gave me:
=====
rhys@metatron:~/repo/learning.repo$ strace update-cache --add w1d4p1.c
execve("/home/rhys/bin/update-cache", ["update-cache", "--add", "w1d4p1.c"], 
[/*
 37 vars */]) = 0
uname({sys="Linux", node="metatron", ...}) = 0
brk(0)                                  = 0x8050000
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
0
xb7fe9000
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or 
directory)
open("/etc/ld.so.preload", O_RDONLY)    = -1 ENOENT (No such file or 
directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=78204, ...}) = 0
old_mmap(NULL, 78204, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7fd5000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or 
directory)
open("/usr/lib/libz.so.1", O_RDONLY)    = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\200\27"..., 512) = 
512
fstat64(3, {st_mode=S_IFREG|0644, st_size=67468, ...}) = 0
old_mmap(NULL, 70528, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0xb7fc3000
old_mmap(0xb7fd4000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 
0x100
00) = 0xb7fd4000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or 
directory)
open("/usr/lib/i686/cmov/libssl.so.0.9.7", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\0\205\0"..., 512) = 
512
fstat64(3, {st_mode=S_IFREG|0644, st_size=198576, ...}) = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
0
xb7fc2000
old_mmap(NULL, 199344, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0xb7f91000
old_mmap(0xb7fbf000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 
0x2e
000) = 0xb7fbf000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or 
directory)
open("/lib/tls/libc.so.6", O_RDONLY)    = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0`Z\1\000"..., 512) = 
512
fstat64(3, {st_mode=S_IFREG|0644, st_size=1254468, ...}) = 0
old_mmap(NULL, 1264780, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0xb7e5c000
old_mmap(0xb7f86000, 36864, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 
0x12
9000) = 0xb7f86000
old_mmap(0xb7f8f000, 7308, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|
MAP_ANONY
MOUS, -1, 0) = 0xb7f8f000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or 
directory)
open("/usr/lib/i686/cmov/libcrypto.so.0.9.7", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0p\300\2"..., 512) = 
512
fstat64(3, {st_mode=S_IFREG|0644, st_size=1029672, ...}) = 0
old_mmap(NULL, 1043608, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0xb7d5d000
old_mmap(0xb7e47000, 73728, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 
0xea
000) = 0xb7e47000
old_mmap(0xb7e59000, 11416, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|
MAP_ANON
YMOUS, -1, 0) = 0xb7e59000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or 
directory)
open("/lib/tls/libdl.so.2", O_RDONLY)   = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\320\32"..., 512) = 
512
fstat64(3, {st_mode=S_IFREG|0644, st_size=9872, ...}) = 0
old_mmap(NULL, 8632, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0xb7d5a000
old_mmap(0xb7d5c000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 
0x200
0) = 0xb7d5c000
close(3)                                = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
0xb7d59000
set_thread_area({entry_number:-1 -> 6, base_addr:0xb7d592a0, limit:1048575, 
seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, 
seg_not_present:0, useable:1}) = 0
munmap(0xb7fd5000, 78204)               = 0
open(".git/index.lock", O_RDWR|O_CREAT|O_EXCL, 0600) = 3
access(".git/objects", X_OK)            = 0
open(".git/index", O_RDONLY)            = 4
fstat64(4, {st_mode=S_IFREG|0600, st_size=176, ...}) = 0
mmap2(NULL, 176, PROT_READ, MAP_PRIVATE, 4, 0) = 0xb7fe8000
close(4)                                = 0
brk(0)                                  = 0x8050000
brk(0x8071000)                          = 0x8071000
brk(0)                                  = 0x8071000
open("w1d4p1.c", O_RDONLY)              = -1 ENOENT (No such file or 
directory)
write(2, "fatal: ", 7fatal: )                  = 7
write(2, "Unable to add w1d4p1.c to databa"..., 34Unable to add w1d4p1.c to 
database) = 34
write(2, "\n", 1
)                       = 1
unlink(".git/index.lock")               = 0
exit_group(1)                           = ?
====
ltrace update-cache --add xxxx gave
====

rhys@metatron:~/repo/learning.repo$ ltrace update-cache --add w1d4p1.c __libc_start_main(0x8049680, 3, 0xbffff854, 0x804ad60, 0x804adc0 <unfinished ...> getenv("GIT_INDEX_FILE") = NULL snprintf(".git/index.lock", 4097, "%s.lock", ".git/index") = 15 open(".git/index.lock", 194, 0600) = 3 __cxa_atexit(0x8049660, 0, 0, 0xb7f8de80, 0xbffff7c8) = 0 __errno_location() = 0xb7d59280 getenv("SHA1_FILE_DIRECTORY") = NULL access(".git/objects", 1) = 0 getenv("GIT_INDEX_FILE") = NULL open(".git/index", 0, 026777021220) = 4 __fxstat(3, 4, 0xbffff710) = 0 __errno_location() = 0xb7d59280 mmap(0, 176, 1, 2, 4) = 0xb7fe8000 close(4) = 0 SHA1_Init(0xbffff660, 0xb7e67bc8, 0xb7fc2290, 0x804870e, 96) = 1 SHA1_Update(0xbffff660, 0xb7fe8000, 156, 0x804870e, 96) = 1 SHA1_Final(0xbffff640, 0xbffff660, 156, 0x804870e, 96) = 1 calloc(27, 4) = 0x8050008 open("w1d4p1.c", 0, 044653) = -1 __errno_location() = 0xb7d59280 fputs("fatal: ", 0xb7f86f60fatal: ) = 1 vfprintf(0xb7f86f60, "Unable to add %s to database", 0xbffff794Unable to add w1d4p1.c to database) = 34 fputc('\n', 0xb7f86f60 ) = 10 exit(1 <unfinished ...> unlink(".git/index.lock") = 0 +++ exited (status 1) +++

====

More information: this seems to be happening with all my local repositories. I can remove files from the cache, and commit fine, but not add files.

Rhys
On Tuesday 26 Apr 2005 01:47, Linus Torvalds wrote:
Herbert Xu· Apr 27, 2005, 02:35 UTC · re: Rhys Hardwick · lore

Re: git add / update-cache --add fails.

Rhys Hardwick <rhys@rhyshardwick.co.uk> wrote:
> 
> rhys@metatron:~/repo/learning.repo$ strace update-cache --add w1d4p1.c
...
> open("w1d4p1.c", O_RDONLY)              = -1 ENOENT (No such file or 
> directory)
The file that you're trying to add doesn't exist.
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Ed L Cashin· Apr 27, 2005, 16:48 UTC · re: Herbert Xu · lore

Re: git add / update-cache --add fails.

Herbert Xu <herbert@gondor.apana.org.au> writes:
Show 8 quoted lines
> Rhys Hardwick <rhys@rhyshardwick.co.uk> wrote:
>> 
>> rhys@metatron:~/repo/learning.repo$ strace update-cache --add w1d4p1.c
> ...
>> open("w1d4p1.c", O_RDONLY)              = -1 ENOENT (No such file or 
>> directory)
>
> The file that you're trying to add doesn't exist.
Maybe the user should be informed as soon as update-cache knows that?
update-cache.c: 11388582a830a6161d1c769aa8616bed6f593b8a
--- a/update-cache.c
+++ b/update-cache.c
@@ -98,6 +98,7 @@ static int add_file_to_cache(char *path)
 
 	fd = open(path, O_RDONLY);
 	if (fd < 0) {
+		fprintf(stderr, "update-cache Error: %s\n", strerror(errno));
 		if (errno == ENOENT) {
 			if (allow_remove)
 				return remove_file_from_cache(path);



By the way, I created that patch with "git diff" in my git-pasky
working directory.  Strangely, I had to redirect standard error to the
same place as standard output in order to get the filename in the diff
output.  I didn't check why the filename is on standard error,
though.
-- 
  Ed L Cashin <ecashin@coraid.com>
Petr Baudis· Apr 27, 2005, 17:30 UTC · re: Ed L Cashin · lore

Re: git add / update-cache --add fails.

Dear diary, on Wed, Apr 27, 2005 at 06:48:43PM CEST, I got a letter where Ed L Cashin <ecashin@coraid.com> told me that...

Show 13 quoted lines
> Herbert Xu <herbert@gondor.apana.org.au> writes:
> 
> > Rhys Hardwick <rhys@rhyshardwick.co.uk> wrote:
> >> 
> >> rhys@metatron:~/repo/learning.repo$ strace update-cache --add w1d4p1.c
> > ...
> >> open("w1d4p1.c", O_RDONLY)              = -1 ENOENT (No such file or 
> >> directory)
> >
> > The file that you're trying to add doesn't exist.
> 
> Maybe the user should be informed as soon as update-cache knows that?
> 
Show 11 quoted lines
> update-cache.c: 11388582a830a6161d1c769aa8616bed6f593b8a
> --- a/update-cache.c
> +++ b/update-cache.c
> @@ -98,6 +98,7 @@ static int add_file_to_cache(char *path)
>  
>  	fd = open(path, O_RDONLY);
>  	if (fd < 0) {
> +		fprintf(stderr, "update-cache Error: %s\n", strerror(errno));
>  		if (errno == ENOENT) {
>  			if (allow_remove)
>  				return remove_file_from_cache(path);
FWIW, I have this in my tree for some time already. :-)
Show 5 quoted lines
> By the way, I created that patch with "git diff" in my git-pasky
> working directory.  Strangely, I had to redirect standard error to the
> same place as standard output in order to get the filename in the diff
> output.  I didn't check why the filename is on standard error,
> though.

Interesting. Anyway, you are apparently using some quite antique git-pasky version.

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
Ed L Cashin· Apr 27, 2005, 17:38 UTC · re: Petr Baudis · lore

Re: git add / update-cache --add fails.

Petr Baudis <pasky@ucw.cz> writes:
...
>> +		fprintf(stderr, "update-cache Error: %s\n", strerror(errno));
...
> FWIW, I have this in my tree for some time already. :-)
OK, nice.
...
Show 9 quoted lines
>
>> By the way, I created that patch with "git diff" in my git-pasky
>> working directory.  Strangely, I had to redirect standard error to the
>> same place as standard output in order to get the filename in the diff
>> output.  I didn't check why the filename is on standard error,
>> though.
>
> Interesting. Anyway, you are apparently using some quite antique
> git-pasky version.
It wasn't on purpose!  :)

Thinking back, my "git pull" probably didn't merge correctly because it was too old. I'll just blow away the old one and start over.

-- 
  Ed L Cashin <ecashin@coraid.com>
Paul Jackson· Apr 28, 2005, 01:01 UTC · re: Petr Baudis · lore

Re: git add / update-cache --add fails.

Petr wrote:
>  	fd = open(path, O_RDONLY);
>  	if (fd < 0) {
> +		fprintf(stderr, "update-cache Error: %s\n", strerror(errno));

It's usually a good idea to indicate which system call you were attempting in such error messages, and if handy, the key argument. Just the errno might not mean much:

> +		fprintf(stderr, "update-cache open(%s) failed: %s\n", path, strerror(errno));
-- 
                  I won't rest till it's the best ...
                  Programmer, Linux Scalability
                  Paul Jackson <pj@engr.sgi.com> 1.650.933.1373, 1.925.600.0401
Petr Baudis· Apr 28, 2005, 01:05 UTC · re: Paul Jackson · lore

Re: git add / update-cache --add fails.

Dear diary, on Thu, Apr 28, 2005 at 03:01:43AM CEST, I got a letter where Paul Jackson <pj@sgi.com> told me that...

Show 10 quoted lines
> Petr wrote:
> >  	fd = open(path, O_RDONLY);
> >  	if (fd < 0) {
> > +		fprintf(stderr, "update-cache Error: %s\n", strerror(errno));
> 
> It's usually a good idea to indicate which system call you were
> attempting in such error messages, and if handy, the key argument.
> Just the errno might not mean much:
> 
> > +		fprintf(stderr, "update-cache open(%s) failed: %s\n", path, strerror(errno));

Sorry for being unclear, I meant that I did an analogous change in my tree before; it is actually a little different:

	if (errno == ENOENT) {
		if (allow_remove)
			return remove_file_from_cache(path);
	}
	return error("open(\"%s\"): %s", path, strerror(errno));
-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
Paul Jackson· Apr 28, 2005, 01:20 UTC · re: Petr Baudis · lore

Re: git add / update-cache --add fails.

> I meant that I did an analogous change in my
ah - fine - sorry for the noise
-- 
                  I won't rest till it's the best ...
                  Programmer, Linux Scalability
                  Paul Jackson <pj@engr.sgi.com> 1.650.933.1373, 1.925.600.0401

← back to recent threads