git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] git_odb_open ckeck for valid path to database

From
Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Date
Nov 9, 2009, 19:16 UTC
Message-ID
<4AF86A7F.1010500@ramsay1.demon.co.uk>
In-Reply-To
<1257510729-6803-1-git-send-email-kde@mosehansen.dk>
Esben Mose Hansen wrote:
Show 12 quoted lines
> diff --git a/src/odb.c b/src/odb.c
> index 6d646a4..89d6d03 100644
> --- a/src/odb.c
> +++ b/src/odb.c
> @@ -30,6 +30,10 @@
>  #include "hash.h"
>  #include "odb.h"
>  
> +#include <sys/types.h>
> +#include <sys/stat.h>
> +#include <unistd.h>
> +

None of these #includes should be necessary (they are not for me). Also, "#include <unistd.h>" breaks on windows ;-)

Show 8 quoted lines
>  #define GIT_PACK_NAME_MAX (5 + 40 + 1)
>  struct git_pack {
>  	git_odb *db;
> @@ -1023,6 +1027,15 @@ int git_odb_open(git_odb **out, const char *objects_dir)
>  		free(db);
>  		return GIT_ERROR;
>  	}
> +	struct stat objects_dir_stat;

This should be declared at the head of the function (or generally at the start of a block/scope); ie we don't use this C99 facility. This breaks MSVC, which does not understand C99.

Show 5 quoted lines
> +	if (stat(db->objects_dir, &objects_dir_stat)) {
> +		free(db);
> +		return GIT_EOSERR;
> +	}
> +	if (!S_ISDIR(objects_dir_stat.st_mode)) {

This breaks on MSVC, since the MS headers do not define S_ISDIR. It's not difficult to add; it's on my TODO list. (Andreas, I can add this later if you like)

However, I suspect it may be useful to add an gitfo_is_directory() function, or something like it. Maybe. Andreas?

Thank you for the patch.

(I think Andreas would prefer to see libgit2 somewhere in the subject, perhaps like [LIBGIT2 PATCH], otherwise he may miss you email)

ATB, Ramsay Jones

Previous: Esben Mose HansenNext: Esben Mose Hansen
Message 2 of 5 in “git_odb_open ckeck for valid path to database”
  1. git_odb_open ckeck for valid path to databaseEsben Mose Hansen, Nov 6, 2009
  2. Ramsay JonesNov 9, 2009
  3. Esben Mose HansenNov 10, 2009
  4. Esben Mose HansenNov 30, 2009
  5. Ramsay JonesDec 3, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.