* [PATCHv2 05/36] attr.c: complete a sentence in a comment
From: Stefan Beller @ 2016-10-28 18:54 UTC (permalink / raw)
To: gitster; +Cc: bmwill, pclouds, git, Stefan Beller
In-Reply-To: <20161028185502.8789-1-sbeller@google.com>
From: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
---
attr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/attr.c b/attr.c
index 6b55a57ef7..9bdf87a6fe 100644
--- a/attr.c
+++ b/attr.c
@@ -300,7 +300,7 @@ static struct match_attr *parse_attr_line(const char *line, const char *src,
* directory (again, reading the file from top to bottom) down to the
* current directory, and then scan the list backwards to find the first match.
* This is exactly the same as what is_excluded() does in dir.c to deal with
- * .gitignore
+ * .gitignore file and info/excludes file as a fallback.
*/
static struct attr_stack {
--
2.10.1.714.ge3da0db
^ permalink raw reply related
* [PATCHv2 07/36] attr.c: simplify macroexpand_one()
From: Stefan Beller @ 2016-10-28 18:54 UTC (permalink / raw)
To: gitster; +Cc: bmwill, pclouds, git, Stefan Beller
In-Reply-To: <20161028185502.8789-1-sbeller@google.com>
From: Junio C Hamano <gitster@pobox.com>
The double-loop wants to do an early return immediately when one
matching macro is found. Eliminate the extra variable 'a' used for
that purpose and rewrite the "assign the found item to 'a' to make
it non-NULL and force the loop(s) to terminate" with a direct return
from there.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
---
attr.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/attr.c b/attr.c
index 17297fffee..e42f931b35 100644
--- a/attr.c
+++ b/attr.c
@@ -705,24 +705,21 @@ static int fill(const char *path, int pathlen, int basename_offset,
static int macroexpand_one(int nr, int rem)
{
struct attr_stack *stk;
- struct match_attr *a = NULL;
int i;
if (check_all_attr[nr].value != ATTR__TRUE ||
!check_all_attr[nr].attr->maybe_macro)
return rem;
- for (stk = attr_stack; !a && stk; stk = stk->prev)
- for (i = stk->num_matches - 1; !a && 0 <= i; i--) {
+ for (stk = attr_stack; stk; stk = stk->prev) {
+ for (i = stk->num_matches - 1; 0 <= i; i--) {
struct match_attr *ma = stk->attrs[i];
if (!ma->is_macro)
continue;
if (ma->u.attr->attr_nr == nr)
- a = ma;
+ return fill_one("expand", ma, rem);
}
-
- if (a)
- rem = fill_one("expand", a, rem);
+ }
return rem;
}
--
2.10.1.714.ge3da0db
^ permalink raw reply related
* [PATCHv2 06/36] attr.c: mark where #if DEBUG ends more clearly
From: Stefan Beller @ 2016-10-28 18:54 UTC (permalink / raw)
To: gitster; +Cc: bmwill, pclouds, git, Stefan Beller
In-Reply-To: <20161028185502.8789-1-sbeller@google.com>
From: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
---
attr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/attr.c b/attr.c
index 9bdf87a6fe..17297fffee 100644
--- a/attr.c
+++ b/attr.c
@@ -469,7 +469,7 @@ static void debug_set(const char *what, const char *match, struct git_attr *attr
#define debug_push(a) do { ; } while (0)
#define debug_pop(a) do { ; } while (0)
#define debug_set(a,b,c,d) do { ; } while (0)
-#endif
+#endif /* DEBUG_ATTR */
static void drop_attr_stack(void)
{
--
2.10.1.714.ge3da0db
^ permalink raw reply related
* [PATCHv2 04/36] attr.c: explain the lack of attr-name syntax check in parse_attr()
From: Stefan Beller @ 2016-10-28 18:54 UTC (permalink / raw)
To: gitster; +Cc: bmwill, pclouds, git, Stefan Beller
In-Reply-To: <20161028185502.8789-1-sbeller@google.com>
From: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
---
attr.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/attr.c b/attr.c
index 007f1a2995..6b55a57ef7 100644
--- a/attr.c
+++ b/attr.c
@@ -183,6 +183,12 @@ static const char *parse_attr(const char *src, int lineno, const char *cp,
return NULL;
}
} else {
+ /*
+ * As this function is always called twice, once with
+ * e == NULL in the first pass and then e != NULL in
+ * the second pass, no need for invalid_attr_name()
+ * check here.
+ */
if (*cp == '-' || *cp == '!') {
e->setto = (*cp == '-') ? ATTR__FALSE : ATTR__UNSET;
cp++;
--
2.10.1.714.ge3da0db
^ permalink raw reply related
* [PATCHv2 03/36] attr.c: update a stale comment on "struct match_attr"
From: Stefan Beller @ 2016-10-28 18:54 UTC (permalink / raw)
To: gitster; +Cc: bmwill, pclouds, git, Stefan Beller
In-Reply-To: <20161028185502.8789-1-sbeller@google.com>
From: Junio C Hamano <gitster@pobox.com>
When 82dce998 (attr: more matching optimizations from .gitignore,
2012-10-15) changed a pointer to a string "*pattern" into an
embedded "struct pattern" in struct match_attr, it forgot to update
the comment that describes the structure.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
---
attr.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/attr.c b/attr.c
index 04d24334e8..007f1a2995 100644
--- a/attr.c
+++ b/attr.c
@@ -131,9 +131,8 @@ struct pattern {
* If is_macro is true, then u.attr is a pointer to the git_attr being
* defined.
*
- * If is_macro is false, then u.pattern points at the filename pattern
- * to which the rule applies. (The memory pointed to is part of the
- * memory block allocated for the match_attr instance.)
+ * If is_macro is false, then u.pat is the filename pattern to which the
+ * rule applies.
*
* In either case, num_attr is the number of attributes affected by
* this rule, and state is an array listing them. The attributes are
--
2.10.1.714.ge3da0db
^ permalink raw reply related
* [PATCHv2 02/36] attr.c: use strchrnul() to scan for one line
From: Stefan Beller @ 2016-10-28 18:54 UTC (permalink / raw)
To: gitster; +Cc: bmwill, pclouds, git, Stefan Beller
In-Reply-To: <20161028185502.8789-1-sbeller@google.com>
From: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
---
attr.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/attr.c b/attr.c
index 1fcf042b87..04d24334e8 100644
--- a/attr.c
+++ b/attr.c
@@ -402,8 +402,8 @@ static struct attr_stack *read_attr_from_index(const char *path, int macro_ok)
for (sp = buf; *sp; ) {
char *ep;
int more;
- for (ep = sp; *ep && *ep != '\n'; ep++)
- ;
+
+ ep = strchrnul(sp, '\n');
more = (*ep == '\n');
*ep = '\0';
handle_attr_line(res, sp, path, ++lineno, macro_ok);
--
2.10.1.714.ge3da0db
^ permalink raw reply related
* [PATCHv2 01/36] commit.c: use strchrnul() to scan for one line
From: Stefan Beller @ 2016-10-28 18:54 UTC (permalink / raw)
To: gitster; +Cc: bmwill, pclouds, git, Stefan Beller
In-Reply-To: <20161028185502.8789-1-sbeller@google.com>
From: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
---
commit.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/commit.c b/commit.c
index 856fd4aeef..41b2fdd335 100644
--- a/commit.c
+++ b/commit.c
@@ -415,8 +415,7 @@ int find_commit_subject(const char *commit_buffer, const char **subject)
p++;
if (*p) {
p = skip_blank_lines(p + 2);
- for (eol = p; *eol && *eol != '\n'; eol++)
- ; /* do nothing */
+ eol = strchrnul(p, '\n');
} else
eol = p;
--
2.10.1.714.ge3da0db
^ permalink raw reply related
* [PATCHv2 00/36] Revamp the attr subsystem!
From: Stefan Beller @ 2016-10-28 18:54 UTC (permalink / raw)
To: gitster; +Cc: bmwill, pclouds, git, Stefan Beller
previous discussion at https://public-inbox.org/git/20161022233225.8883-1-sbeller@google.com
This implements the discarded series':
jc/attr
jc/attr-more
sb/pathspec-label
sb/submodule-default-paths
This includes
* The fixes for windows
* Junios latest suggestion to use git_attr_check_initv instead of
alloc/append.
* I implemented the thread safe attr API in patch 27 (attr: convert to new threadsafe API)
* patch 28 (attr: keep attr stack for each check) makes it actually possible
to run in a multithreaded environment.
* I added a test for the multithreaded when it is introduced in patch 32
(pathspec: allow querying for attributes) as well as a test to disallow
multiple "attr"s in a pathspec.
Thanks,
Stefan
Junio C Hamano (24):
commit.c: use strchrnul() to scan for one line
attr.c: use strchrnul() to scan for one line
attr.c: update a stale comment on "struct match_attr"
attr.c: explain the lack of attr-name syntax check in parse_attr()
attr.c: complete a sentence in a comment
attr.c: mark where #if DEBUG ends more clearly
attr.c: simplify macroexpand_one()
attr.c: tighten constness around "git_attr" structure
attr.c: plug small leak in parse_attr_line()
attr: rename function and struct related to checking attributes
attr: (re)introduce git_check_attr() and struct git_attr_check
attr: convert git_all_attrs() to use "struct git_attr_check"
attr: convert git_check_attrs() callers to use the new API
attr: retire git_check_attrs() API
attr: add counted string version of git_check_attr()
attr: add counted string version of git_attr()
attr: expose validity check for attribute names
attr.c: add push_stack() helper
attr.c: pass struct git_attr_check down the callchain
attr.c: rename a local variable check
attr.c: correct ugly hack for git_all_attrs()
attr.c: introduce empty_attr_check_elems()
attr.c: always pass check[] to collect_some_attrs()
attr.c: outline the future plans by heavily commenting
Nguyễn Thái Ngọc Duy (1):
attr: support quoting pathname patterns in C style
Stefan Beller (11):
attr: make git_check_attr_counted static
attr: convert to new threadsafe API
attr: keep attr stack for each check
Documentation: fix a typo
pathspec: move long magic parsing out of prefix_pathspec
pathspec: move prefix check out of the inner loop
pathspec: allow querying for attributes
pathspec: allow escaped query values
submodule update: add `--init-default-path` switch
clone: add --init-submodule=<pathspec> switch
completion: clone can initialize specific submodules
Documentation/config.txt | 5 +
Documentation/git-clone.txt | 23 +-
Documentation/git-submodule.txt | 17 +-
Documentation/gitattributes.txt | 10 +-
Documentation/glossary-content.txt | 20 +
Documentation/technical/api-gitattributes.txt | 140 ++++---
archive.c | 25 +-
attr.c | 525 ++++++++++++++++++--------
attr.h | 71 ++--
builtin/check-attr.c | 74 ++--
builtin/clone.c | 36 +-
builtin/pack-objects.c | 27 +-
commit.c | 3 +-
compat/mingw.c | 4 +
contrib/completion/git-completion.bash | 1 +
convert.c | 46 ++-
dir.c | 35 ++
git-submodule.sh | 21 +-
hashmap.h | 2 +
ll-merge.c | 35 +-
pathspec.c | 227 +++++++++--
pathspec.h | 15 +
t/t0003-attributes.sh | 26 ++
t/t6134-pathspec-with-labels.sh | 185 +++++++++
t/t7400-submodule-basic.sh | 134 +++++++
userdiff.c | 21 +-
ws.c | 19 +-
27 files changed, 1336 insertions(+), 411 deletions(-)
create mode 100755 t/t6134-pathspec-with-labels.sh
--
2.10.1.714.ge3da0db
^ permalink raw reply
* Re: [PATCH] compat: Allow static initializer for pthreads on Windows
From: Jacob Keller @ 2016-10-28 18:49 UTC (permalink / raw)
To: Philip Oakley
Cc: Johannes Sixt, Stefan Beller, Junio C Hamano, Johannes Schindelin,
Git mailing list, Simon Ruderich, Jeff King
In-Reply-To: <B5FD05E58E36480894F1BDBBC9589EE1@PhilipOakley>
On Fri, Oct 28, 2016 at 6:01 AM, Philip Oakley <philipoakley@iee.org> wrote:
> From: "Johannes Sixt" <j6t@kdbg.org>
>>
>>
>> One point is that the DCLP idiom must be implemented correctly. There are
>> solutions, of course, and when the initialization is over, we have a
>> miniscule overhead at each pthread_mutex_lock call.
>>
>
> I had to look up DCLP ( = Double Checked Locking Patterns), and found a good
> write up on the issues..
>
> http://www.aristeia.com/Papers/DDJ_Jul_Aug_2004_revised.pdf "C++ and the
> Perils of Double-Checked Locking", which include 'C' issues, and
> multi-thread, multi-processor issues. Not an easy issue when fighting
> optimisers..
>
> --
>
> Philip
Yep, this is why we have memory barriers. Ofcourse languages like C
don't really allow you to express them in the language and we restore
to various platform specific methods.
Thanks,
Jake
^ permalink raw reply
* Re: [PATCH] compat: Allow static initializer for pthreads on Windows
From: Jacob Keller @ 2016-10-28 18:48 UTC (permalink / raw)
To: Johannes Schindelin
Cc: Johannes Sixt, Stefan Beller, Junio C Hamano, git@vger.kernel.org,
Simon Ruderich, Jeff King
In-Reply-To: <alpine.DEB.2.20.1610281356310.3264@virtualbox>
On Fri, Oct 28, 2016 at 4:58 AM, Johannes Schindelin
<Johannes.Schindelin@gmx.de> wrote:
> Hi Jake,
>
> On Thu, 27 Oct 2016, Jacob Keller wrote:
>
>> I agree with Stefan that there isn't really a great place to put a
>> dynamic initialization.
>
> Ummm. Wait. What???
>
> https://github.com/git/git/blob/v2.10.1/common-main.c#L25-L41
>
> Ciao,
> Johannes
I think Stefan has since provided a better suggestion of isolating the
dynamic initialization into the MINGW startup section. However, you
are right either place works, though I think platforms which support
static initialization should use it.
Thanks,
Jake
^ permalink raw reply
* [PATCH] pre-receive.sample: Mark executable
From: Anders Kaseorg @ 2016-10-28 18:40 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
For consistency with other hooks, allow the hook to be activated by
renaming pre-receive.sample to pre-receive without a separate step to
mark it executable.
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
---
templates/hooks--pre-receive.sample | 0
1 file changed, 0 insertions(+), 0 deletions(-)
mode change 100644 => 100755 templates/hooks--pre-receive.sample
diff --git a/templates/hooks--pre-receive.sample b/templates/hooks--pre-receive.sample
old mode 100644
new mode 100755
--
2.10.1
^ permalink raw reply
* Re: [PATCH] attr: convert to new threadsafe API
From: Johannes Sixt @ 2016-10-28 18:16 UTC (permalink / raw)
To: Stefan Beller, gitster
Cc: git, bmwill, pclouds, Johannes.Schindelin, peff, simon
In-Reply-To: <20161027221550.14930-1-sbeller@google.com>
Am 28.10.2016 um 00:15 schrieb Stefan Beller:
> * use attr_start on Windows to dynamically initialize the Single Big Attr Mutex
I'm sorry, I didn't find time to test the patch on Windows. I won't be
back at my Windows box before Wednesday.
-- Hannes
^ permalink raw reply
* Re: [PATCH v3 2/3] sha1_file: open window into packfiles with O_CLOEXEC
From: Junio C Hamano @ 2016-10-28 17:47 UTC (permalink / raw)
To: Linus Torvalds
Cc: Johannes Schindelin, Jeff King, Git Mailing List, Lars Schneider,
Eric Wong
In-Reply-To: <CA+55aFwUEzfvWVSZfhBi85QaKWSo-gVMOk1BJFrR0ZsdCRHRsg@mail.gmail.com>
Linus Torvalds <torvalds@linux-foundation.org> writes:
> On Fri, Oct 28, 2016 at 9:48 AM, Junio C Hamano <gitster@pobox.com> wrote:
>>
>> Setting FD_CLOEXEC with fcntl(2) may be racy, but in what way
>> it is broken to open(2) with O_CLOEXEC?
>
> Apparently windows doesn't even support it, at least not mingw. So
> you'll have to have some supprt for just explicitly closing things at
> execve anyway. And if you do that for windows, then what's the point
> of using O_CLOEXEC on Linux, and having two totally different paths
> that will just mean maintenance headache.
Ah, that's where your reaction comes from. If I understood Dscho
correctly, what he said was that I cannot set FD_CLOEXEC via fcntl()
emulation they have. It wasn't an objection to O_CLOEXEC. In fact,
since 05d1ed6148 ("mingw: ensure temporary file handles are not
inherited by child processes", 2016-08-22), we have been relying on
open(2) with O_CLOEXEC even on Windows (by emulating it with
O_NOINHERIT, which Windows has) on some codepaths.
^ permalink raw reply
* Re: [PATCH v3 2/3] sha1_file: open window into packfiles with O_CLOEXEC
From: Linus Torvalds @ 2016-10-28 17:38 UTC (permalink / raw)
To: Junio C Hamano
Cc: Johannes Schindelin, Jeff King, Git Mailing List, Lars Schneider,
Eric Wong
In-Reply-To: <xmqqshrg1ksv.fsf@gitster.mtv.corp.google.com>
On Fri, Oct 28, 2016 at 9:48 AM, Junio C Hamano <gitster@pobox.com> wrote:
>
> Excuse me, but care to elaborate a bit more?
It just seems entirely pointless to change the games with O_xyz.
> Setting FD_CLOEXEC with fcntl(2) may be racy, but in what way
> it is broken to open(2) with O_CLOEXEC?
Apparently windows doesn't even support it, at least not mingw. So
you'll have to have some supprt for just explicitly closing things at
execve anyway. And if you do that for windows, then what's the point
of using O_CLOEXEC on Linux, and having two totally different paths
that will just mean maintenance headache.
In contrast, O_NOATIME isn't a maintenance problem, since it's purely
an optimization and has no semantic difference, so it not existing on
some platform is immaterial.
End result: leave O_NOATIME as it is (working), and just forget about O_CLOEXEC.
I have no actual idea about mingw support for this, but Johannes'
email certainly implies it's painful on Windows. Some googling also
shows people doing things like
#ifdef O_CLOEXEC
flags |= O_CLOEXEC;
#endif
or
#ifndef O_CLOEXEC
#define O_CLOEXEC 0
#endif
so O_CLOEXEC definitely isn't considered portable. Do you really want
to rely on it?
Linus
^ permalink raw reply
* Re: [PATCH] attr: convert to new threadsafe API
From: Junio C Hamano @ 2016-10-28 17:30 UTC (permalink / raw)
To: Stefan Beller; +Cc: git, bmwill, pclouds, Johannes.Schindelin, j6t, peff, simon
In-Reply-To: <xmqqinsc1jcg.fsf@gitster.mtv.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
>> + if (check)
>> + return; /* already done */
>> check = git_attr_check_alloc();
>> while (*argv) {
>> struct git_attr *attr = git_attr(*argv);
>> git_attr_check_append(check, attr);
I thought you made git_attr() constructor unavailable, so
check_append() would just get a "const char *" instead?
>> argv++;
>> }
>> + struct git_attr_result *result = git_attr_result_alloc(check);
>
> This does not look like thread-safe.
>
> I could understand it if the calling convention were like this,
> though:
>
> if (git_attr_check_alloc(&check)) {
> while (*argv) {
> ... append ...
> }
> git_attr_check_finished_appending(&check);
> }
> result = result_alloc();
>
> In this variant, git_attr_check_alloc() is responsible for ensuring
> that the "check" is allocated only once just like _initl() is, and
> at the same time, it makes simultanous callers wait until the first
> caller who appends to the singleton check instance declares that it
> finished appending. The return value signals if you are the first
> caller (who is responsible for populating the check and for
> declaring the check is ready to use at the end of appending).
> Everybody else waits while the first caller is doing the if (...) {
> } thing, and then receives false, at which time everybody (including
> the first caller) goes on and allocating its own result and start
> making queries.
Having said that, how flexible does the "alloc then append" side of
API have to be in the envisioned set of callers? Is it expected
that it wouldn't be too hard to arrange them so that they have an
array of "const char *"s when they need to initialize/populate a
check? If that is the case, instead of the "alloc and have others
wait" illustrated above, it may be a lot simpler to give _initv()
variant to them and be done with it, i.e. the above sample caller
would become just:
git_attr_check_initv(&check, argv);
result = git_attr_result_alloc(&check);
would that be too limiting? The use of "alloc then append" pattern
in "git check-attr" done in your patch seems to fit the _initv()
well, and the "pathspec with attr match" that appears later in the
series also has all the attributes it needs to query available by
the time it wants to allocate and append to create an instance of
"check", I would think, so the _initv() might be sufficient as a
public API.
^ permalink raw reply
* Re: [RFC PATCH 0/5] recursively grep across submodules
From: Junio C Hamano @ 2016-10-28 17:21 UTC (permalink / raw)
To: Brandon Williams; +Cc: git
In-Reply-To: <20161028170213.GA72114@google.com>
Brandon Williams <bmwill@google.com> writes:
>> Just a few brief comments, before reading the patches carefully.
>>
>> * It is somewhat surprising that [1/5] is even needed (in other
>> words, I would have expected something like this to be already
>> there, and my knee-jerk reaction was "Heh, how does 'git status'
>> know how to show submodules that are and are not initialized
>> differently without this?"
>
> Yeah I was also surprised to find that this kind of functionality didn't
> already exist. Though I guess there are still many builtin's that don't
> play nice with submodules so maybe this kind of functionality just
> wasn't needed until now.
>
>> * It is somewhat surprising that [4/5] does not even use the
>> previous ls-files to find out the paths.
>
> The first attempt I made at this series used ls-files to produce a list
> of files which was then fed to the grep machinery. The problem I found
> with this approach was when I started moving to work on grepping
> history, at that point it seemed to make more sense to have a process
> for each submodule.
Yup, that makes sense to me.
^ permalink raw reply
* Re: [PATCH] attr: convert to new threadsafe API
From: Junio C Hamano @ 2016-10-28 17:20 UTC (permalink / raw)
To: Stefan Beller; +Cc: git, bmwill, pclouds, Johannes.Schindelin, j6t, peff, simon
In-Reply-To: <20161027221550.14930-1-sbeller@google.com>
Stefan Beller <sbeller@google.com> writes:
> +* Prepare a `struct git_attr_check` using `git_attr_check_initl()`
> function, enumerating the names of attributes whose values you are
> interested in, terminated with a NULL pointer. Alternatively, an
> - empty `struct git_attr_check` can be prepared by calling
> - `git_attr_check_alloc()` function and then attributes you want to
> - ask about can be added to it with `git_attr_check_append()`
> - function.
> -
> -* Call `git_check_attr()` to check the attributes for the path.
> -
> -* Inspect `git_attr_check` structure to see how each of the
> - attribute in the array is defined for the path.
> -
> + empty `struct git_attr_check` as allocated by git_attr_check_alloc()
Need to drop "as allocated by git_attr_check_alloc()" here.
> + can be prepared by calling `git_attr_check_alloc()` function and
> + then attributes you want to ask about can be added to it with
> + `git_attr_check_append()` function.
> + Both ways with `git_attr_check_initl()` as well as the
> + alloc and append route are thread safe, i.e. you can call it
> + from different threads at the same time; when check determines
> + the initialization is still needed, the threads will use a
> + single global mutex to perform the initialization just once, the
> + others will wait on the the thread to actually perform the
> + initialization.
I have some comments on the example in the doc on the "alloc-append"
side. _initl() side looks OK.
> + static struct git_attr_check *check;
> + git_attr_check_initl(&check, "crlf", "ident", NULL);
OK.
> const char *path;
> + struct git_attr_result result[2];
>
> + git_check_attr(path, check, result);
OK. The above two may be easier to understand if they were a single
example, though.
> +. Act on `result.value[]`:
>
> ------------
> - const char *value = check->check[0].value;
> + const char *value = result.value[0];
OK.
> @@ -123,12 +135,15 @@ the first step in the above would be different.
> static struct git_attr_check *check;
> static void setup_check(const char **argv)
> {
> + if (check)
> + return; /* already done */
> check = git_attr_check_alloc();
> while (*argv) {
> struct git_attr *attr = git_attr(*argv);
> git_attr_check_append(check, attr);
> argv++;
> }
> + struct git_attr_result *result = git_attr_result_alloc(check);
This does not look like thread-safe.
I could understand it if the calling convention were like this,
though:
if (git_attr_check_alloc(&check)) {
while (*argv) {
... append ...
}
git_attr_check_finished_appending(&check);
}
result = result_alloc();
In this variant, git_attr_check_alloc() is responsible for ensuring
that the "check" is allocated only once just like _initl() is, and
at the same time, it makes simultanous callers wait until the first
caller who appends to the singleton check instance declares that it
finished appending. The return value signals if you are the first
caller (who is responsible for populating the check and for
declaring the check is ready to use at the end of appending).
Everybody else waits while the first caller is doing the if (...) {
} thing, and then receives false, at which time everybody (including
the first caller) goes on and allocating its own result and start
making queries.
> +* Setup a local variables for the question
> + `struct git_attr_check` as well as a pointer where the result
> + `struct git_attr_result` will be stored. Both should be initialized
> + to NULL.
> +
> +------------
> + struct git_attr_check *check = NULL;
> + struct git_attr_result *result = NULL;
> +------------
> +
> +* Call `git_all_attrs()`.
>
> +------------
> + git_all_attrs(full_path, &check, &result);
> +------------
OK.
Thanks.
^ permalink raw reply
* Re: [RFC PATCH 0/5] recursively grep across submodules
From: Brandon Williams @ 2016-10-28 17:02 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <xmqqk2ct4bmr.fsf@gitster.mtv.corp.google.com>
On 10/27, Junio C Hamano wrote:
> Brandon Williams <bmwill@google.com> writes:
>
> > As for the rest of the series, it should be ready for review or comments.
>
> Just a few brief comments, before reading the patches carefully.
>
> * It is somewhat surprising that [1/5] is even needed (in other
> words, I would have expected something like this to be already
> there, and my knee-jerk reaction was "Heh, how does 'git status'
> know how to show submodules that are and are not initialized
> differently without this?"
Yeah I was also surprised to find that this kind of functionality didn't
already exist. Though I guess there are still many builtin's that don't
play nice with submodules so maybe this kind of functionality just
wasn't needed until now.
> * It is somewhat surprising that [4/5] does not even use the
> previous ls-files to find out the paths.
The first attempt I made at this series used ls-files to produce a list
of files which was then fed to the grep machinery. The problem I found
with this approach was when I started moving to work on grepping
history, at that point it seemed to make more sense to have a process
for each submodule.
--
Brandon Williams
^ permalink raw reply
* Re: [PATCH v3 2/3] sha1_file: open window into packfiles with O_CLOEXEC
From: Junio C Hamano @ 2016-10-28 16:48 UTC (permalink / raw)
To: Linus Torvalds
Cc: Johannes Schindelin, Jeff King, Git Mailing List, Lars Schneider,
Eric Wong
In-Reply-To: <CA+55aFw93vkraxBvFCXFSYJqn836tXW+OCOFuToN+HaxTcJ7cg@mail.gmail.com>
Linus Torvalds <torvalds@linux-foundation.org> writes:
> On Fri, Oct 28, 2016 at 4:11 AM, Johannes Schindelin
> <Johannes.Schindelin@gmx.de> wrote:
>>
>> You guys. I mean: You guys! You sure make my life hard. A brief look at
>> mingw.h could have answered your implicit question:
>
> So here's what you guys should do:
>
> - leave O_NOATIME damn well alone. It works. It has worked for 10+
> years. Stop arguing against it, people who do.
>
> - get rid of all O_CLOEXEC games. They don't work. If you want to
> close file descriptors at execve(), you - gasp - close the file
> descriptor before doing an execve.
>
> So O_CLOEXEC or FD_CLOEXEC is broken.
>
> DO NOT BREAK O_NOATIME JUST TO ADD COMPLETELY NEW BREAKAGE.
Excuse me, but care to elaborate a bit more?
Did I botch the way I ask fcntl(2) to set O_NOATIME in *1*? Its
follow-up in *2* is optional and as peff said in *3*, I do not think
we mind dropping that step and keeping O_NOATIME. It is not that
much code to keep.
Setting FD_CLOEXEC with fcntl(2) may be racy, but in what way
it is broken to open(2) with O_CLOEXEC?
If we want to close file descriptors we opened at execve() time
ourselves, we'd need to somehow keep track of which file descriptors
are meant to be closed upon execve() time, and one way to mark that
may be to use O_CLOEXEC, but once we mark a file descriptor with the
bit, execve() would take care of "closing" it for us---wouldn't that
be the whole point of that bit?
*1* http://public-inbox.org/git/xmqqh97w38gj.fsf@gitster.mtv.corp.google.com
*2* http://public-inbox.org/git/xmqqd1ik38f4.fsf@gitster.mtv.corp.google.com
*3* http://public-inbox.org/git/20161028075104.la24zydnr3ogb6qv@sigill.intra.peff.net
^ permalink raw reply
* Re: [RFC PATCH 0/5] recursively grep across submodules
From: Philip Oakley @ 2016-10-28 15:06 UTC (permalink / raw)
To: Junio C Hamano, Stefan Beller; +Cc: Brandon Williams, Git List
In-Reply-To: <xmqq1sz1425w.fsf@gitster.mtv.corp.google.com>
From: "Junio C Hamano" <gitster@pobox.com>
>
> I hate it when people become overly defensive and start making
> excuses when given harmless observations.
>
Hi Junio,
It can sometimes be difficult for readers to appreciate which way comments
are meant to be interpreted, especially as one cannot usually 'see' the
issue being raised with one's personal work, no matter who writes them. I
too have to supportively review the work of others (as a volunteer), who
then don't always respond or understand, as hoped, and it can be
frustrating.
It can be very hard to write a reasonable write up that gets the balance
between being on the one hand patronising (e.g. over-explained) and on the
other too terse, and yet still not be too nuanced that the points are
missed. The responder has the similar problem, especially if they have
misunderstood the comment, and then end up just end up digging the hole
deeper by over-explaining their position. Extricating the discussion from
the trap can be tricky.
Thank you for your reviews.
--
Philip
^ permalink raw reply
* Re: [PATCH] compat: Allow static initializer for pthreads on Windows
From: Philip Oakley @ 2016-10-28 13:01 UTC (permalink / raw)
To: Jacob Keller, Johannes Sixt
Cc: Stefan Beller, Junio C Hamano, Johannes Schindelin, git,
Simon Ruderich, Jeff King
In-Reply-To: <2ddca5e3-3c4d-b555-4309-a180ceed581e@kdbg.org>
From: "Johannes Sixt" <j6t@kdbg.org>
>
> One point is that the DCLP idiom must be implemented correctly. There are
> solutions, of course, and when the initialization is over, we have a
> miniscule overhead at each pthread_mutex_lock call.
>
I had to look up DCLP ( = Double Checked Locking Patterns), and found a good
write up on the issues..
http://www.aristeia.com/Papers/DDJ_Jul_Aug_2004_revised.pdf "C++ and the
Perils of Double-Checked Locking", which include 'C' issues, and
multi-thread, multi-processor issues. Not an easy issue when fighting
optimisers..
--
Philip
^ permalink raw reply
* Re: feature request
From: Philip Oakley @ 2016-10-28 12:54 UTC (permalink / raw)
To: David Lang, John Rood; +Cc: Stefan Beller, Git List
In-Reply-To: <alpine.DEB.2.02.1610271623260.4123@nftneq.ynat.uz>
From: "David Lang" <david@lang.hm>
> On Thu, 27 Oct 2016, John Rood wrote:
>
>> Thanks, I think changing the default for windows is a good idea.
>
> notepad doesn't work well with unix line endings, wordpad handles the
> files much more cleanly.
>
> David Lang
>
Notepad++ does work well, but isn't a standard part of Windows.
[core]
editor = 'C:/Program
Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noplugin
.. is one of the standard StackOverflow recipes.
--
Philip
^ permalink raw reply
* Re: [PATCH v3 2/3] sha1_file: open window into packfiles with O_CLOEXEC
From: Linus Torvalds @ 2016-10-28 16:13 UTC (permalink / raw)
To: Johannes Schindelin
Cc: Junio C Hamano, Jeff King, Git Mailing List, Lars Schneider,
Eric Wong
In-Reply-To: <alpine.DEB.2.20.1610281306320.3264@virtualbox>
On Fri, Oct 28, 2016 at 4:11 AM, Johannes Schindelin
<Johannes.Schindelin@gmx.de> wrote:
>
> You guys. I mean: You guys! You sure make my life hard. A brief look at
> mingw.h could have answered your implicit question:
So here's what you guys should do:
- leave O_NOATIME damn well alone. It works. It has worked for 10+
years. Stop arguing against it, people who do.
- get rid of all O_CLOEXEC games. They don't work. If you want to
close file descriptors at execve(), you - gasp - close the file
descriptor before doing an execve.
So O_CLOEXEC or FD_CLOEXEC is broken.
DO NOT BREAK O_NOATIME JUST TO ADD COMPLETELY NEW BREAKAGE.
Linus
^ permalink raw reply
* Re: [PATCH] Fix typo in 2.11.0 RelNotes
From: Henrik Ahlgren @ 2016-10-28 15:33 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <xmqqoa2439sp.fsf@gitster.mtv.corp.google.com>
On Fri, 2016-10-28 at 06:03 -0700, Junio C Hamano wrote:
> If the original text were like the following, would it have been
> clear enough that prevented you from sending your patch?
>
> * An empty string used as a pathspec element has always meant
> 'everything matches', but it is too easy to write a script that
> finds a path to remove in $path and run 'git rm "$paht"' by
> mistake (when the user meant to give "$path"), which ends up
> removing everything. This release starts warning about the
> use of an empty string that is used for 'everything matches' and
> asks users to use a more explicit '.' for that instead.
Oops. Yes, but not sure if it really needs to be clear enough even for
idiots like me. :-) Sorry.
^ permalink raw reply
* Re: [PATCH] Documenation: fmt-merge-msg: fix markup in example
From: Junio C Hamano @ 2016-10-28 15:15 UTC (permalink / raw)
To: Jeff King; +Cc: Stefan Christ, git
In-Reply-To: <20161028110820.a46ttxjicq2k5xdk@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
> On Fri, Oct 28, 2016 at 12:01:26PM +0200, Stefan Christ wrote:
>
>> diff --git a/Documentation/git-fmt-merge-msg.txt b/Documentation/git-fmt-merge-msg.txt
>> index 6526b17..44892c4 100644
>> --- a/Documentation/git-fmt-merge-msg.txt
>> +++ b/Documentation/git-fmt-merge-msg.txt
>> @@ -60,10 +60,10 @@ merge.summary::
>> EXAMPLE
>> -------
>>
>> ---
>> +---------
>> $ git fetch origin master
>> $ git fmt-merge-msg --log <$GIT_DIR/FETCH_HEAD
>> ---
>> +---------
>
> Thanks. Asciidoc generally requires at least 4 delimiter characters to
> open a delimited block (including a ListingBlock, which is what we want
> here). There is one exception, "--", which is a generic OpenBlock, which
> is just used for grouping, and not any special syntactic meaning (so
> that's why this _didn't_ render the "--", but did render the contents
> without line breaks).
>
> So looks good, modulo the typo in the subject that somebody else pointed
> out.
Thanks, both. I queued with a bit more enhanced log message while
fixing the typo.
-- >8 --
From: Stefan Christ <contact@stefanchrist.eu>
Date: Fri, 28 Oct 2016 12:01:26 +0200
Subject: [PATCH] Documentation/fmt-merge-msg: fix markup in example
Use at least 4 delimiting dashes that are required for
ListingBlock to get this block rendered as verbatim text.
Signed-off-by: Stefan Christ <contact@stefanchrist.eu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
Documentation/git-fmt-merge-msg.txt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Documentation/git-fmt-merge-msg.txt b/Documentation/git-fmt-merge-msg.txt
index 6526b178e8..44892c447e 100644
--- a/Documentation/git-fmt-merge-msg.txt
+++ b/Documentation/git-fmt-merge-msg.txt
@@ -60,10 +60,10 @@ merge.summary::
EXAMPLE
-------
---
+---------
$ git fetch origin master
$ git fmt-merge-msg --log <$GIT_DIR/FETCH_HEAD
---
+---------
Print a log message describing a merge of the "master" branch from
the "origin" remote.
--
2.10.1-791-g404733b9cf
^ permalink raw reply related
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