* Re: [PATCH v3 0/6] recursively grep across submodules
From: Stefan Beller @ 2016-11-15 17:42 UTC (permalink / raw)
To: Brandon Williams; +Cc: git@vger.kernel.org, Jonathan Tan, Junio C Hamano
In-Reply-To: <1478908273-190166-1-git-send-email-bmwill@google.com>
coverity seems to dislike this part:
*** CID 1394367: Null pointer dereferences (NULL_RETURNS)
/builtin/grep.c: 625 in grep_submodule()
619 is_submodule_populated(path))) {
620 /*
621 * If searching history, check for the presense of the
622 * submodule's gitdir before skipping the submodule.
623 */
624 if (sha1) {
>>> CID 1394367: Null pointer dereferences (NULL_RETURNS)
>>> Dereferencing a null pointer "submodule_from_path(null_sha1, path)".
625 path = git_path("modules/%s",
626
submodule_from_path(null_sha1, path)->name);
627
628 if (!(is_directory(path) &&
is_git_directory(path)))
629 return 0;
630 } else {
^ permalink raw reply
* Re: [PATCH v7 13/17] ref-filter: add `:dir` and `:base` options for ref printing atoms
From: Junio C Hamano @ 2016-11-15 17:42 UTC (permalink / raw)
To: Jacob Keller; +Cc: Karthik Nayak, Git mailing list
In-Reply-To: <CA+P7+xo6OqcpLZ7v_m1EPm85eK2xCPD_LCw1Ly2RSPeSC0Ei7g@mail.gmail.com>
Jacob Keller <jacob.keller@gmail.com> writes:
> dirname makes sense. What about implementing a reverse variant of
> strip, which you could perform stripping of right-most components and
> instead of stripping by a number, strip "to" a number, ie: keep the
> left N most components, and then you could use something like
> ...
> I think that would be more general purpose than basename, and less confusing?
I think you are going in the right direction. I had a similar
thought but built around a different axis. I.e. if strip=1 strips
one from the left, perhaps we want to have rstrip=1 that strips one
from the right, and also strip=-1 to mean strip everything except
one from the left and so on?. I think this and your keep (and
perhaps you'll have rkeep for completeness) have the same expressive
power. I do not offhand have a preference one over the other.
Somehow it sounds a bit strange to me to treat 'remotes' as the same
class of token as 'heads' and 'tags' (I'd expect 'heads' and
'remotes/origin' would be at the same level in end-user's mind), but
that is probably an unrelated tangent. The reason this series wants
to introduce :base must be to emulate an existing feature, so that
existing feature is a concrete counter-example that argues against
my "it sounds a bit strange" reaction.
^ permalink raw reply
* Re: Protecting old temporary objects being reused from concurrent "git gc"?
From: Jeff King @ 2016-11-15 17:40 UTC (permalink / raw)
To: Matt McCutchen; +Cc: git
In-Reply-To: <1479231184.2406.88.camel@mattmccutchen.net>
On Tue, Nov 15, 2016 at 12:33:04PM -0500, Matt McCutchen wrote:
> On Tue, 2016-11-15 at 12:06 -0500, Jeff King wrote:
> > - when an object write is optimized out because we already have the
> > object, git will update the mtime on the file (loose object or
> > packfile) to freshen it
>
> FWIW, I am not seeing this happen when I do "git read-tree --prefix"
> followed by "git write-tree" using the current master (3ab2281). See
> the attached test script.
The optimization I'm thinking about is the one from write_sha1_file(),
which learned to freshen in 33d4221c7 (write_sha1_file: freshen existing
objects, 2014-10-15).
I suspect the issue is that read-tree populates the cache-tree index
extension, and then write-tree omits the object write before it even
gets to write_sha1_file(). The solution is that it should probably be
calling one of the freshen() functions (possibly just replacing
has_sha1_file() with check_and_freshen(), but I haven't looked).
I'd definitely welcome patches in this area.
> OK. I'll write a patch to add a summary of this information to the
> git-gc man page.
Sounds like a good idea. Thanks.
-Peff
^ permalink raw reply
* Re: Protecting old temporary objects being reused from concurrent "git gc"?
From: Matt McCutchen @ 2016-11-15 17:33 UTC (permalink / raw)
To: Jeff King; +Cc: git
In-Reply-To: <20161115170634.ichqrqbhmpv2dsiw@sigill.intra.peff.net>
[-- Attachment #1: Type: text/plain, Size: 1349 bytes --]
On Tue, 2016-11-15 at 12:06 -0500, Jeff King wrote:
> - when an object write is optimized out because we already have the
> object, git will update the mtime on the file (loose object or
> packfile) to freshen it
FWIW, I am not seeing this happen when I do "git read-tree --prefix"
followed by "git write-tree" using the current master (3ab2281). See
the attached test script.
> If you have long-running data (like, a temporary index file that might
> literally sit around for days or weeks) I think that is a potential
> problem. And the solution is probably to use refs in some way to point
> to your objects.
Agreed. This is not my current scenario.
> If you're worried about a short-term operation where
> somebody happens to run git-gc concurrently, I agree it's a possible
> problem, but I suspect something you can ignore in practice.
>
> For the most part, a lot of the client-side git tools assume that one
> operation is happening at a time in the repository. And I think that
> largely holds for a developer working on a single clone, and things just
> work in practice.
>
> Auto-gc makes that a little sketchier, but historically does not seem to
> have really caused problems in practice.
OK. I'll write a patch to add a summary of this information to the
git-gc man page.
Matt
[-- Attachment #2: test-git-read-tree-write-tree-touch-object.sh --]
[-- Type: application/x-shellscript, Size: 502 bytes --]
^ permalink raw reply
* Re: [PATCH 1/2] push: --dry-run updates submodules when --recurse-submodules=on-demand
From: Brandon Williams @ 2016-11-15 17:29 UTC (permalink / raw)
To: Johannes Sixt; +Cc: git
In-Reply-To: <4a72ad14-0a8f-ede9-9f54-601fcd37740b@kdbg.org>
On 11/15, Johannes Sixt wrote:
> Am 15.11.2016 um 02:18 schrieb Brandon Williams:
> >diff --git a/t/t5531-deep-submodule-push.sh b/t/t5531-deep-submodule-push.sh
> >index 198ce84..e6ccc30 100755
> >--- a/t/t5531-deep-submodule-push.sh
> >+++ b/t/t5531-deep-submodule-push.sh
> >@@ -427,7 +427,31 @@ test_expect_success 'push unpushable submodule recursively fails' '
> > cd submodule.git &&
> > git rev-parse master >../actual
> > ) &&
> >- test_cmp expected actual
> >+ test_cmp expected actual &&
> >+ git -C work reset --hard master^
>
> This line looks like a clean-up to be done after the test case. You
> should wrap it in test_when_finished, but outside of a sub-shell,
> which looks like it's just one line earlier, before the test_cmp.
K will do.
>
> >+'
> >+
> >+test_expect_failure 'push --dry-run does not recursively update submodules' '
> >+ (
> >+ cd work &&
> >+ (
> >+ cd gar/bage &&
> >+ git checkout master &&
> >+ git rev-parse master >../../../expected_submodule &&
> >+ > junk9 &&
> >+ git add junk9 &&
> >+ git commit -m "Ninth junk"
> >+ ) &&
>
> Could you please avoid this nested sub-shell? It is fine to cd
> around when you are in a sub-shell.
Yes I can reorganize it to avoid the nested sub-shells. I was just
trying to follow the organization of the other tests in the same file.
>
> >+ git checkout master &&
> >+ git rev-parse master >../expected_pub
>
> Broken && chain.
>
> >+ git add gar/bage &&
> >+ git commit -m "Ninth commit for gar/bage" &&
> >+ git push --dry-run --recurse-submodules=on-demand ../pub.git master
> >+ ) &&
> >+ git -C submodule.git rev-parse master >actual_submodule &&
> >+ git -C pub.git rev-parse master >actual_pub &&
>
> All of the commands above are 'git something' that could become 'git
> -C work something' and then the sub-shell would be unnecessary. I'm
> not sure I would appreciate the verbosity of the result, though.
> (Perhaps aligning the git subcommands after -C foo would help.)
I'll play around with it and try to make it look pretty while trying to
avoid sub-shells. I'm assuming the reason we want to avoid sub-shells is
for performance reasons right?
--
Brandon Williams
^ permalink raw reply
* Re: Protecting old temporary objects being reused from concurrent "git gc"?
From: Jeff King @ 2016-11-15 17:06 UTC (permalink / raw)
To: Matt McCutchen; +Cc: git
In-Reply-To: <1479219194.2406.73.camel@mattmccutchen.net>
On Tue, Nov 15, 2016 at 09:13:14AM -0500, Matt McCutchen wrote:
> I want to change this to something that won't leave an inconsistent
> state if interrupted. I've written code for this kind of thing before
> that sets GIT_INDEX_FILE and uses a temporary index file and "git
> write-tree". But I realized that if "git gc" runs concurrently, the
> generated tree could be deleted before it is used and the tool would
> fail. If I had a need to run "git commit-tree", it seems like I might
> even end up with a commit object with a broken reference to a tree.
> "git gc" normally doesn't delete objects that were created in the last
> 2 weeks, but if an identical tree was added to the object database more
> than 2 weeks ago by another operation and is unreferenced, it could be
> reused without updating its mtime and it could still get deleted.
Modern versions of git do two things to help with this:
- any object which is referenced by a "recent" object (within the 2
weeks) is also considered recent. So if you create a new commit
object that points to a tree, even before you reference the commit
that tree is protected
- when an object write is optimized out because we already have the
object, git will update the mtime on the file (loose object or
packfile) to freshen it
This isn't perfect, though. You can decide to reference an existing
object just as it is being deleted. And the pruning process itself is
not atomic (and it's tricky to make it so, just because of what we're
promised by the filesystem).
> Is there a recommended way to avoid this kind of problem in add-on
> tools? (I searched the Git documentation and the web for information
> about races with "git gc" and didn't find anything useful.) If not, it
> seems to be a significant design flaw in "git gc", even if the problem
> is extremely rare in practice. I wonder if some of the built-in
> commands may have the same problem, though I haven't tried to test
> them. If this is confirmed to be a known problem affecting built-in
> commands, then at least I won't feel bad about introducing the
> same problem into add-on tools. :/
If you have long-running data (like, a temporary index file that might
literally sit around for days or weeks) I think that is a potential
problem. And the solution is probably to use refs in some way to point
to your objects. If you're worried about a short-term operation where
somebody happens to run git-gc concurrently, I agree it's a possible
problem, but I suspect something you can ignore in practice.
For the most part, a lot of the client-side git tools assume that one
operation is happening at a time in the repository. And I think that
largely holds for a developer working on a single clone, and things just
work in practice.
Auto-gc makes that a little sketchier, but historically does not seem to
have really caused problems in practice.
For a busy multi-user server, I recommend turning off auto-gc entirely,
and repacking manually with "-k" to be on the safe side.
-Peff
^ permalink raw reply
* Re: [PATCH] t0021, t5615: use $PWD instead of $(pwd) in PATH-like shell variables
From: Johannes Schindelin @ 2016-11-15 16:54 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Lars Schneider, Johannes Sixt, git, Jeff King
In-Reply-To: <xmqqshqux9il.fsf@gitster.mtv.corp.google.com>
Hi Junio,
On Mon, 14 Nov 2016, Junio C Hamano wrote:
> Dscho's mention of 'still times out' may be an indiciation that
> something unspecified on 'pu' is not ready to be merged to 'next',
> but blocking all of 'pu' with a blanket statement is not useful,
> and that was where my response comes from.
Until the time when the test suite takes less than the insane three hours
to run, I am afraid that a blanket statement on `pu` is the best I can do.
Ciao,
Johannes
^ permalink raw reply
* gitweb html validation
From: Raphaël Gertz @ 2016-11-15 15:13 UTC (permalink / raw)
To: git
Hi,
There a small bug in gitweb html validation, you need the following
patch to pass w3c check with searchbox enabled.
The problem lies in the input directly embed inside a form without a
wrapper which is not valid.
Best regards
The following patch fix the issue for git-2.10.2 :
--- /usr/share/gitweb/gitweb.cgi.orig 2016-11-15 15:37:21.149805026
+0100
+++ /usr/share/gitweb/gitweb.cgi 2016-11-15 15:37:48.579240429
+0100
@@ -5518,6 +5518,7 @@ sub git_project_search_form {
print "<div class=\"projsearch\">\n";
print $cgi->start_form(-method => 'get', -action => $my_uri) .
+ '<div>'.
$cgi->hidden(-name => 'a', -value => 'project_list') .
"\n";
print $cgi->hidden(-name => 'pf', -value => $project_filter).
"\n"
if (defined $project_filter);
@@ -5529,6 +5530,7 @@ sub git_project_search_form {
-checked => $search_use_regexp) .
"</span>\n" .
$cgi->submit(-name => 'btnS', -value => 'Search') .
+ '</div>'.
$cgi->end_form() . "\n" .
$cgi->a({-href => href(project => undef, searchtext =>
undef,
project_filter =>
$project_filter)},
^ permalink raw reply
* RE: [PATCH] remote-curl: don't hang when a server dies before any output
From: David Turner @ 2016-11-15 15:45 UTC (permalink / raw)
To: 'Jeff King'; +Cc: git@vger.kernel.org, spearce@spearce.org
In-Reply-To: <20161114234847.2nexsgedpg7zvrr5@sigill.intra.peff.net>
> -----Original Message-----
> From: Jeff King [mailto:peff@peff.net]
...
> I'll make that change and then try to wrap this up with a commit message.
> I plan to steal your tests, if that's OK.
Please do!
^ permalink raw reply
* Re: New to git, need help!
From: Pranit Bauva @ 2016-11-15 15:43 UTC (permalink / raw)
To: Mayank Gupta; +Cc: Git List
In-Reply-To: <CAJNRPQRhyrALj0zdaTxKgwo8j8r8_7ixgX21+C=ue+CGKYgaCg@mail.gmail.com>
Hey Mayank,
On Tue, Nov 15, 2016 at 6:00 PM, Mayank Gupta
<mayankgupta18198@gmail.com> wrote:
> Hi All,
>
> I'm new to open source and have recently joined this mailing list.
> Since I'm new at this, I think I can initially contribute to the
> community by fixing some small bugs or errors but as the documentation
> is too large, I don't know where to start.
> So if anybody could guide me on how to go about it, it would be really
> appreciated.
It is really nice that you want to start contributing. We have a user
documentation[1] and a developer documentation[2]. To contribute to a
feature, firstly you need to learn about that feature. So go through
the man pages of the tool which you would want to work on. The things
that you would be using are documented in the technical documentation.
Apart from this, you can start hunting small errors but I think it
would be difficult in the initial stages. So read this[3] even though
it is specific for GSoC, it is helpful for any new developer. Also you
can search the mailing list archives for "low hanging fruit" to get
things which were thought of but not done or something like that.
[1]: https://github.com/git/git/tree/master/Documentation
[2]: https://github.com/git/git/tree/master/Documentation/technical
[3]: https://git.github.io/SoC-2016-Microprojects/
Hope to see a patch from your side soon! :)
Regards,
Pranit Bauva
^ permalink raw reply
* Re: [PATCH v1 2/2] travis-ci: disable GIT_TEST_HTTPD for macOS
From: Jeff King @ 2016-11-15 15:31 UTC (permalink / raw)
To: Heiko Voigt
Cc: Lars Schneider, Junio C Hamano, Torsten Bögershausen, git,
Eric Sunshine
In-Reply-To: <20161115120718.GA7854@book.hvoigt.net>
On Tue, Nov 15, 2016 at 01:07:18PM +0100, Heiko Voigt wrote:
> On Fri, Nov 11, 2016 at 09:22:51AM +0100, Lars Schneider wrote:
> > To all macOS users on the list:
> > Does anyone execute the tests with GIT_TEST_HTTPD enabled successfully?
>
> Nope. The following tests fail for me on master: 5539, 5540, 5541, 5542,
> 5550, 5551, 5561, 5812.
Failing how? Does apache fail to start up? Do tests fails? What does
"-v" say? Is there anything interesting in httpd/error.log in the trash
directory?
-Peff
^ permalink raw reply
* Re: Git status takes too long- How to improve the performance of git
From: Heiko Voigt @ 2016-11-15 15:10 UTC (permalink / raw)
To: ravalika; +Cc: git
In-Reply-To: <1479202392275-7657456.post@n2.nabble.com>
On Tue, Nov 15, 2016 at 02:33:12AM -0700, ravalika wrote:
> Number of files - 63883
Since you also posted this to the "Git for Windows" mailinglist I assume
that you are using Windows. Reduce the number of files. For example
split the repository into two one for documentation and one for source.
Thats what I did with a converted repository that had to many files.
Windows is unfortunately very slow when it comes to handling many files
and if I recall correctly ~30000 files was in a nicely handleable range
for a Git repository on Windows, but that might have changed...
Cheers Heiko
^ permalink raw reply
* [PATCH v3 4/4] submodule_needs_pushing() NEEDSWORK when we can not answer this question
From: Heiko Voigt @ 2016-11-15 14:56 UTC (permalink / raw)
To: Junio C Hamano
Cc: git, Jeff King, Stefan Beller, Jens.Lehmann, Fredrik Gustafsson,
Leandro Lucarella
In-Reply-To: <cover.1479221071.git.hvoigt@hvoigt.net>
Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
---
submodule.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/submodule.c b/submodule.c
index e1196fd..29efee9 100644
--- a/submodule.c
+++ b/submodule.c
@@ -531,6 +531,14 @@ static int submodule_has_commits(const char *path, struct sha1_array *commits)
static int submodule_needs_pushing(const char *path, struct sha1_array *commits)
{
if (!submodule_has_commits(path, commits))
+ /* NEEDSWORK: The correct answer here is "We do not
+ * know" instead of "No push needed". We currently
+ * proceed pushing here as if the submodules commits are
+ * available on a remote. Since we can not check the
+ * remote availability for this submodule we should
+ * consider changing this behavior to: Stop here and
+ * tell the user how to skip this check if wanted.
+ */
return 0;
if (for_each_remote_ref_submodule(path, has_remote, NULL) > 0) {
--
2.10.1.386.gc503e45
^ permalink raw reply related
* [PATCH v3 1/4] serialize collection of changed submodules
From: Heiko Voigt @ 2016-11-15 14:56 UTC (permalink / raw)
To: Junio C Hamano
Cc: git, Jeff King, Stefan Beller, Jens.Lehmann, Fredrik Gustafsson,
Leandro Lucarella
In-Reply-To: <cover.1479221071.git.hvoigt@hvoigt.net>
To check whether a submodule needs to be pushed we need to collect all
changed submodules. Lets collect them first and then execute the
possibly expensive test whether certain revisions are already pushed
only once per submodule.
There is further potential for optimization since we can assemble one
command and only issued that instead of one call for each remote ref in
the submodule.
Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
---
submodule.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 56 insertions(+), 4 deletions(-)
diff --git a/submodule.c b/submodule.c
index 6f7d883..b91585e 100644
--- a/submodule.c
+++ b/submodule.c
@@ -532,19 +532,34 @@ static int submodule_needs_pushing(const char *path, const unsigned char sha1[20
return 0;
}
+static struct sha1_array *submodule_commits(struct string_list *submodules,
+ const char *path)
+{
+ struct string_list_item *item;
+
+ item = string_list_insert(submodules, path);
+ if (item->util)
+ return (struct sha1_array *) item->util;
+
+ /* NEEDSWORK: should we have sha1_array_init()? */
+ item->util = xcalloc(1, sizeof(struct sha1_array));
+ return (struct sha1_array *) item->util;
+}
+
static void collect_submodules_from_diff(struct diff_queue_struct *q,
struct diff_options *options,
void *data)
{
int i;
- struct string_list *needs_pushing = data;
+ struct string_list *submodules = data;
for (i = 0; i < q->nr; i++) {
struct diff_filepair *p = q->queue[i];
+ struct sha1_array *commits;
if (!S_ISGITLINK(p->two->mode))
continue;
- if (submodule_needs_pushing(p->two->path, p->two->oid.hash))
- string_list_insert(needs_pushing, p->two->path);
+ commits = submodule_commits(submodules, p->two->path);
+ sha1_array_append(commits, p->two->oid.hash);
}
}
@@ -560,6 +575,31 @@ static void find_unpushed_submodule_commits(struct commit *commit,
diff_tree_combined_merge(commit, 1, &rev);
}
+struct collect_submodule_from_sha1s_data {
+ char *submodule_path;
+ struct string_list *needs_pushing;
+};
+
+static int collect_submodules_from_sha1s(const unsigned char sha1[20],
+ void *data)
+{
+ struct collect_submodule_from_sha1s_data *me =
+ (struct collect_submodule_from_sha1s_data *) data;
+
+ if (submodule_needs_pushing(me->submodule_path, sha1))
+ string_list_insert(me->needs_pushing, me->submodule_path);
+
+ return 0;
+}
+
+static void free_submodules_sha1s(struct string_list *submodules)
+{
+ struct string_list_item *item;
+ for_each_string_list_item(item, submodules)
+ sha1_array_clear((struct sha1_array *) item->util);
+ string_list_clear(submodules, 1);
+}
+
int find_unpushed_submodules(unsigned char new_sha1[20],
const char *remotes_name, struct string_list *needs_pushing)
{
@@ -568,6 +608,8 @@ int find_unpushed_submodules(unsigned char new_sha1[20],
const char *argv[] = {NULL, NULL, "--not", "NULL", NULL};
int argc = ARRAY_SIZE(argv) - 1;
char *sha1_copy;
+ struct string_list submodules = STRING_LIST_INIT_DUP;
+ struct string_list_item *submodule;
struct strbuf remotes_arg = STRBUF_INIT;
@@ -581,12 +623,22 @@ int find_unpushed_submodules(unsigned char new_sha1[20],
die("revision walk setup failed");
while ((commit = get_revision(&rev)) != NULL)
- find_unpushed_submodule_commits(commit, needs_pushing);
+ find_unpushed_submodule_commits(commit, &submodules);
reset_revision_walk();
free(sha1_copy);
strbuf_release(&remotes_arg);
+ for_each_string_list_item(submodule, &submodules) {
+ struct collect_submodule_from_sha1s_data data;
+ data.submodule_path = submodule->string;
+ data.needs_pushing = needs_pushing;
+ sha1_array_for_each_unique((struct sha1_array *) submodule->util,
+ collect_submodules_from_sha1s,
+ &data);
+ }
+ free_submodules_sha1s(&submodules);
+
return needs_pushing->nr;
}
--
2.10.1.386.gc503e45
^ permalink raw reply related
* [PATCH v3 2/4] serialize collection of refs that contain submodule changes
From: Heiko Voigt @ 2016-11-15 14:56 UTC (permalink / raw)
To: Junio C Hamano
Cc: git, Jeff King, Stefan Beller, Jens.Lehmann, Fredrik Gustafsson,
Leandro Lucarella
In-Reply-To: <cover.1479221071.git.hvoigt@hvoigt.net>
We are iterating over each pushed ref and want to check whether it
contains changes to submodules. Instead of immediately checking each ref
lets first collect them and then do the check for all of them in one
revision walk.
Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
---
submodule.c | 35 ++++++++++++++++++++---------------
submodule.h | 5 +++--
transport.c | 29 +++++++++++++++++++++--------
3 files changed, 44 insertions(+), 25 deletions(-)
diff --git a/submodule.c b/submodule.c
index b91585e..769d666 100644
--- a/submodule.c
+++ b/submodule.c
@@ -500,6 +500,13 @@ static int has_remote(const char *refname, const struct object_id *oid,
return 1;
}
+static int append_sha1_to_argv(const unsigned char sha1[20], void *data)
+{
+ struct argv_array *argv = (struct argv_array *) data;
+ argv_array_push(argv, sha1_to_hex(sha1));
+ return 0;
+}
+
static int submodule_needs_pushing(const char *path, const unsigned char sha1[20])
{
if (add_submodule_odb(path) || !lookup_commit_reference(sha1))
@@ -600,25 +607,24 @@ static void free_submodules_sha1s(struct string_list *submodules)
string_list_clear(submodules, 1);
}
-int find_unpushed_submodules(unsigned char new_sha1[20],
+int find_unpushed_submodules(struct sha1_array *commits,
const char *remotes_name, struct string_list *needs_pushing)
{
struct rev_info rev;
struct commit *commit;
- const char *argv[] = {NULL, NULL, "--not", "NULL", NULL};
- int argc = ARRAY_SIZE(argv) - 1;
- char *sha1_copy;
struct string_list submodules = STRING_LIST_INIT_DUP;
struct string_list_item *submodule;
+ struct argv_array argv = ARGV_ARRAY_INIT;
- struct strbuf remotes_arg = STRBUF_INIT;
-
- strbuf_addf(&remotes_arg, "--remotes=%s", remotes_name);
init_revisions(&rev, NULL);
- sha1_copy = xstrdup(sha1_to_hex(new_sha1));
- argv[1] = sha1_copy;
- argv[3] = remotes_arg.buf;
- setup_revisions(argc, argv, &rev, NULL);
+
+ /* argv.argv[0] will be ignored by setup_revisions */
+ argv_array_push(&argv, "find_unpushed_submodules");
+ sha1_array_for_each_unique(commits, append_sha1_to_argv, &argv);
+ argv_array_push(&argv, "--not");
+ argv_array_pushf(&argv, "--remotes=%s", remotes_name);
+
+ setup_revisions(argv.argc, argv.argv, &rev, NULL);
if (prepare_revision_walk(&rev))
die("revision walk setup failed");
@@ -626,8 +632,7 @@ int find_unpushed_submodules(unsigned char new_sha1[20],
find_unpushed_submodule_commits(commit, &submodules);
reset_revision_walk();
- free(sha1_copy);
- strbuf_release(&remotes_arg);
+ argv_array_clear(&argv);
for_each_string_list_item(submodule, &submodules) {
struct collect_submodule_from_sha1s_data data;
@@ -664,12 +669,12 @@ static int push_submodule(const char *path)
return 1;
}
-int push_unpushed_submodules(unsigned char new_sha1[20], const char *remotes_name)
+int push_unpushed_submodules(struct sha1_array *commits, const char *remotes_name)
{
int i, ret = 1;
struct string_list needs_pushing = STRING_LIST_INIT_DUP;
- if (!find_unpushed_submodules(new_sha1, remotes_name, &needs_pushing))
+ if (!find_unpushed_submodules(commits, remotes_name, &needs_pushing))
return 1;
for (i = 0; i < needs_pushing.nr; i++) {
diff --git a/submodule.h b/submodule.h
index d9e197a..9454806 100644
--- a/submodule.h
+++ b/submodule.h
@@ -3,6 +3,7 @@
struct diff_options;
struct argv_array;
+struct sha1_array;
enum {
RECURSE_SUBMODULES_CHECK = -4,
@@ -62,9 +63,9 @@ int submodule_uses_gitfile(const char *path);
int ok_to_remove_submodule(const char *path);
int merge_submodule(unsigned char result[20], const char *path, const unsigned char base[20],
const unsigned char a[20], const unsigned char b[20], int search);
-int find_unpushed_submodules(unsigned char new_sha1[20], const char *remotes_name,
+int find_unpushed_submodules(struct sha1_array *commits, const char *remotes_name,
struct string_list *needs_pushing);
-int push_unpushed_submodules(unsigned char new_sha1[20], const char *remotes_name);
+int push_unpushed_submodules(struct sha1_array *commits, const char *remotes_name);
void connect_work_tree_and_git_dir(const char *work_tree, const char *git_dir);
int parallel_submodules(void);
diff --git a/transport.c b/transport.c
index d57e8de..f482869 100644
--- a/transport.c
+++ b/transport.c
@@ -949,23 +949,36 @@ int transport_push(struct transport *transport,
if ((flags & TRANSPORT_RECURSE_SUBMODULES_ON_DEMAND) && !is_bare_repository()) {
struct ref *ref = remote_refs;
+ struct sha1_array commits = SHA1_ARRAY_INIT;
+
for (; ref; ref = ref->next)
- if (!is_null_oid(&ref->new_oid) &&
- !push_unpushed_submodules(ref->new_oid.hash,
- transport->remote->name))
- die ("Failed to push all needed submodules!");
+ if (!is_null_oid(&ref->new_oid))
+ sha1_array_append(&commits, ref->new_oid.hash);
+
+ if (!push_unpushed_submodules(&commits, transport->remote->name)) {
+ sha1_array_clear(&commits);
+ die("Failed to push all needed submodules!");
+ }
+ sha1_array_clear(&commits);
}
if ((flags & (TRANSPORT_RECURSE_SUBMODULES_ON_DEMAND |
TRANSPORT_RECURSE_SUBMODULES_CHECK)) && !is_bare_repository()) {
struct ref *ref = remote_refs;
struct string_list needs_pushing = STRING_LIST_INIT_DUP;
+ struct sha1_array commits = SHA1_ARRAY_INIT;
for (; ref; ref = ref->next)
- if (!is_null_oid(&ref->new_oid) &&
- find_unpushed_submodules(ref->new_oid.hash,
- transport->remote->name, &needs_pushing))
- die_with_unpushed_submodules(&needs_pushing);
+ if (!is_null_oid(&ref->new_oid))
+ sha1_array_append(&commits, ref->new_oid.hash);
+
+ if (find_unpushed_submodules(&commits, transport->remote->name,
+ &needs_pushing)) {
+ sha1_array_clear(&commits);
+ die_with_unpushed_submodules(&needs_pushing);
+ }
+ string_list_clear(&needs_pushing, 0);
+ sha1_array_clear(&commits);
}
push_ret = transport->push_refs(transport, remote_refs, flags);
--
2.10.1.386.gc503e45
^ permalink raw reply related
* [PATCH v3 3/4] batch check whether submodule needs pushing into one call
From: Heiko Voigt @ 2016-11-15 14:56 UTC (permalink / raw)
To: Junio C Hamano
Cc: git, Jeff King, Stefan Beller, Jens.Lehmann, Fredrik Gustafsson,
Leandro Lucarella
In-Reply-To: <cover.1479221071.git.hvoigt@hvoigt.net>
We run a command for each sha1 change in a submodule. This is
unnecessary since we can simply batch all sha1's we want to check into
one command. Lets do it so we can speedup the check when many submodule
changes are in need of checking.
Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
---
submodule.c | 63 ++++++++++++++++++++++++++++++++-----------------------------
1 file changed, 33 insertions(+), 30 deletions(-)
diff --git a/submodule.c b/submodule.c
index 769d666..e1196fd 100644
--- a/submodule.c
+++ b/submodule.c
@@ -507,27 +507,49 @@ static int append_sha1_to_argv(const unsigned char sha1[20], void *data)
return 0;
}
-static int submodule_needs_pushing(const char *path, const unsigned char sha1[20])
+static int check_has_commit(const unsigned char sha1[20], void *data)
{
- if (add_submodule_odb(path) || !lookup_commit_reference(sha1))
+ int *has_commit = (int *) data;
+
+ if (!lookup_commit_reference(sha1))
+ *has_commit = 0;
+
+ return 0;
+}
+
+static int submodule_has_commits(const char *path, struct sha1_array *commits)
+{
+ int has_commit = 1;
+
+ if (add_submodule_odb(path))
+ return 0;
+
+ sha1_array_for_each_unique(commits, check_has_commit, &has_commit);
+ return has_commit;
+}
+
+static int submodule_needs_pushing(const char *path, struct sha1_array *commits)
+{
+ if (!submodule_has_commits(path, commits))
return 0;
if (for_each_remote_ref_submodule(path, has_remote, NULL) > 0) {
struct child_process cp = CHILD_PROCESS_INIT;
- const char *argv[] = {"rev-list", NULL, "--not", "--remotes", "-n", "1" , NULL};
struct strbuf buf = STRBUF_INIT;
int needs_pushing = 0;
- argv[1] = sha1_to_hex(sha1);
- cp.argv = argv;
+ argv_array_push(&cp.args, "rev-list");
+ sha1_array_for_each_unique(commits, append_sha1_to_argv, &cp.args);
+ argv_array_pushl(&cp.args, "--not", "--remotes", "-n", "1" , NULL);
+
prepare_submodule_repo_env(&cp.env_array);
cp.git_cmd = 1;
cp.no_stdin = 1;
cp.out = -1;
cp.dir = path;
if (start_command(&cp))
- die("Could not run 'git rev-list %s --not --remotes -n 1' command in submodule %s",
- sha1_to_hex(sha1), path);
+ die("Could not run 'git rev-list <commits> --not --remotes -n 1' command in submodule %s",
+ path);
if (strbuf_read(&buf, cp.out, 41))
needs_pushing = 1;
finish_command(&cp);
@@ -582,23 +604,6 @@ static void find_unpushed_submodule_commits(struct commit *commit,
diff_tree_combined_merge(commit, 1, &rev);
}
-struct collect_submodule_from_sha1s_data {
- char *submodule_path;
- struct string_list *needs_pushing;
-};
-
-static int collect_submodules_from_sha1s(const unsigned char sha1[20],
- void *data)
-{
- struct collect_submodule_from_sha1s_data *me =
- (struct collect_submodule_from_sha1s_data *) data;
-
- if (submodule_needs_pushing(me->submodule_path, sha1))
- string_list_insert(me->needs_pushing, me->submodule_path);
-
- return 0;
-}
-
static void free_submodules_sha1s(struct string_list *submodules)
{
struct string_list_item *item;
@@ -635,12 +640,10 @@ int find_unpushed_submodules(struct sha1_array *commits,
argv_array_clear(&argv);
for_each_string_list_item(submodule, &submodules) {
- struct collect_submodule_from_sha1s_data data;
- data.submodule_path = submodule->string;
- data.needs_pushing = needs_pushing;
- sha1_array_for_each_unique((struct sha1_array *) submodule->util,
- collect_submodules_from_sha1s,
- &data);
+ struct sha1_array *commits = (struct sha1_array *) submodule->util;
+
+ if (submodule_needs_pushing(submodule->string, commits))
+ string_list_insert(needs_pushing, submodule->string);
}
free_submodules_sha1s(&submodules);
--
2.10.1.386.gc503e45
^ permalink raw reply related
* [PATCH v3 0/4] Speedup finding of unpushed submodules
From: Heiko Voigt @ 2016-11-15 14:56 UTC (permalink / raw)
To: Junio C Hamano
Cc: git, Jeff King, Stefan Beller, Jens.Lehmann, Fredrik Gustafsson,
Leandro Lucarella
You can find the second iteration of this series here:
http://public-inbox.org/git/cover.1475851621.git.hvoigt@hvoigt.net/
All mentioned issues should be fixed. I put the NEEDSWORK comment in a
seperate patch since it seemed to me as if we did not fully agree on
that. So in case we decide against it we can just drop that patch.
Cheers Heiko
Heiko Voigt (4):
serialize collection of changed submodules
serialize collection of refs that contain submodule changes
batch check whether submodule needs pushing into one call
submodule_needs_pushing() NEEDSWORK when we can not answer this
question
submodule.c | 120 +++++++++++++++++++++++++++++++++++++++++++++++-------------
submodule.h | 5 ++-
transport.c | 29 +++++++++++----
3 files changed, 118 insertions(+), 36 deletions(-)
--
2.10.1.386.gc503e45
^ permalink raw reply
* Re: RFC: Enable delayed responses to Git clean/smudge filter requests
From: Lars Schneider @ 2016-11-15 14:29 UTC (permalink / raw)
To: Eric Wong; +Cc: git
In-Reply-To: <20161115010356.GA29602@starla>
> On 15 Nov 2016, at 02:03, Eric Wong <e@80x24.org> wrote:
>
> Lars Schneider <larsxschneider@gmail.com> wrote:
>> Hi,
>>
>> Git always performs a clean/smudge filter on files in sequential order.
>> Sometimes a filter operation can take a noticeable amount of time.
>> This blocks the entire Git process.
>
> I have the same problem in many places which aren't git :>
>
>> I would like to give a filter process the possibility to answer Git with
>> "I got your request, I am processing it, ask me for the result later!".
>>
>> I see the following way to realize this:
>>
>> In unpack-trees.c:check_updates() [1] we loop through the cache
>> entries and "ask me later" could be an acceptable return value of the
>> checkout_entry() call. The loop could run until all entries returned
>> success or error.
>>
>> The filter machinery is triggered in various other places in Git and
>> all places that want to support "ask me later" would need to be patched
>> accordingly.
>
> That all sounds reasonable.
>
> The filter itself would need to be aware of parallelism
> if it lives for multiple objects, right?
Correct. This way Git doesn't need to deal with threading...
>> Do you think this could be a viable approach?
>
> It'd probably require a bit of work, but yes, I think it's viable.
>
> We already do this with curl_multi requests for parallel
> fetching from dumb HTTP servers, but that's driven by curl
> internals operating with a select/poll loop.
>
> Perhaps the curl API could be a good example for doing this.
Thanks for the pointer!
>> Do you see a better way?
>
> Nope, I prefer non-blocking state machines to threads for
> debuggability and determinism.
Agreed!
> Anyways, I'll plan on doing something similar (in Perl) with the
> synchronous parts of public-inbox which relies on "cat-file --batch"
> at some point... (my rotational disks are sloooooooow :<)
That sounds interesting! What changes to you have in mind for
"cat-file --batch"? We are thinking about performance improvements
in that area, too. I would be happy to help reviewing your patches!
Thanks a lot for your RFC feedback,
Lars
^ permalink raw reply
* Re: [PATCH v1 2/2] travis-ci: disable GIT_TEST_HTTPD for macOS
From: Lars Schneider @ 2016-11-15 14:18 UTC (permalink / raw)
To: Heiko Voigt
Cc: Jeff King, Junio C Hamano, Torsten Bögershausen, git,
Eric Sunshine
In-Reply-To: <20161115120718.GA7854@book.hvoigt.net>
> On 15 Nov 2016, at 13:07, Heiko Voigt <hvoigt@hvoigt.net> wrote:
>
> On Fri, Nov 11, 2016 at 09:22:51AM +0100, Lars Schneider wrote:
>> To all macOS users on the list:
>> Does anyone execute the tests with GIT_TEST_HTTPD enabled successfully?
>
> Nope. The following tests fail for me on master: 5539, 5540, 5541, 5542,
> 5550, 5551, 5561, 5812.
That's what I see, too. Apache needs to be configured in some special way
to make them work and I was wondering if anyone has figured that out
already for macOS...
However, I much prefer Peff's idea to test against real world servers:
http://public-inbox.org/git/20161111092824.qqgrmhtkuw3wpbwa@sigill.intra.peff.net/
- Lars
^ permalink raw reply
* Protecting old temporary objects being reused from concurrent "git gc"?
From: Matt McCutchen @ 2016-11-15 14:13 UTC (permalink / raw)
To: git
The Braid subproject management tool stores the subproject content in
the main tree and is able to switch to a different upstream revision of
a subproject by doing the equivalent of "git read-tree -m" on the
superproject tree and the two upstream trees. The tricky part is
preparing temporary trees with the upstream content moved to the path
configured for the superproject. The usual method is "git read-tree
--prefix", but using what index file? Braid currently uses the user's
actual worktree, which can leave a mess if it gets interrupted:
https://github.com/cristibalan/braid/blob/7d81da6e86e24de62a74f3ab8d880666cb343b04/lib/braid/commands/update.rb#L98
I want to change this to something that won't leave an inconsistent
state if interrupted. I've written code for this kind of thing before
that sets GIT_INDEX_FILE and uses a temporary index file and "git
write-tree". But I realized that if "git gc" runs concurrently, the
generated tree could be deleted before it is used and the tool would
fail. If I had a need to run "git commit-tree", it seems like I might
even end up with a commit object with a broken reference to a tree.
"git gc" normally doesn't delete objects that were created in the last
2 weeks, but if an identical tree was added to the object database more
than 2 weeks ago by another operation and is unreferenced, it could be
reused without updating its mtime and it could still get deleted.
Is there a recommended way to avoid this kind of problem in add-on
tools? (I searched the Git documentation and the web for information
about races with "git gc" and didn't find anything useful.) If not, it
seems to be a significant design flaw in "git gc", even if the problem
is extremely rare in practice. I wonder if some of the built-in
commands may have the same problem, though I haven't tried to test
them. If this is confirmed to be a known problem affecting built-in
commands, then at least I won't feel bad about introducing the
same problem into add-on tools. :/
Thanks,
Matt
^ permalink raw reply
* Re: git shortlog vs. stdin
From: Christian Neukirchen @ 2016-11-15 13:39 UTC (permalink / raw)
To: git
In-Reply-To: <20161115130418.GA28847@inner.h.apk.li>
Andreas Krey <a.krey@gmx.de> writes:
> Bug or feature?
Documented feature, but you're holding it wrong ;)
If no revisions are passed on the command line and either standard
input is not a terminal or there is no current branch, git shortlog
will output a summary of the log read from standard input, without
reference to the current repository.
(Note that you can use shortlog ala "git log --pretty=short | git shortlog")
--
Christian Neukirchen <chneukirchen@gmail.com> http://chneukirchen.org
^ permalink raw reply
* git shortlog vs. stdin
From: Andreas Krey @ 2016-11-15 13:04 UTC (permalink / raw)
To: git
Hi all,
I observed a strange an unexpected behaviour in 'git shortlog'.
When in git.git:
$ git shortlog -sn | wc
1441 4493 31477
but with input redirected:
$ git shortlog -sn </dev/null | wc
0 0 0
--no-pager expectedly doesn't help.
Observed with 2.6.2 and 2.10.0-rc1.
I originally stumbled over this while trying something like
$ ls z* | while read name rest; do
echo "$name" ====; git --no-pager shortlog | tail -4; done
where it also essentially terminates the while loop,
presumably by eating the stdin to the loop.
Bug or feature?
- Andreas
--
"Totally trivial. Famous last words."
From: Linus Torvalds <torvalds@*.org>
Date: Fri, 22 Jan 2010 07:29:21 -0800
^ permalink raw reply
* New to git, need help!
From: Mayank Gupta @ 2016-11-15 12:30 UTC (permalink / raw)
To: git
Hi All,
I'm new to open source and have recently joined this mailing list.
Since I'm new at this, I think I can initially contribute to the
community by fixing some small bugs or errors but as the documentation
is too large, I don't know where to start.
So if anybody could guide me on how to go about it, it would be really
appreciated.
Thanks,
Mayank
^ permalink raw reply
* Re: [PATCH v1 2/2] travis-ci: disable GIT_TEST_HTTPD for macOS
From: Heiko Voigt @ 2016-11-15 12:07 UTC (permalink / raw)
To: Lars Schneider
Cc: Jeff King, Junio C Hamano, Torsten Bögershausen, git,
Eric Sunshine
In-Reply-To: <2088B631-4FE8-4232-9F3C-699122E6A7B0@gmail.com>
On Fri, Nov 11, 2016 at 09:22:51AM +0100, Lars Schneider wrote:
> To all macOS users on the list:
> Does anyone execute the tests with GIT_TEST_HTTPD enabled successfully?
Nope. The following tests fail for me on master: 5539, 5540, 5541, 5542,
5550, 5551, 5561, 5812.
Cheers Heiko
^ permalink raw reply
* Re: Git status takes too long- How to improve the performance of git
From: Christian Couder @ 2016-11-15 11:44 UTC (permalink / raw)
To: ravalika; +Cc: git, Fredrik Gustafsson
In-Reply-To: <20161115102400.GC28860@paksenarrion.iveqy.com>
On Tue, Nov 15, 2016 at 11:24 AM, Fredrik Gustafsson <iveqy@iveqy.com> wrote:
> On Tue, Nov 15, 2016 at 02:33:12AM -0700, ravalika wrote:
[...]
>> And I have experimented the following ways
>> - - Setting core.ignorestat to true
>> - - Git gc &git clean
>> - - Shallow clone – Reducing number of commits
>> - - Clone only one branch
>> - Git repacking - git repack -ad && git prune
>> - - Cold/warm cache
>>
>> Could you please let me know, what are the ways to improve the git
>> performance ?
>> I have gone through the mailing lists.
>
> You could always check the --assume-unchanged bit, see the manual page
> for git update-index. However this is quite extreme and demanding for
> the user.
If you install a recent version version, you may be able to use the
untracked cache feature.
(See "core.untrackedCache" in the git config documentation and
--untracked-cache in the git update-index documentation.)
^ 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