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

From: Ed L Cashin <[email-masked]>
Date: Wed, 27 Apr 2005 12:48:43 -0400

Herbert Xu <[email-masked]> writes:

> Rhys Hardwick <[email-masked]> 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 <[email-masked]>