* Re: [PATCH v2 11/13] Allow helpers to request the path to the .git directory
From: Daniel Barkalow @ 2009-11-04 23:25 UTC (permalink / raw)
To: Sverre Rabbelier; +Cc: Git List, Johannes Schindelin, Johan Herland
In-Reply-To: <fabb9a1e0911041518h9e3d07dneba3056848e98f3e@mail.gmail.com>
On Thu, 5 Nov 2009, Sverre Rabbelier wrote:
> Heya,
>
> On Thu, Nov 5, 2009 at 00:17, Daniel Barkalow <barkalow@iabervon.org> wrote:
> > Well, gfi is used with different native systems, each of which will
> > presumably put it somewhere different.
>
> Right, but I meant for git itself :). I assume that you meant that
> 'gitdir' (or 'infodir' , whatever) should return the same path,
> whatever we decide on?q
Yeah. I think the base that git uses wasn't decided on, although I may
have missed that part of the thread. In any case, I do think it should be
the directory passed to the helper.
-Daniel
*This .sig left intentionally blank*
^ permalink raw reply
* [PATCH] MSVC: Windows-native implementation for subset of Pthreads API
From: Andrzej K. Haczewski @ 2009-11-04 23:47 UTC (permalink / raw)
To: git; +Cc: Nicolas Pitre, Johannes Sixt
In-Reply-To: <16cee31f0911041316n20fc9f12s6595dadc813d8f46@mail.gmail.com>
This patch implements native to Windows subset of pthreads API used by Git.
It allows to remove Pthreads for Win32 dependency for msysgit and cygwin.
The patch modifies Makefile only for MSVC (that's the environment I'm
capable of testing on), so it requires further corrections to compile
with MinGW or Cygwin.
Signed-off-by: Andrzej K. Haczewski <ahaczewski@gmail.com>
---
Makefile | 4 +-
builtin-pack-objects.c | 34 ++++++++++--
compat/mingw.c | 2 +-
compat/mingw.h | 5 ++
compat/win32/pthread.h | 132 ++++++++++++++++++++++++++++++++++++++++++++++++
git-compat-util.h | 10 ++++
preload-index.c | 4 +-
7 files changed, 180 insertions(+), 11 deletions(-)
create mode 100644 compat/win32/pthread.h
diff --git a/Makefile b/Makefile
index 94d44b0..0146ac7 100644
--- a/Makefile
+++ b/Makefile
@@ -975,7 +975,7 @@ ifdef MSVC
OBJECT_CREATION_USES_RENAMES = UnfortunatelyNeedsTo
NO_REGEX = YesPlease
NO_CURL = YesPlease
- NO_PTHREADS = YesPlease
+ THREADED_DELTA_SEARCH = YesPlease
BLK_SHA1 = YesPlease
CC = compat/vcbuild/scripts/clink.pl
@@ -983,7 +983,7 @@ ifdef MSVC
CFLAGS =
BASIC_CFLAGS = -nologo -I. -I../zlib -Icompat/vcbuild -Icompat/vcbuild/include -DWIN32 -D_CONSOLE -DHAVE_STRING_H -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE
COMPAT_OBJS = compat/msvc.o compat/fnmatch/fnmatch.o compat/winansi.o
- COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DNOGDI -DHAVE_STRING_H -DHAVE_ALLOCA_H -Icompat -Icompat/fnmatch -Icompat/regex -Icompat/fnmatch -DSTRIP_EXTENSION=\".exe\"
+ COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DNOGDI -DHAVE_STRING_H -DHAVE_ALLOCA_H -Icompat -Icompat/fnmatch -Icompat/regex -Icompat/fnmatch -Icompat/win32 -DSTRIP_EXTENSION=\".exe\"
BASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -SUBSYSTEM:CONSOLE -NODEFAULTLIB:MSVCRT.lib
EXTLIBS = advapi32.lib shell32.lib wininet.lib ws2_32.lib
lib =
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index 02f9246..e897b16 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -1255,15 +1255,15 @@ static int delta_cacheable(unsigned long src_size, unsigned long trg_size,
#ifdef THREADED_DELTA_SEARCH
-static pthread_mutex_t read_mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t read_mutex;
#define read_lock() pthread_mutex_lock(&read_mutex)
#define read_unlock() pthread_mutex_unlock(&read_mutex)
-static pthread_mutex_t cache_mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t cache_mutex;
#define cache_lock() pthread_mutex_lock(&cache_mutex)
#define cache_unlock() pthread_mutex_unlock(&cache_mutex)
-static pthread_mutex_t progress_mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t progress_mutex;
#define progress_lock() pthread_mutex_lock(&progress_mutex)
#define progress_unlock() pthread_mutex_unlock(&progress_mutex)
@@ -1590,9 +1590,28 @@ struct thread_params {
unsigned *processed;
};
-static pthread_cond_t progress_cond = PTHREAD_COND_INITIALIZER;
+static pthread_cond_t progress_cond;
-static void *threaded_find_deltas(void *arg)
+/*
+ * Mutex and conditional variable can't be statically-initialized on Windows.
+ */
+static void init_threaded_search()
+{
+ pthread_mutex_init(&read_mutex);
+ pthread_mutex_init(&cache_mutex);
+ pthread_mutex_init(&progress_mutex);
+ pthread_cond_init(&progress_cond, NULL);
+}
+
+static void cleanup_threaded_search()
+{
+ pthread_cond_destroy(&progress_cond);
+ pthread_mutex_destroy(&read_mutex);
+ pthread_mutex_destroy(&cache_mutex);
+ pthread_mutex_destroy(&progress_mutex);
+}
+
+static THREAD_RET_TYPE threaded_find_deltas(void *arg)
{
struct thread_params *me = arg;
@@ -1620,7 +1639,7 @@ static void *threaded_find_deltas(void *arg)
pthread_mutex_unlock(&me->mutex);
}
/* leave ->working 1 so that this doesn't get more work assigned */
- return NULL;
+ return 0;
}
static void ll_find_deltas(struct object_entry **list, unsigned list_size,
@@ -1638,6 +1657,8 @@ static void ll_find_deltas(struct object_entry **list, unsigned list_size,
delta_search_threads);
p = xcalloc(delta_search_threads, sizeof(*p));
+ init_threaded_search();
+
/* Partition the work amongst work threads. */
for (i = 0; i < delta_search_threads; i++) {
unsigned sub_size = list_size / (delta_search_threads - i);
@@ -1745,6 +1766,7 @@ static void ll_find_deltas(struct object_entry **list, unsigned list_size,
active_threads--;
}
}
+ cleanup_threaded_search();
free(p);
}
diff --git a/compat/mingw.c b/compat/mingw.c
index 6b5b5b2..f2e9f02 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -5,7 +5,7 @@
#include <shellapi.h>
-static int err_win_to_posix(DWORD winerr)
+int err_win_to_posix(DWORD winerr)
{
int error = ENOSYS;
switch(winerr) {
diff --git a/compat/mingw.h b/compat/mingw.h
index 6907345..7e25fb5 100644
--- a/compat/mingw.h
+++ b/compat/mingw.h
@@ -294,3 +294,8 @@ struct mingw_dirent
#define readdir(x) mingw_readdir(x)
struct dirent *mingw_readdir(DIR *dir);
#endif // !NO_MINGW_REPLACE_READDIR
+
+/*
+ * Used by Pthread API implementation for Windows
+ */
+extern int err_win_to_posix(DWORD winerr);
diff --git a/compat/win32/pthread.h b/compat/win32/pthread.h
new file mode 100644
index 0000000..0e43714
--- /dev/null
+++ b/compat/win32/pthread.h
@@ -0,0 +1,132 @@
+/*
+ * Header used to adapt pthread-based POSIX code to Windows API threads.
+ *
+ * Copyright (C) 2009 Andrzej K. Haczewski <ahaczewski@gmail.com>
+ */
+
+#ifndef PTHREAD_H
+#define PTHREAD_H
+
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif
+
+#include <windows.h>
+
+/*
+ * Implement simple condition variable for Windows threads, based on ACE
+ * implementation.
+ *
+ * See original implementation: http://bit.ly/1vkDjo
+ * ACE homepage: http://www.cse.wustl.edu/~schmidt/ACE.html
+ * See also: http://www.cse.wustl.edu/~schmidt/win32-cv-1.html
+ */
+typedef struct {
+ LONG waiters;
+ CRITICAL_SECTION waiters_lock;
+ HANDLE sema;
+} pthread_cond_t;
+
+static inline int pthread_cond_init(pthread_cond_t *cond, const void *unused)
+{
+ cond->waiters = 0;
+
+ InitializeCriticalSection(&cond->waiters_lock);
+
+ cond->sema = CreateSemaphore(NULL, 0, LONG_MAX, NULL);
+ if (!cond->sema)
+ return 0; /* POSIX do not allow pthread_cond_init to fail */
+ return 0;
+}
+
+static inline int pthread_cond_destroy(pthread_cond_t *cond)
+{
+ CloseHandle(cond->sema);
+ cond->sema = NULL;
+
+ DeleteCriticalSection(&cond->waiters_lock);
+
+ return 0;
+}
+
+static inline int pthread_cond_wait(pthread_cond_t *cond, CRITICAL_SECTION *mutex)
+{
+ /* serialize access to waiters count */
+ EnterCriticalSection(&cond->waiters_lock);
+ ++cond->waiters;
+ LeaveCriticalSection(&cond->waiters_lock);
+
+ /*
+ * Unlock external mutex and wait for signal.
+ * NOTE: we've held mutex locked long enough to increment
+ * waiters count above, so there's no problem with
+ * leaving mutex unlocked before we wait on semaphore.
+ */
+ LeaveCriticalSection(mutex);
+
+ /* let's wait */
+ WaitForSingleObject(cond->sema, INFINITE))
+
+ /* we're done waiting, so make sure we decrease waiters count */
+ EnterCriticalSection(&cond->waiters_lock);
+ --cond->waiters;
+ LeaveCriticalSection(&cond->waiters_lock);
+
+ /* lock external mutex again */
+ EnterCriticalSection(mutex);
+
+ return 0;
+}
+
+static inline int pthread_cond_signal(pthread_cond_t *cond)
+{
+ int have_waiters;
+
+ /* serialize access to waiters count */
+ EnterCriticalSection(&cond->waiters_lock);
+ have_waiters = cond->waiters > 0;
+ LeaveCriticalSection(&cond->waiters_lock);
+
+ /*
+ * Signal only when there are waiters
+ */
+ if (have_waiters)
+ return ReleaseSemaphore(cond->sema, 1, NULL) ?
+ 0 : err_win_to_posix(GetLastError();
+ else
+ return 0;
+}
+
+#define pthread_t HANDLE
+#define pthread_mutex_t CRITICAL_SECTION
+
+#define pthread_mutex_init(a,b) InitializeCriticalSection((a))
+#define pthread_mutex_destroy(a) DeleteCriticalSection((a))
+#define pthread_mutex_lock EnterCriticalSection
+#define pthread_mutex_unlock LeaveCriticalSection
+
+static inline int pthread_create(pthread_t *thread, const void *unused,
+ DWORD (__stdcall *start_routine)(LPVOID), void *arg)
+{
+ *thread = CreateThread(NULL, 0, start_routine, arg, 0, NULL);
+
+ if (!*thread)
+ return err_win_to_posix(GetLastError());
+ else
+ return 0;
+}
+
+static inline int pthread_join(pthread_t thread, void **unused)
+{
+ DWORD result = WaitForSingleObject(t, INFINITE);
+ switch (result) {
+ case WAIT_OBJECT_0:
+ return 0;
+ case WAIT_ABANDONED:
+ return EINVAL;
+ default:
+ return err_win_to_posix(GetLastError());
+ }
+}
+
+#endif /* PTHREAD_H */
diff --git a/git-compat-util.h b/git-compat-util.h
index ef60803..4311117 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -464,4 +464,14 @@ void git_qsort(void *base, size_t nmemb, size_t size,
*/
int unlink_or_warn(const char *path);
+/*
+ * Define type of thread function return type to distinguish
+ * Windows and POSIX.
+ */
+#ifndef _WIN32
+# define THREAD_RET_TYPE void *
+#else
+# define THREAD_RET_TYPE DWORD __stdcall
+#endif
+
#endif
diff --git a/preload-index.c b/preload-index.c
index 9289933..41b11a3 100644
--- a/preload-index.c
+++ b/preload-index.c
@@ -28,7 +28,7 @@ struct thread_data {
int offset, nr;
};
-static void *preload_thread(void *_data)
+static THREAD_RET_TYPE preload_thread(void* _data)
{
int nr;
struct thread_data *p = _data;
@@ -59,7 +59,7 @@ static void *preload_thread(void *_data)
continue;
ce_mark_uptodate(ce);
} while (--nr > 0);
- return NULL;
+ return 0;
}
static void preload_index(struct index_state *index, const char **pathspec)
--
1.6.5.2
^ permalink raw reply related
* Re: gitweb - bare repos integration - owner info in description file
From: Eugene Sajine @ 2009-11-04 23:48 UTC (permalink / raw)
To: Petr Baudis; +Cc: Johannes Schindelin, Jakub Narebski, git
In-Reply-To: <20091103202211.GA17748@machine.or.cz>
>
> I think you got confused by perhaps unclear gitweb/README wording. There
> is a single property file, it's called "config" and _that's_ where you
> set the gitweb configuration variables, in its gitweb section.
>
> Try running
>
> git config gitweb.owner "Eugene Sajine"
> git config gitweb.description tralala
>
> within the repository (and optionally marveling at the config file again
> afterwards). Is this what you are after?
>
> Perhaps the gitweb/README file doesn't make it clear enough that these
> are gitweb configuration variables, not stand-alone files, and maybe it
> should provide an example on how to set them. I'm sure that if you will
> submit a patch for gitweb/README clarifying this, it will be welcome.
>
> Kind regards,
>
> --
> Petr "Pasky" Baudis
> A lot of people have my books on their bookshelves.
> That's the problem, they need to read them. -- Don Knuth
>
Thank you for the advice, but I found a better solution than gitweb - cgit!
I should say cgit is an amazing tool - nice design and graphic
appearance, easy to set up and very easy to maintain, full of features
and fits our environment nicely. Many thanks to the Author (Lars
Hjemli) and all contributors!
Eugene
^ permalink raw reply
* Re: thoughts on setting core.logAllRefUpdates default true for bare repos
From: Nicolas Sebrecht @ 2009-11-04 23:52 UTC (permalink / raw)
To: Sitaram Chamarty; +Cc: Johannes Schindelin, git, Nicolas Sebrecht
In-Reply-To: <2e24e5b90911040841l7741787et48fabb8c8066e946@mail.gmail.com>
The 04/11/09, Sitaram Chamarty wrote:
> But if you are able to do "gc" manually on any repo you can also do
> "reflog expire" before "gc" can you not? Please correct me if I'm
> wrong.
"If we are able to do 'gc' on any repo"... But a lot of users aren't
able to it because they aren't the admin.
Or did you mean if "non-admin users could" ?
--
Nicolas Sebrecht
^ permalink raw reply
* [PATCH] MSVC: Windows-native implementation for subset of Pthreads API
From: Andrzej K. Haczewski @ 2009-11-04 23:57 UTC (permalink / raw)
Cc: git, Nicolas Pitre, Johannes Sixt
In-Reply-To: <4AF21283.3080407@gmail.com>
This patch implements native to Windows subset of pthreads API used by Git.
It allows to remove Pthreads for Win32 dependency for msysgit and cygwin.
The patch modifies Makefile only for MSVC (that's the environment I'm
capable of testing on), so it requires further corrections to compile
with MinGW or Cygwin.
Signed-off-by: Andrzej K. Haczewski <ahaczewski@gmail.com>
---
Ignore previous patch, there was a compile error for POSIX platform
(pthread_mutex_init takes 2 arguments, MSVC doesn't complain if
1 argument is supplied to a macro call, but on POSIX it's function
call).
I haven't integrated Nicolas patch.
Makefile | 4 +-
builtin-pack-objects.c | 34 ++++++++++--
compat/mingw.c | 2 +-
compat/mingw.h | 5 ++
compat/win32/pthread.h | 132 ++++++++++++++++++++++++++++++++++++++++++++++++
git-compat-util.h | 10 ++++
preload-index.c | 4 +-
7 files changed, 180 insertions(+), 11 deletions(-)
create mode 100644 compat/win32/pthread.h
diff --git a/Makefile b/Makefile
index 94d44b0..0146ac7 100644
--- a/Makefile
+++ b/Makefile
@@ -975,7 +975,7 @@ ifdef MSVC
OBJECT_CREATION_USES_RENAMES = UnfortunatelyNeedsTo
NO_REGEX = YesPlease
NO_CURL = YesPlease
- NO_PTHREADS = YesPlease
+ THREADED_DELTA_SEARCH = YesPlease
BLK_SHA1 = YesPlease
CC = compat/vcbuild/scripts/clink.pl
@@ -983,7 +983,7 @@ ifdef MSVC
CFLAGS =
BASIC_CFLAGS = -nologo -I. -I../zlib -Icompat/vcbuild -Icompat/vcbuild/include -DWIN32 -D_CONSOLE -DHAVE_STRING_H -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE
COMPAT_OBJS = compat/msvc.o compat/fnmatch/fnmatch.o compat/winansi.o
- COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DNOGDI -DHAVE_STRING_H -DHAVE_ALLOCA_H -Icompat -Icompat/fnmatch -Icompat/regex -Icompat/fnmatch -DSTRIP_EXTENSION=\".exe\"
+ COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DNOGDI -DHAVE_STRING_H -DHAVE_ALLOCA_H -Icompat -Icompat/fnmatch -Icompat/regex -Icompat/fnmatch -Icompat/win32 -DSTRIP_EXTENSION=\".exe\"
BASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -SUBSYSTEM:CONSOLE -NODEFAULTLIB:MSVCRT.lib
EXTLIBS = advapi32.lib shell32.lib wininet.lib ws2_32.lib
lib =
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index 02f9246..e897b16 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -1255,15 +1255,15 @@ static int delta_cacheable(unsigned long src_size, unsigned long trg_size,
#ifdef THREADED_DELTA_SEARCH
-static pthread_mutex_t read_mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t read_mutex;
#define read_lock() pthread_mutex_lock(&read_mutex)
#define read_unlock() pthread_mutex_unlock(&read_mutex)
-static pthread_mutex_t cache_mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t cache_mutex;
#define cache_lock() pthread_mutex_lock(&cache_mutex)
#define cache_unlock() pthread_mutex_unlock(&cache_mutex)
-static pthread_mutex_t progress_mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t progress_mutex;
#define progress_lock() pthread_mutex_lock(&progress_mutex)
#define progress_unlock() pthread_mutex_unlock(&progress_mutex)
@@ -1590,9 +1590,28 @@ struct thread_params {
unsigned *processed;
};
-static pthread_cond_t progress_cond = PTHREAD_COND_INITIALIZER;
+static pthread_cond_t progress_cond;
-static void *threaded_find_deltas(void *arg)
+/*
+ * Mutex and conditional variable can't be statically-initialized on Windows.
+ */
+static void init_threaded_search()
+{
+ pthread_mutex_init(&read_mutex, NULL);
+ pthread_mutex_init(&cache_mutex, NULL);
+ pthread_mutex_init(&progress_mutex, NULL);
+ pthread_cond_init(&progress_cond, NULL);
+}
+
+static void cleanup_threaded_search()
+{
+ pthread_cond_destroy(&progress_cond);
+ pthread_mutex_destroy(&read_mutex);
+ pthread_mutex_destroy(&cache_mutex);
+ pthread_mutex_destroy(&progress_mutex);
+}
+
+static THREAD_RET_TYPE threaded_find_deltas(void *arg)
{
struct thread_params *me = arg;
@@ -1620,7 +1639,7 @@ static void *threaded_find_deltas(void *arg)
pthread_mutex_unlock(&me->mutex);
}
/* leave ->working 1 so that this doesn't get more work assigned */
- return NULL;
+ return 0;
}
static void ll_find_deltas(struct object_entry **list, unsigned list_size,
@@ -1638,6 +1657,8 @@ static void ll_find_deltas(struct object_entry **list, unsigned list_size,
delta_search_threads);
p = xcalloc(delta_search_threads, sizeof(*p));
+ init_threaded_search();
+
/* Partition the work amongst work threads. */
for (i = 0; i < delta_search_threads; i++) {
unsigned sub_size = list_size / (delta_search_threads - i);
@@ -1745,6 +1766,7 @@ static void ll_find_deltas(struct object_entry **list, unsigned list_size,
active_threads--;
}
}
+ cleanup_threaded_search();
free(p);
}
diff --git a/compat/mingw.c b/compat/mingw.c
index 6b5b5b2..f2e9f02 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -5,7 +5,7 @@
#include <shellapi.h>
-static int err_win_to_posix(DWORD winerr)
+int err_win_to_posix(DWORD winerr)
{
int error = ENOSYS;
switch(winerr) {
diff --git a/compat/mingw.h b/compat/mingw.h
index 6907345..7e25fb5 100644
--- a/compat/mingw.h
+++ b/compat/mingw.h
@@ -294,3 +294,8 @@ struct mingw_dirent
#define readdir(x) mingw_readdir(x)
struct dirent *mingw_readdir(DIR *dir);
#endif // !NO_MINGW_REPLACE_READDIR
+
+/*
+ * Used by Pthread API implementation for Windows
+ */
+extern int err_win_to_posix(DWORD winerr);
diff --git a/compat/win32/pthread.h b/compat/win32/pthread.h
new file mode 100644
index 0000000..0e43714
--- /dev/null
+++ b/compat/win32/pthread.h
@@ -0,0 +1,132 @@
+/*
+ * Header used to adapt pthread-based POSIX code to Windows API threads.
+ *
+ * Copyright (C) 2009 Andrzej K. Haczewski <ahaczewski@gmail.com>
+ */
+
+#ifndef PTHREAD_H
+#define PTHREAD_H
+
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif
+
+#include <windows.h>
+
+/*
+ * Implement simple condition variable for Windows threads, based on ACE
+ * implementation.
+ *
+ * See original implementation: http://bit.ly/1vkDjo
+ * ACE homepage: http://www.cse.wustl.edu/~schmidt/ACE.html
+ * See also: http://www.cse.wustl.edu/~schmidt/win32-cv-1.html
+ */
+typedef struct {
+ LONG waiters;
+ CRITICAL_SECTION waiters_lock;
+ HANDLE sema;
+} pthread_cond_t;
+
+static inline int pthread_cond_init(pthread_cond_t *cond, const void *unused)
+{
+ cond->waiters = 0;
+
+ InitializeCriticalSection(&cond->waiters_lock);
+
+ cond->sema = CreateSemaphore(NULL, 0, LONG_MAX, NULL);
+ if (!cond->sema)
+ return 0; /* POSIX do not allow pthread_cond_init to fail */
+ return 0;
+}
+
+static inline int pthread_cond_destroy(pthread_cond_t *cond)
+{
+ CloseHandle(cond->sema);
+ cond->sema = NULL;
+
+ DeleteCriticalSection(&cond->waiters_lock);
+
+ return 0;
+}
+
+static inline int pthread_cond_wait(pthread_cond_t *cond, CRITICAL_SECTION *mutex)
+{
+ /* serialize access to waiters count */
+ EnterCriticalSection(&cond->waiters_lock);
+ ++cond->waiters;
+ LeaveCriticalSection(&cond->waiters_lock);
+
+ /*
+ * Unlock external mutex and wait for signal.
+ * NOTE: we've held mutex locked long enough to increment
+ * waiters count above, so there's no problem with
+ * leaving mutex unlocked before we wait on semaphore.
+ */
+ LeaveCriticalSection(mutex);
+
+ /* let's wait */
+ WaitForSingleObject(cond->sema, INFINITE))
+
+ /* we're done waiting, so make sure we decrease waiters count */
+ EnterCriticalSection(&cond->waiters_lock);
+ --cond->waiters;
+ LeaveCriticalSection(&cond->waiters_lock);
+
+ /* lock external mutex again */
+ EnterCriticalSection(mutex);
+
+ return 0;
+}
+
+static inline int pthread_cond_signal(pthread_cond_t *cond)
+{
+ int have_waiters;
+
+ /* serialize access to waiters count */
+ EnterCriticalSection(&cond->waiters_lock);
+ have_waiters = cond->waiters > 0;
+ LeaveCriticalSection(&cond->waiters_lock);
+
+ /*
+ * Signal only when there are waiters
+ */
+ if (have_waiters)
+ return ReleaseSemaphore(cond->sema, 1, NULL) ?
+ 0 : err_win_to_posix(GetLastError();
+ else
+ return 0;
+}
+
+#define pthread_t HANDLE
+#define pthread_mutex_t CRITICAL_SECTION
+
+#define pthread_mutex_init(a,b) InitializeCriticalSection((a))
+#define pthread_mutex_destroy(a) DeleteCriticalSection((a))
+#define pthread_mutex_lock EnterCriticalSection
+#define pthread_mutex_unlock LeaveCriticalSection
+
+static inline int pthread_create(pthread_t *thread, const void *unused,
+ DWORD (__stdcall *start_routine)(LPVOID), void *arg)
+{
+ *thread = CreateThread(NULL, 0, start_routine, arg, 0, NULL);
+
+ if (!*thread)
+ return err_win_to_posix(GetLastError());
+ else
+ return 0;
+}
+
+static inline int pthread_join(pthread_t thread, void **unused)
+{
+ DWORD result = WaitForSingleObject(t, INFINITE);
+ switch (result) {
+ case WAIT_OBJECT_0:
+ return 0;
+ case WAIT_ABANDONED:
+ return EINVAL;
+ default:
+ return err_win_to_posix(GetLastError());
+ }
+}
+
+#endif /* PTHREAD_H */
diff --git a/git-compat-util.h b/git-compat-util.h
index ef60803..4311117 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -464,4 +464,14 @@ void git_qsort(void *base, size_t nmemb, size_t size,
*/
int unlink_or_warn(const char *path);
+/*
+ * Define type of thread function return type to distinguish
+ * Windows and POSIX.
+ */
+#ifndef _WIN32
+# define THREAD_RET_TYPE void *
+#else
+# define THREAD_RET_TYPE DWORD __stdcall
+#endif
+
#endif
diff --git a/preload-index.c b/preload-index.c
index 9289933..41b11a3 100644
--- a/preload-index.c
+++ b/preload-index.c
@@ -28,7 +28,7 @@ struct thread_data {
int offset, nr;
};
-static void *preload_thread(void *_data)
+static THREAD_RET_TYPE preload_thread(void* _data)
{
int nr;
struct thread_data *p = _data;
@@ -59,7 +59,7 @@ static void *preload_thread(void *_data)
continue;
ce_mark_uptodate(ce);
} while (--nr > 0);
- return NULL;
+ return 0;
}
static void preload_index(struct index_state *index, const char **pathspec)
-- 1.6.5.2
^ permalink raw reply related
* Re: [PATCH] MSVC: Windows-native implementation for subset of Pthreads API
From: Junio C Hamano @ 2009-11-04 23:58 UTC (permalink / raw)
To: Nicolas Pitre; +Cc: Andrzej K. Haczewski, git, Johannes Sixt
In-Reply-To: <alpine.LFD.2.00.0911041247250.10340@xanadu.home>
Nicolas Pitre <nico@fluxnic.net> writes:
> On Wed, 4 Nov 2009, Andrzej K. Haczewski wrote:
>
>> + NO_STATIC_PTHREADS_INIT = YesPlease
>
> Let's not go that route please. If Windows can't get away without
> runtime initializations then let's use them on all platforms. There is
> no gain in exploding the code path combinations here wrt testing
> coverage.
Hear hear.
^ permalink raw reply
* Re: thoughts on setting core.logAllRefUpdates default true for bare repos
From: Sverre Rabbelier @ 2009-11-04 23:59 UTC (permalink / raw)
To: Nicolas Sebrecht; +Cc: Sitaram Chamarty, Johannes Schindelin, git
In-Reply-To: <20091104235241.GA12984@vidovic>
Heya,
On Thu, Nov 5, 2009 at 00:52, Nicolas Sebrecht <nicolas.s.dev@gmx.fr> wrote:
> Or did you mean if "non-admin users could" ?
We're talking about the case wherein a confidential object is pruned,
regardless of whether it is a non-admin or admin user doing the
pruning, they should be able to 'reflog expire' if they can 'git gc'.
--
Cheers,
Sverre Rabbelier
^ permalink raw reply
* Re: [PATCH v2 11/13] Allow helpers to request the path to the .git directory
From: Junio C Hamano @ 2009-11-05 0:04 UTC (permalink / raw)
To: Sverre Rabbelier
Cc: Daniel Barkalow, Git List, Johannes Schindelin, Johan Herland
In-Reply-To: <fabb9a1e0911041406tce0956ai2ad3fe6cfbdc546d@mail.gmail.com>
Sverre Rabbelier <srabbelier@gmail.com> writes:
>> In any case, I think it would be good to have
>> something like that, but I think maybe we should tell it where it can put
>> its status files, rather than telling it where the .git dir is.
>
> Yes, that would probably be a good idea, .git/info/remote-<vcs>/<alias> perhaps?
What do you mean by <alias> here? Is it the <alias> in
[remote "alias"]
url = hg::http://some.where/repo/sito/ry.hg
IOW, can a user ever use the foreign interface directly from the command
line, without ever defining such entries in .git/config, perhaps using
"git remote"?
^ permalink raw reply
* Re: [PATCH v2 11/13] Allow helpers to request the path to the .git directory
From: Sverre Rabbelier @ 2009-11-05 0:15 UTC (permalink / raw)
To: Junio C Hamano
Cc: Daniel Barkalow, Git List, Johannes Schindelin, Johan Herland
In-Reply-To: <7vd43xg7lf.fsf@alter.siamese.dyndns.org>
Heya,
On Thu, Nov 5, 2009 at 01:04, Junio C Hamano <gitster@pobox.com> wrote:
> What do you mean by <alias> here? Is it the <alias> in
>
> [remote "alias"]
> url = hg::http://some.where/repo/sito/ry.hg
Yes, that one.
> IOW, can a user ever use the foreign interface directly from the command
> line, without ever defining such entries in .git/config, perhaps using
> "git remote"?
No, my primary use case for remote helpers is currently 'git clone
hg::https://soc.googlecode.com/hg/', and to have 'git fetch origin'
Just Work (tm) from that clone. My secondary use case though, is to
support 'git fetch hg:: https://soc.googlecode.com/hg/' just as well
and have 'git log FETCH_HEAD' Just Work (tm) too. In that light
.git/info/remote-<vcs>/ is probably a better idea, so that the helper
can use say '.git/info/remote-<vcs>/fetch/ for one-time fetches.
--
Cheers,
Sverre Rabbelier
^ permalink raw reply
* Re: [PATCH] MSVC: Windows-native implementation for subset of Pthreads API
From: Nicolas Pitre @ 2009-11-05 0:22 UTC (permalink / raw)
To: Andrzej K. Haczewski; +Cc: git, Johannes Sixt
In-Reply-To: <4AF214D5.6050202@gmail.com>
On Thu, 5 Nov 2009, Andrzej K. Haczewski wrote:
> @@ -1638,6 +1657,8 @@ static void ll_find_deltas(struct object_entry **list, unsigned list_size,
> delta_search_threads);
> p = xcalloc(delta_search_threads, sizeof(*p));
>
> + init_threaded_search();
Careful. At the beginning of the function you'll find:
if (delta_search_threads <= 1) {
find_deltas(list, &list_size, window, depth, processed);
return;
}
That is, if we have thread support compiled in but we're told to use
only one thread, then the bulk of the work splitting is bypassed
entirely. Inside find_deltas() there will still be pthread_mutex_lock()
and pthread_mutex_unlock() calls even if no threads are spawned.
Nicolas
^ permalink raw reply
* Re: [PATCH] MSVC: port pthread code to native Windows threads
From: Nicolas Pitre @ 2009-11-05 0:27 UTC (permalink / raw)
To: Daniel Barkalow; +Cc: Andrzej K. Haczewski, Johannes Sixt, git
In-Reply-To: <alpine.LNX.2.00.0911041640060.14365@iabervon.org>
On Wed, 4 Nov 2009, Daniel Barkalow wrote:
> On Wed, 4 Nov 2009, Nicolas Pitre wrote:
>
> > On Wed, 4 Nov 2009, Daniel Barkalow wrote:
> >
> > > On Wed, 4 Nov 2009, Andrzej K. Haczewski wrote:
> > >
> > > > 2009/11/4 Johannes Sixt <j.sixt@viscovery.net>:
> > > > >
> > > > > You are right. But #ifdef THREADED_DELTA_SEARCH is about a "generic"
> > > > > property of the code and is already used elsewhere in the file, whereas
> > > > > #ifdef WIN32 would be new and is is about platform differences.
> > > > >
> > > > > Anyway, we would have to see what Junio says about the new function calls,
> > > > > because he's usually quite anal when it comes to added code vs. static
> > > > > initialization. ;)
> > > >
> > > > I could do it with wrappers for pthread_mutex_lock and _unlock and
> > > > lazy init there plus lazy init cond var in cond_wait and _signal, that
> > > > way it could be done without any additional code in the first #ifdef.
> > > > But I don't see any simple solution for working around
> > > > deinitialization, that's why I'd leave non-static initialization. Let
> > > > me put some touchups and resubmit for another round.
> > >
> > > Is it actually necessary to deinitialize? Since the variables are static
> > > and therefore can't leak, and would presumably not need to be
> > > reinitialized differently if they were used again, I think they should be
> > > able to just stay. If Windows is unhappy about processes still having
> > > locks initialized at exit, I suppose we could go through and destroy all
> > > our mutexes and conds at cleanup time. Pthreads does have the appropriate
> > > functions, and it would be correct to use them, although unnecessary.
> >
> > Lazy initialization would probably turn up to be more expensive
> > (checking a flag on each usage) than unconditionally initializing them
> > once. Remember that those are used at least once per object meaning a
> > lot.
>
> Meh, checking a flag on the same cache line as the lock you're about to
> take can't be a big incremental cost, especially if it's actually checking
> whether some sort of cookie is non-zero before doing something with it.
This is still a bigger cost than not checking such flag at all.
Especially if the check will be false on every call but the first one
out of millions. I agree this is not significant, but neither is a
runtime initialization vs a static one.
> I don't think it matters terribly much either way which we use, so long as
> its consistent. It'd be nice if the static initializers worked, just
> because people seem to write code with them, but we could just not do that
> in the future.
Maybe the static initializer can be turned into a global constructor on
Windows?
Nicolas
^ permalink raw reply
* [PATCH v5.1 2/3] http-backend: Use http.getanyfile to disable dumb HTTP serving
From: Shawn O. Pearce @ 2009-11-05 1:16 UTC (permalink / raw)
To: git
In-Reply-To: <1257383798-29826-1-git-send-email-spearce@spearce.org>
Some repository owners may wish to enable smart HTTP, but disallow
dumb content serving. Disallowing dumb serving might be because
the owners want to rely upon reachability to control which objects
clients may access from the repository, or they just want to
encourage clients to use the more bandwidth efficient transport.
If http.getanyfile is set to false the backend CGI will return with
'403 Forbidden' when an object file is accessed by a dumb client.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
Documentation/git-http-backend.txt | 8 ++++++++
http-backend.c | 34 ++++++++++++++++++++++++++++------
2 files changed, 36 insertions(+), 6 deletions(-)
diff --git a/Documentation/git-http-backend.txt b/Documentation/git-http-backend.txt
index f17251a..67aec06 100644
--- a/Documentation/git-http-backend.txt
+++ b/Documentation/git-http-backend.txt
@@ -29,6 +29,14 @@ SERVICES
These services can be enabled/disabled using the per-repository
configuration file:
+http.getanyfile::
+ This serves older Git clients which are unable to use the
+ upload pack service. When enabled, clients are able to read
+ any file within the repository, including objects that are
+ no longer reachable from a branch but are still present.
+ It is enabled by default, but a repository can disable it
+ by setting this configuration item to `false`.
+
http.uploadpack::
This serves 'git-fetch-pack' and 'git-ls-remote' clients.
It is enabled by default, but a repository can disable it
diff --git a/http-backend.c b/http-backend.c
index 7900cda..9021266 100644
--- a/http-backend.c
+++ b/http-backend.c
@@ -10,6 +10,7 @@
static const char content_type[] = "Content-Type";
static const char content_length[] = "Content-Length";
static const char last_modified[] = "Last-Modified";
+static int getanyfile = 1;
static struct string_list *query_params;
@@ -194,6 +195,12 @@ static NORETURN void forbidden(const char *err, ...)
exit(0);
}
+static void select_getanyfile(void)
+{
+ if (!getanyfile)
+ forbidden("Unsupported service: getanyfile");
+}
+
static void send_strbuf(const char *type, struct strbuf *buf)
{
hdr_int(content_length, buf->len);
@@ -238,38 +245,51 @@ static void send_file(const char *the_type, const char *name)
static void get_text_file(char *name)
{
+ select_getanyfile();
hdr_nocache();
send_file("text/plain", name);
}
static void get_loose_object(char *name)
{
+ select_getanyfile();
hdr_cache_forever();
send_file("application/x-git-loose-object", name);
}
static void get_pack_file(char *name)
{
+ select_getanyfile();
hdr_cache_forever();
send_file("application/x-git-packed-objects", name);
}
static void get_idx_file(char *name)
{
+ select_getanyfile();
hdr_cache_forever();
send_file("application/x-git-packed-objects-toc", name);
}
static int http_config(const char *var, const char *value, void *cb)
{
- struct rpc_service *svc = cb;
-
- if (!prefixcmp(var, "http.") &&
- !strcmp(var + 5, svc->config_name)) {
- svc->enabled = git_config_bool(var, value);
+ if (!strcmp(var, "http.getanyfile")) {
+ getanyfile = git_config_bool(var, value);
return 0;
}
+ if (!prefixcmp(var, "http.")) {
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(rpc_service); i++) {
+ struct rpc_service *svc = &rpc_service[i];
+ if (!strcmp(var + 5, svc->config_name)) {
+ svc->enabled = git_config_bool(var, value);
+ return 0;
+ }
+ }
+ }
+
/* we are not interested in parsing any other configuration here */
return 0;
}
@@ -293,7 +313,6 @@ static struct rpc_service *select_service(const char *name)
if (!svc)
forbidden("Unsupported service: '%s'", name);
- git_config(http_config, svc);
if (svc->enabled < 0) {
const char *user = getenv("REMOTE_USER");
svc->enabled = (user && *user) ? 1 : 0;
@@ -442,6 +461,7 @@ static void get_info_refs(char *arg)
run_service(argv);
} else {
+ select_getanyfile();
for_each_ref(show_text_ref, &buf);
send_strbuf("text/plain", &buf);
}
@@ -455,6 +475,7 @@ static void get_info_packs(char *arg)
struct packed_git *p;
size_t cnt = 0;
+ select_getanyfile();
prepare_packed_git();
for (p = packed_git; p; p = p->next) {
if (p->pack_local)
@@ -621,6 +642,7 @@ int main(int argc, char **argv)
if (!enter_repo(dir, 0))
not_found("Not a git repository: '%s'", dir);
+ git_config(http_config, NULL);
cmd->imp(cmd_arg);
return 0;
}
--
1.6.5.2.295.g0d105
^ permalink raw reply related
* [PATCH v5.1 3/3] http-backend: Test configuration options
From: Shawn O. Pearce @ 2009-11-05 1:16 UTC (permalink / raw)
To: git
In-Reply-To: <1257383798-29826-1-git-send-email-spearce@spearce.org>
Test the major configuration settings which control access to
the repository:
http.getanyfile
http.uploadpack
http.receivepack
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
t/t5560-http-backend.sh | 229 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 229 insertions(+), 0 deletions(-)
create mode 100755 t/t5560-http-backend.sh
diff --git a/t/t5560-http-backend.sh b/t/t5560-http-backend.sh
new file mode 100755
index 0000000..908ba07
--- /dev/null
+++ b/t/t5560-http-backend.sh
@@ -0,0 +1,229 @@
+#!/bin/sh
+
+test_description='test git-http-backend'
+. ./test-lib.sh
+
+if test -n "$NO_CURL"; then
+ say 'skipping test, git built without http support'
+ test_done
+fi
+
+LIB_HTTPD_PORT=${LIB_HTTPD_PORT-'5560'}
+. "$TEST_DIRECTORY"/lib-httpd.sh
+start_httpd
+
+find_file() {
+ cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
+ find $1 -type f |
+ sed -e 1q
+}
+
+config() {
+ git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" config $1 $2
+}
+
+GET() {
+ curl --include "$HTTPD_URL/smart/repo.git/$1" >out 2>/dev/null &&
+ tr '\015' Q <out |
+ sed '
+ s/Q$//
+ 1q
+ ' >act &&
+ echo "HTTP/1.1 $2" >exp &&
+ test_cmp exp act
+}
+
+POST() {
+ curl --include --data "$2" \
+ --header "Content-Type: application/x-$1-request" \
+ "$HTTPD_URL/smart/repo.git/$1" >out 2>/dev/null &&
+ tr '\015' Q <out |
+ sed '
+ s/Q$//
+ 1q
+ ' >act &&
+ echo "HTTP/1.1 $3" >exp &&
+ test_cmp exp act
+}
+
+log_div() {
+ echo >>"$HTTPD_ROOT_PATH"/access.log
+ echo "### $1" >>"$HTTPD_ROOT_PATH"/access.log
+ echo "###" >>"$HTTPD_ROOT_PATH"/access.log
+}
+
+test_expect_success 'setup repository' '
+ echo content >file &&
+ git add file &&
+ git commit -m one &&
+
+ mkdir "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
+ (cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
+ git --bare init &&
+ : >objects/info/alternates &&
+ : >objects/info/http-alternates
+ ) &&
+ git remote add public "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
+ git push public master:master &&
+
+ (cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
+ git repack -a -d
+ ) &&
+
+ echo other >file &&
+ git add file &&
+ git commit -m two &&
+ git push public master:master &&
+
+ LOOSE_URL=$(find_file objects/??) &&
+ PACK_URL=$(find_file objects/pack/*.pack) &&
+ IDX_URL=$(find_file objects/pack/*.idx)
+'
+
+get_static_files() {
+ GET HEAD "$1" &&
+ GET info/refs "$1" &&
+ GET objects/info/packs "$1" &&
+ GET objects/info/alternates "$1" &&
+ GET objects/info/http-alternates "$1" &&
+ GET $LOOSE_URL "$1" &&
+ GET $PACK_URL "$1" &&
+ GET $IDX_URL "$1"
+}
+
+test_expect_success 'direct refs/heads/master not found' '
+ log_div "refs/heads/master"
+ GET refs/heads/master "404 Not Found"
+'
+test_expect_success 'static file is ok' '
+ log_div "getanyfile default"
+ get_static_files "200 OK"
+'
+test_expect_success 'static file if http.getanyfile true is ok' '
+ log_div "getanyfile true"
+ config http.getanyfile true &&
+ get_static_files "200 OK"
+'
+test_expect_success 'static file if http.getanyfile false fails' '
+ log_div "getanyfile false"
+ config http.getanyfile false &&
+ get_static_files "403 Forbidden"
+'
+
+test_expect_success 'http.uploadpack default enabled' '
+ log_div "uploadpack default"
+ GET info/refs?service=git-upload-pack "200 OK" &&
+ POST git-upload-pack 0000 "200 OK"
+'
+test_expect_success 'http.uploadpack true' '
+ log_div "uploadpack true"
+ config http.uploadpack true &&
+ GET info/refs?service=git-upload-pack "200 OK" &&
+ POST git-upload-pack 0000 "200 OK"
+'
+test_expect_success 'http.uploadpack false' '
+ log_div "uploadpack false"
+ config http.uploadpack false &&
+ GET info/refs?service=git-upload-pack "403 Forbidden" &&
+ POST git-upload-pack 0000 "403 Forbidden"
+'
+
+test_expect_success 'http.receivepack default disabled' '
+ log_div "receivepack default"
+ GET info/refs?service=git-receive-pack "403 Forbidden" &&
+ POST git-receive-pack 0000 "403 Forbidden"
+'
+test_expect_success 'http.receivepack true' '
+ log_div "receivepack true"
+ config http.receivepack true &&
+ GET info/refs?service=git-receive-pack "200 OK" &&
+ POST git-receive-pack 0000 "200 OK"
+'
+test_expect_success 'http.receivepack false' '
+ log_div "receivepack false"
+ config http.receivepack false &&
+ GET info/refs?service=git-receive-pack "403 Forbidden" &&
+ POST git-receive-pack 0000 "403 Forbidden"
+'
+
+cat >exp <<EOF
+
+### refs/heads/master
+###
+GET /smart/repo.git/refs/heads/master HTTP/1.1 404 -
+
+### getanyfile default
+###
+GET /smart/repo.git/HEAD HTTP/1.1 200
+GET /smart/repo.git/info/refs HTTP/1.1 200
+GET /smart/repo.git/objects/info/packs HTTP/1.1 200
+GET /smart/repo.git/objects/info/alternates HTTP/1.1 200 -
+GET /smart/repo.git/objects/info/http-alternates HTTP/1.1 200 -
+GET /smart/repo.git/$LOOSE_URL HTTP/1.1 200
+GET /smart/repo.git/$PACK_URL HTTP/1.1 200
+GET /smart/repo.git/$IDX_URL HTTP/1.1 200
+
+### getanyfile true
+###
+GET /smart/repo.git/HEAD HTTP/1.1 200
+GET /smart/repo.git/info/refs HTTP/1.1 200
+GET /smart/repo.git/objects/info/packs HTTP/1.1 200
+GET /smart/repo.git/objects/info/alternates HTTP/1.1 200 -
+GET /smart/repo.git/objects/info/http-alternates HTTP/1.1 200 -
+GET /smart/repo.git/$LOOSE_URL HTTP/1.1 200
+GET /smart/repo.git/$PACK_URL HTTP/1.1 200
+GET /smart/repo.git/$IDX_URL HTTP/1.1 200
+
+### getanyfile false
+###
+GET /smart/repo.git/HEAD HTTP/1.1 403 -
+GET /smart/repo.git/info/refs HTTP/1.1 403 -
+GET /smart/repo.git/objects/info/packs HTTP/1.1 403 -
+GET /smart/repo.git/objects/info/alternates HTTP/1.1 403 -
+GET /smart/repo.git/objects/info/http-alternates HTTP/1.1 403 -
+GET /smart/repo.git/$LOOSE_URL HTTP/1.1 403 -
+GET /smart/repo.git/$PACK_URL HTTP/1.1 403 -
+GET /smart/repo.git/$IDX_URL HTTP/1.1 403 -
+
+### uploadpack default
+###
+GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
+POST /smart/repo.git/git-upload-pack HTTP/1.1 200 -
+
+### uploadpack true
+###
+GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
+POST /smart/repo.git/git-upload-pack HTTP/1.1 200 -
+
+### uploadpack false
+###
+GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 403 -
+POST /smart/repo.git/git-upload-pack HTTP/1.1 403 -
+
+### receivepack default
+###
+GET /smart/repo.git/info/refs?service=git-receive-pack HTTP/1.1 403 -
+POST /smart/repo.git/git-receive-pack HTTP/1.1 403 -
+
+### receivepack true
+###
+GET /smart/repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
+POST /smart/repo.git/git-receive-pack HTTP/1.1 200 -
+
+### receivepack false
+###
+GET /smart/repo.git/info/refs?service=git-receive-pack HTTP/1.1 403 -
+POST /smart/repo.git/git-receive-pack HTTP/1.1 403 -
+EOF
+test_expect_success 'server request log matches test results' '
+ sed -e "
+ s/^.* \"//
+ s/\"//
+ s/ [1-9][0-9]*\$//
+ s/^GET /GET /
+ " >act <"$HTTPD_ROOT_PATH"/access.log &&
+ test_cmp exp act
+'
+
+stop_httpd
+test_done
--
1.6.5.2.295.g0d105
^ permalink raw reply related
* [PATCH v5.1 1/3] http-backend: Remove pointless objects/info/* service entry
From: Shawn O. Pearce @ 2009-11-05 1:16 UTC (permalink / raw)
To: git
In earlier versions of this patch series this rule was used to
match and serve objects/info/alternates and http-alternates.
Later versions of the patch series explicitly called out match
rules for those files, making this wildcard rule unnecessary.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
This probably should be squashed into the commit that introduces
this CGI script ("Git-aware CGI to provide dumb HTTP transport").
http-backend.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/http-backend.c b/http-backend.c
index 8e5c0a2..7900cda 100644
--- a/http-backend.c
+++ b/http-backend.c
@@ -558,7 +558,6 @@ static struct service_cmd {
{"GET", "/objects/info/alternates$", get_text_file},
{"GET", "/objects/info/http-alternates$", get_text_file},
{"GET", "/objects/info/packs$", get_info_packs},
- {"GET", "/objects/info/[^/]*$", get_text_file},
{"GET", "/objects/[0-9a-f]{2}/[0-9a-f]{38}$", get_loose_object},
{"GET", "/objects/pack/pack-[0-9a-f]{40}\\.pack$", get_pack_file},
{"GET", "/objects/pack/pack-[0-9a-f]{40}\\.idx$", get_idx_file},
--
1.6.5.2.295.g0d105
^ permalink raw reply related
* Re: thoughts on setting core.logAllRefUpdates default true for bare repos
From: Sitaram Chamarty @ 2009-11-05 1:24 UTC (permalink / raw)
To: Nicolas Sebrecht; +Cc: Johannes Schindelin, git
In-Reply-To: <20091104235241.GA12984@vidovic>
On Thu, Nov 5, 2009 at 5:22 AM, Nicolas Sebrecht <nicolas.s.dev@gmx.fr> wrote:
> The 04/11/09, Sitaram Chamarty wrote:
>
>> But if you are able to do "gc" manually on any repo you can also do
>> "reflog expire" before "gc" can you not? Please correct me if I'm
>> wrong.
>
> "If we are able to do 'gc' on any repo"... But a lot of users aren't
> able to it because they aren't the admin.
>
> Or did you mean if "non-admin users could" ?
dscho's original mail said: > With gitweb on a public site, there
might be a problem when you pushed
> some blob containing trade secrets accidentally, and try to scrub the
> repository using "git gc" after a forced push.
That's a manual gc. If you can do a manual gc, you can do a reflog
expire before the gc, is what I meant.
>
> --
> Nicolas Sebrecht
>
^ permalink raw reply
* Re: thoughts on setting core.logAllRefUpdates default true for bare repos
From: Sitaram Chamarty @ 2009-11-05 1:28 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Matthieu Moy, Johannes Schindelin, git
In-Reply-To: <7v3a4ugjea.fsf@alter.siamese.dyndns.org>
On Thu, Nov 5, 2009 at 1:19 AM, Junio C Hamano <gitster@pobox.com> wrote:
> The single most common reason why a bare repository is bare is because
> nobody regularly logs in to the machine that hosts it and goes there to
> access its contents. As reflog is a local thing, and not exposed to
> outside world, enabling it alone would not help a lot to people who do not
> have such a direct access to the bare repository, which by definition is
> the majority because the reason why the repository is bare to begin with.
>
> Once we add ways to expose information kept in reflog of a bare repository
> more effectively and conveniently, the argument could become "should be
> enabled now it would be very useful to have one".
It doesn't have to be exposed nor we have to wait till such features
(like you mentioned gitweb, remote log, etc) are implemented.
We're talking "disaster recovery", not "daily use" -- after all,
*someone* has access to the machine, and can become "local" to it.
Regards,
Sitaram
^ permalink raw reply
* Re: Automatically remote prune
From: John Tapsell @ 2009-11-05 1:41 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Git List
In-Reply-To: <7v639qi2un.fsf@alter.siamese.dyndns.org>
2009/11/5 Junio C Hamano <gitster@pobox.com>:
> John Tapsell <johnflux@gmail.com> writes:
> You could store necessary information somewhere else when you contacted
> the remote the last time, but we need to consider what the benefits are to
> give this information in the first place.
We already get all this information on a "git fetch", no? And then
promptly discard it. Surely when we do "git fetch" . So I'm talking
about just not ignoring the information we get from git fetch, but
present that information to the user.
John
^ permalink raw reply
* Re: [PATCH v2 09/13] Honour the refspec when updating refs after import
From: Sverre Rabbelier @ 2009-11-05 1:45 UTC (permalink / raw)
To: Daniel Barkalow; +Cc: Git List, Johannes Schindelin, Johan Herland
In-Reply-To: <alpine.LNX.2.00.0911041624401.14365@iabervon.org>
Heya,
On Wed, Nov 4, 2009 at 22:30, Daniel Barkalow <barkalow@iabervon.org> wrote:
> On Wed, 4 Nov 2009, Sverre Rabbelier wrote:
>> On Wed, Nov 4, 2009 at 22:20, Daniel Barkalow <barkalow@iabervon.org> wrote:
>> > That's not true for "git pull <url> <branch>"; we do want the remote ref,
>> > but it doesn't have a local peer.
No, I don't think that's right, when doing a fetch we want to store
the refs somewhere, sure, but not under 'refs/heads/<branch>', perhaps
'refs/hg/fetch/<branch>', either way, the current code does not work.
>> >I think going straight to the refspec
>> > command is the right answer.
>>
>> Can you clarity what you mean with "the refspec command"?
>
> Whatever it is that lets the helper tell the transport code where in the
> helper's private namespace to look for refs. I'd been thinking the helper
> would advertize the "refspec" capability, and the transport code would
> call the "refspec" command in order to get the helper to report that; but
> then I actually only said that the helper reports refspec, and not
> proposed a name for the command.
Currently I'm implementing so that it would work like this for the svn helper:
$ echo capabilities | git remote-svn origin /path/to/hg/repo
import
refspec +refs/trunk:refs/svn/origin/trunk
refspec +refs/branches/*:refs/svn/origin/*
That way we can put the refspec in the config file at clone time.
Now I've been browsing through the builtin-fetch code, and it looks
like the main problem is going to be to apply this refspec at all.
I'll have a more extensive look tomorrow.
--
Cheers,
Sverre Rabbelier
^ permalink raw reply
* Re: Automatically remote prune
From: Shawn O. Pearce @ 2009-11-05 2:00 UTC (permalink / raw)
To: John Tapsell; +Cc: Junio C Hamano, Git List
In-Reply-To: <43d8ce650911041741w4b39d137ha2a1529a15256d27@mail.gmail.com>
John Tapsell <johnflux@gmail.com> wrote:
> 2009/11/5 Junio C Hamano <gitster@pobox.com>:
> > John Tapsell <johnflux@gmail.com> writes:
>
> > You could store necessary information somewhere else when you contacted
> > the remote the last time, but we need to consider what the benefits are to
> > give this information in the first place.
>
> We already get all this information on a "git fetch", no? And then
> promptly discard it. Surely when we do "git fetch" . So I'm talking
> about just not ignoring the information we get from git fetch, but
> present that information to the user.
Good point. We currently don't have a provision to store this
information, but we could store a list of dead remote tracking
branches for reference later during `git branch -r`.
Its not a lot of data, it just has little perceived value to most
Git hackers because a remote branch disappears very infrequently
(if ever) for most of us.
--
Shawn.
^ permalink raw reply
* Re: [PATCH] MSVC: Windows-native implementation for subset of Pthreads API
From: Nicolas Pitre @ 2009-11-05 2:10 UTC (permalink / raw)
To: Andrzej K. Haczewski; +Cc: git, Johannes Sixt
In-Reply-To: <4AF214D5.6050202@gmail.com>
On Thu, 5 Nov 2009, Andrzej K. Haczewski wrote:
> +static inline int pthread_cond_init(pthread_cond_t *cond, const void *unused)
> +{
> + cond->waiters = 0;
> +
> + InitializeCriticalSection(&cond->waiters_lock);
> +
> + cond->sema = CreateSemaphore(NULL, 0, LONG_MAX, NULL);
> + if (!cond->sema)
> + return 0; /* POSIX do not allow pthread_cond_init to fail */
> + return 0;
> +}
Please use die("CreateSemaphore() failed") in the failure case instead
of returning success.
However, my pthread_cond_init man page says:
[[[
RETURN VALUE
If successful, the pthread_cond_destroy() and pthread_cond_init() func-
tions shall return zero; otherwise, an error number shall be returned
to indicate the error.
The [EBUSY] and [EINVAL] error checks, if implemented, shall act as if
they were performed immediately at the beginning of processing for the
function and caused an error return prior to modifying the state of the
condition variable specified by cond.
ERRORS
The pthread_cond_destroy() function may fail if:
EBUSY The implementation has detected an attempt to destroy the object
referenced by cond while it is referenced (for example, while
being used in a pthread_cond_wait() or pthread_cond_timedwait())
by another thread.
EINVAL The value specified by cond is invalid.
The pthread_cond_init() function shall fail if:
EAGAIN The system lacked the necessary resources (other than memory) to
initialize another condition variable.
ENOMEM Insufficient memory exists to initialize the condition variable.
The pthread_cond_init() function may fail if:
EBUSY The implementation has detected an attempt to reinitialize the
object referenced by cond, a previously initialized, but not yet
destroyed, condition variable.
EINVAL The value specified by attr is invalid.
]]]
I'm not advocating that you implement detailed error codes as we don't
really care about specific errors. This is just to disagree with the
"POSIX do not allow pthread_cond_init to fail" assertion. In any case,
using die() to keep it simple is certainly better than blindly returning
0 on failure. However you could simply return ENOMEM and use the die()
in init_threaded_search() instead.
Nicolas
^ permalink raw reply
* Re: Automatically remote prune
From: Junio C Hamano @ 2009-11-05 2:23 UTC (permalink / raw)
To: John Tapsell; +Cc: Git List
In-Reply-To: <43d8ce650911041741w4b39d137ha2a1529a15256d27@mail.gmail.com>
John Tapsell <johnflux@gmail.com> writes:
> 2009/11/5 Junio C Hamano <gitster@pobox.com>:
>> John Tapsell <johnflux@gmail.com> writes:
>
>> You could store necessary information somewhere else when you contacted
>> the remote the last time, but we need to consider what the benefits are to
>> give this information in the first place.
>
> We already get all this information on a "git fetch", no?
"what the benefits are to give this information _in the 'branch' output_"
was what I meant. From the part you omitted from my message:
The [Deleted] mark in your suggestion tells the user:
This is already removed in the remote, and this tracking copy is the
only way for you to view it ever again. Do not run 'remote prune
origin' blindly otherwise you will lose it.
There are two reasons I could think of that the user might want to know
this.
(1) The user wants to keep the remotes/<origin>/* namespace clean (iow,
the user does not care to keep old commits that were deemed bad by
the remote side) by removing stale tracking refs. But in this case,
it is very unlikely that the user would use "git branch -d -r" to
remove stale ones one-by-one after seeing '[Deleted]' label in the
output from "git branch -r". Rather he would run "git remote prune
origin" to blindly remove them all.
(2) The user does want to be careful not to lose commits that now only
exists in his repository. Perhaps he saw something worthwhile to
base his topic later on. But these stale remote tracking refs are
not removed until the user runs "git remote prune origin". As long
as we give him a way to check what will be pruned before running "git
remote prune", there is not much point in showing that information in
output of "git branch -r". There is no need to keep extra info by
creating a new file in .git by "fetch". Nor showing that to the user
when he does "fetch" either, for that matter.
A better approach to please the first class of audience may be to
introduce an option that tells fetch to cull tracking refs that are stale.
Then "branch -r" output will not show stale refs and there is no place
(nor need) to show [Deleted] labels.
Such an option won't be very useful for the second class of audience,
though. For them we would need something else, and it would likely be an
enhancement to "git remote". It would ask the other side what refs are no
longer there, and then check our local refspace to see if there are local
topics based on them (which would mean the user is already in a trouble)
and which ones are not forked locally at all (which may mean "it wasn't
interesting to the user, and we can safely remove it" or "the user was
interested in it, but hasn't got around to forking from it yet, being busy
working on something else"). I am unsure what should be done in the
latter case (i.e. lost remote refs haven't been touched locally) but am
just thinking aloud.
^ permalink raw reply
* Re: [PATCH] MSVC: Windows-native implementation for subset of Pthreads API
From: Nicolas Pitre @ 2009-11-05 2:47 UTC (permalink / raw)
To: Andrzej K. Haczewski; +Cc: kusmabite, git, Johannes Sixt
In-Reply-To: <4AF20534.2030004@gmail.com>
On Wed, 4 Nov 2009, Andrzej K. Haczewski wrote:
> Erik Faye-Lund pisze:
> > Couldn't the windows version of pthread_create have a wrapper
> > function, that corrected the calling convention, much like the
> > function run_thread that start_async in run-command.c has?
>
> Can't be done without allocations. I'd have to pass to that wrapping
> thread function an address of original function *and* an original
> argument, and there's no way to pack that as one void*.
What about:
typedef struct {
HANDLE handle;
void *(*start_routine)(void *);
void *arg;
} pthread_t;
DWORD __stdcall windows_thread_start(LPVOID _self)
{
pthread_t *self = _self;
void *ret = self->start_routine(self->arg);
return (DWORD)ret;
}
static inline int pthread_create(pthread_t *thread, const void *unused,
void *(*start_routine)(void *), void *arg)
{
thread->handle = CreateThread(NULL, 0, windows_thread_start,
thread, 0, NULL);
[...]
}
?
Sure this will use 8 to 16 more bytes per thread, but we're dealing with
a rather small number of threads anyway (more threads than the number of
CPU cores is useless) making this extra memory usage rather
insignificant compared to the many megabytes of RAM the rest of the code
is using. The advantage is full compatibility with the native pthread
interface git is using at the source level while still being much
lighter than a full blown pthread implementation.
And thread creation is a relatively rare event compared to e.g. mutex
lock/unlock, so the indirection shouldn't be noticeable. For the same
reason, I also think that you could make pthread_create() and
pthread_join() into a C file instead of being inlined which would reduce
the code footprint at every call site, and allow for only one instance
of windows_thread_start() which could then be made static.
Nicolas
^ permalink raw reply
* Re: Automatically remote prune
From: Sitaram Chamarty @ 2009-11-05 3:15 UTC (permalink / raw)
To: Junio C Hamano; +Cc: John Tapsell, Git List
In-Reply-To: <7viqdpemki.fsf@alter.siamese.dyndns.org>
On Thu, Nov 5, 2009 at 7:53 AM, Junio C Hamano <gitster@pobox.com> wrote:
> (1) The user wants to keep the remotes/<origin>/* namespace clean (iow,
[snip]
> (2) The user does want to be careful not to lose commits that now only
This whole discussion is a conflict between those two. The current
system does the latter, safer, thing. John's users are getting
confused because they *think* this means the remote still has those
refs.
At best an alias that does a prune before (or after) a fetch should do.
And I notice 'git gui' has an option to "prune during fetch" -- maybe
that should be an option that is also made available to the CLI fetch.
^ permalink raw reply
* Re: [PATCH v2] commit -c/-C/--amend: reset timestamp and authorship to committer with --reset-author
From: Nanako Shiraishi @ 2009-11-05 3:34 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Erick Mattos, git
In-Reply-To: <7vpr7ykbh8.fsf@alter.siamese.dyndns.org>
Quoting Junio C Hamano <gitster@pobox.com>
> I had an impression that we have already established that setting the
> author with --author="Somebody Else <s@b.e>" and committing with the
> current time does not make much sense from the workflow point of view long
> time ago in this thread.
> <snip>
> But allowing this combination, even though it might not make much sense,
> is just giving extra length to the rope, so it may not be such a big deal.
It may be wise to forbid a combination of options if it
encourages mistakes or a wrong workflow, but I don't think
using --author and --reset-author with 'git commit --amend'
is such a case.
Imagine somebody other than you (eg. me) were the maintainer,
and a message by Szeder was sent with a good commit log message.
http://article.gmane.org/gmane.comp.version-control.git/132029
Then you sent a replacement patch that solves the same problem
in a more elegant way, but without anything that is usable as the
commit log message.
http://article.gmane.org/gmane.comp.version-control.git/132041
If I were the maintainer, I would find it very convenient if I can
work like this:
% git am -s 132029 --- first I apply Szeder's version
Then I see your message. Replace the code change but use Szeder's
log message.
% git reset --hard HEAD^
% git am 132041 --- your version with no usable log message
% git commit --amend -s -c @{2} --author='Junio C Hamano <...>'
> Sorry, but I cannot help feeling a bit frustrated and mildly irritated.
Don't try to be perfect and feel stressed out, and please take
a good rest.
--
Nanako Shiraishi
http://ivory.ap.teacup.com/nanako3/
^ permalink raw reply
* Re: [RFC/PATCH 0/3] use '--bisect-refs' as bisect rev machinery option
From: Christian Couder @ 2009-11-05 5:22 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Linus Torvalds, git
In-Reply-To: <7vtyxaez4f.fsf@alter.siamese.dyndns.org>
On Wednesday 04 November 2009, Junio C Hamano wrote:
> Christian Couder <chriscool@tuxfamily.org> writes:
> > So to do that you would use "git bisect start ..." and then you could
> > use:
> >
> > $ git rev-list --bisect HEAD --not $GOOD_COMMITS
> >
> > to get the commit that you would have to test if the current commit is
> > bad and:
> >
> > $ git rev-list --bisect $BAD --not $GOOD_COMMITS HEAD
> >
> > to get the commit that you would have to test if the current commit is
> > good.
>
> Even in that case, the problem is still about narrowing the set of the
> current bisection graph. If --bisect option implicitly grabs good and
> bad defined in the refspace like Linus's patch does, it will give you the
> same behaviour of the above two commands, no?
I think it will probably work when you add a good rev, but in the case where
you give a different bad (the first command above) it does not work the
same.
The test case in patch 1/3 shows that. It does:
git bisect start $HASH7 $HASH1 &&
...
rev_list2=$(git rev-list --bisect $HASH3 --not $HASH1) &&
test "$rev_list2" = "$HASH2"
and that last command fails.
Best regards,
Christian.
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox