Re: read_branches_file ()

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <git@...>
Date: Friday, February 8, 2008 - 12:03 pm

On Fri, 8 Feb 2008 16:50:08 +0100, "H.Merijn Brand" <h.m.brand@xs4all.nl>
wrote:


Something like this seems so `fix' this specific problem.
Feel free to take another approach, t5405 now passes

--8<--- remote.c.diff
--- remote.c.org        2008-01-27 09:04:18 +0100
+++ remote.c    2008-02-08 17:01:09 +0100
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "remote.h"
 #include "refs.h"
+#include <sys/stat.h>

 static struct remote **remotes;
 static int allocated_remotes;
@@ -173,11 +174,15 @@ static void read_branches_file(struct re
        char *frag;
        char *branch;
        int n = slash ? slash - remote->name : 1000;
-       FILE *f = fopen(git_path("branches/%.*s", n, remote->name), "r");
+       char *gp = git_path ("branches/%.*s", n, remote->name);
+       struct stat st_buf;
+       FILE *f;
        char *s, *p;
        int len;

-       if (!f)
+       if (stat (gp, &st_buf) || S_ISDIR (st_buf.st_mode))
+               return;
+       if (!(f = fopen(gp, "r")))
                return;
        s = fgets(buffer, BUF_SIZE, f);
        fclose(f);
-->8---


-- 
H.Merijn Brand         Amsterdam Perl Mongers (http://amsterdam.pm.org/)
using & porting perl 5.6.2, 5.8.x, 5.10.x  on HP-UX 10.20, 11.00, 11.11,
& 11.23, SuSE 10.1 & 10.2, AIX 5.2, and Cygwin.       http://qa.perl.org
http://mirrors.develooper.com/hpux/            http://www.test-smoke.org
                        http://www.goldmark.org/jeff/stupid-disclaimers/
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
read_branches_file (), H.Merijn Brand, (Fri Feb 8, 11:50 am)
Re: read_branches_file (), Daniel Barkalow, (Fri Feb 8, 1:18 pm)
Re: read_branches_file (), H.Merijn Brand, (Fri Feb 8, 12:03 pm)
Re: read_branches_file (), Andreas Ericsson, (Mon Feb 11, 6:00 am)
Re: read_branches_file (), H.Merijn Brand, (Mon Feb 11, 6:17 am)
Re: read_branches_file (), Johannes Schindelin, (Fri Feb 8, 12:22 pm)
Re: read_branches_file (), H.Merijn Brand, (Fri Feb 8, 12:49 pm)