git@vger.kernel.org mailing list mirror (one of many)
 help / Atom feed
* [PATCH 0/1] send-pack: set core.warnAmbiguousRefs=false
@ 2018-11-06 19:13 Derrick Stolee via GitGitGadget
  2018-11-06 19:13 ` [PATCH 1/1] " Derrick Stolee via GitGitGadget
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Derrick Stolee via GitGitGadget @ 2018-11-06 19:13 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

I've been looking into the performance of git push for very large repos. Our
users are reporting that 60-80% of git push time is spent during the
"Enumerating objects" phase of git pack-objects.

A git push process runs several processes during its run, but one includes 
git send-pack which calls git pack-objects and passes the known have/wants
into stdin using object ids. However, the default setting for 
core.warnAmbiguousRefs requires git pack-objects to check for ref names
matching the ref_rev_parse_rules array in refs.c. This means that every
object is triggering at least six "file exists?" queries.

When there are a lot of refs, this can add up significantly! My PerfView
trace for a simple push measured 3 seconds spent checking these paths.

The fix for this is simple: set core.warnAmbiguousRefs to false for this
specific call of git pack-objects coming from git send-pack. We don't want
to default it to false for all calls to git pack-objects, as it is valid to
pass ref names instead of object ids. This helps regain these seconds during
a push.

In addition to this patch submission, we are looking into merging it into
our fork sooner [1].

[1] https://github.com/Microsoft/git/pull/67

Derrick Stolee (1):
  send-pack: set core.warnAmbiguousRefs=false

 send-pack.c | 2 ++
 1 file changed, 2 insertions(+)


base-commit: cae598d9980661a978e2df4fb338518f7bf09572
Published-As: https://github.com/gitgitgadget/git/releases/tags/pr-68%2Fderrickstolee%2Fsend-pack-config-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-68/derrickstolee/send-pack-config-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/68
-- 
gitgitgadget

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/1] send-pack: set core.warnAmbiguousRefs=false
  2018-11-06 19:13 [PATCH 0/1] send-pack: set core.warnAmbiguousRefs=false Derrick Stolee via GitGitGadget
@ 2018-11-06 19:13 ` " Derrick Stolee via GitGitGadget
  2018-11-06 19:44 ` [PATCH 0/1] " Jeff King
  2018-11-06 20:34 ` [PATCH v2 " Derrick Stolee via GitGitGadget
  2 siblings, 0 replies; 12+ messages in thread
From: Derrick Stolee via GitGitGadget @ 2018-11-06 19:13 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Derrick Stolee

From: Derrick Stolee <dstolee@microsoft.com>

During a 'git push' command, we run 'git send-pack' inside of our
transport helper. This creates a 'git pack-objects' process and
passes a list of object ids. If this list is large, then the
pack-objects process can spend a lot of time checking the possible
refs these strings could represent.

Remove this extra check by setting core.warnAmbiguousRefs to false
as we call 'git pack-objects'.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
---
 send-pack.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/send-pack.c b/send-pack.c
index e920ca57df..5055150fe1 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -64,6 +64,8 @@ static int pack_objects(int fd, struct ref *refs, struct oid_array *extra, struc
 	int i;
 	int rc;
 
+	argv_array_push(&po.args, "-c");
+	argv_array_push(&po.args, "core.warnAmbiguousRefs=false");
 	argv_array_push(&po.args, "pack-objects");
 	argv_array_push(&po.args, "--all-progress-implied");
 	argv_array_push(&po.args, "--revs");
-- 
gitgitgadget

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/1] send-pack: set core.warnAmbiguousRefs=false
  2018-11-06 19:13 [PATCH 0/1] send-pack: set core.warnAmbiguousRefs=false Derrick Stolee via GitGitGadget
  2018-11-06 19:13 ` [PATCH 1/1] " Derrick Stolee via GitGitGadget
@ 2018-11-06 19:44 ` " Jeff King
  2018-11-06 19:51   ` Jeff King
  2018-11-06 20:00   ` Derrick Stolee
  2018-11-06 20:34 ` [PATCH v2 " Derrick Stolee via GitGitGadget
  2 siblings, 2 replies; 12+ messages in thread
From: Jeff King @ 2018-11-06 19:44 UTC (permalink / raw)
  To: Derrick Stolee via GitGitGadget; +Cc: git, Junio C Hamano

On Tue, Nov 06, 2018 at 11:13:47AM -0800, Derrick Stolee via GitGitGadget wrote:

> I've been looking into the performance of git push for very large repos. Our
> users are reporting that 60-80% of git push time is spent during the
> "Enumerating objects" phase of git pack-objects.
> 
> A git push process runs several processes during its run, but one includes 
> git send-pack which calls git pack-objects and passes the known have/wants
> into stdin using object ids. However, the default setting for 
> core.warnAmbiguousRefs requires git pack-objects to check for ref names
> matching the ref_rev_parse_rules array in refs.c. This means that every
> object is triggering at least six "file exists?" queries.
> 
> When there are a lot of refs, this can add up significantly! My PerfView
> trace for a simple push measured 3 seconds spent checking these paths.

Some of this might be useful in the commit message. :)

> The fix for this is simple: set core.warnAmbiguousRefs to false for this
> specific call of git pack-objects coming from git send-pack. We don't want
> to default it to false for all calls to git pack-objects, as it is valid to
> pass ref names instead of object ids. This helps regain these seconds during
> a push.

I don't think you actually care about the ambiguity check between refs
here; you just care about avoiding the ref check when we've seen (and
are mostly expecting) a 40-hex sha1. We have a more specific flag for
that: warn_on_object_refname_ambiguity.

And I think it would be OK to enable that all the time for pack-objects,
which is plumbing that does typically expect object names. See prior art
in 25fba78d36 (cat-file: disable object/refname ambiguity check for
batch mode, 2013-07-12) and 4c30d50402 (rev-list: disable object/refname
ambiguity check with --stdin, 2014-03-12).

> Derrick Stolee (1):
>   send-pack: set core.warnAmbiguousRefs=false
> 
>  send-pack.c | 2 ++
>  1 file changed, 2 insertions(+)

Whenever I see a change like this to the pack-objects invocation for
send-pack, it makes me wonder if upload-pack would want the same thing.

It's a moot point if we just set the flag directly in inside
pack-objects, though.

-Peff

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/1] send-pack: set core.warnAmbiguousRefs=false
  2018-11-06 19:44 ` [PATCH 0/1] " Jeff King
@ 2018-11-06 19:51   ` Jeff King
  2018-11-06 20:16     ` Derrick Stolee
  2018-11-06 20:00   ` Derrick Stolee
  1 sibling, 1 reply; 12+ messages in thread
From: Jeff King @ 2018-11-06 19:51 UTC (permalink / raw)
  To: Derrick Stolee via GitGitGadget; +Cc: Derrick Stolee, git, Junio C Hamano

On Tue, Nov 06, 2018 at 02:44:42PM -0500, Jeff King wrote:

> > The fix for this is simple: set core.warnAmbiguousRefs to false for this
> > specific call of git pack-objects coming from git send-pack. We don't want
> > to default it to false for all calls to git pack-objects, as it is valid to
> > pass ref names instead of object ids. This helps regain these seconds during
> > a push.
> 
> I don't think you actually care about the ambiguity check between refs
> here; you just care about avoiding the ref check when we've seen (and
> are mostly expecting) a 40-hex sha1. We have a more specific flag for
> that: warn_on_object_refname_ambiguity.
> 
> And I think it would be OK to enable that all the time for pack-objects,
> which is plumbing that does typically expect object names. See prior art
> in 25fba78d36 (cat-file: disable object/refname ambiguity check for
> batch mode, 2013-07-12) and 4c30d50402 (rev-list: disable object/refname
> ambiguity check with --stdin, 2014-03-12).

I'd probably do it here:

diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index e50c6cd1ff..d370638a5d 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -3104,6 +3104,7 @@ static void get_object_list(int ac, const char **av)
 	struct rev_info revs;
 	char line[1000];
 	int flags = 0;
+	int save_warning;
 
 	repo_init_revisions(the_repository, &revs, NULL);
 	save_commit_buffer = 0;
@@ -3112,6 +3113,9 @@ static void get_object_list(int ac, const char **av)
 	/* make sure shallows are read */
 	is_repository_shallow(the_repository);
 
+	save_warning = warn_on_object_refname_ambiguity;
+	warn_on_object_refname_ambiguity = 0;
+
 	while (fgets(line, sizeof(line), stdin) != NULL) {
 		int len = strlen(line);
 		if (len && line[len - 1] == '\n')
@@ -3138,6 +3142,8 @@ static void get_object_list(int ac, const char **av)
 			die(_("bad revision '%s'"), line);
 	}
 
+	warn_on_object_refname_ambiguity = save_warning;
+
 	if (use_bitmap_index && !get_object_list_from_bitmap(&revs))
 		return;
 

But I'll leave it to you to wrap that up in a patch, since you probably
should re-check your timings (which it would be interesting to include
in the commit message, if you have reproducible timings).

-Peff

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/1] send-pack: set core.warnAmbiguousRefs=false
  2018-11-06 19:44 ` [PATCH 0/1] " Jeff King
  2018-11-06 19:51   ` Jeff King
@ 2018-11-06 20:00   ` Derrick Stolee
  1 sibling, 0 replies; 12+ messages in thread
From: Derrick Stolee @ 2018-11-06 20:00 UTC (permalink / raw)
  To: Jeff King, Derrick Stolee via GitGitGadget; +Cc: git, Junio C Hamano

On 11/6/2018 2:44 PM, Jeff King wrote:
> On Tue, Nov 06, 2018 at 11:13:47AM -0800, Derrick Stolee via GitGitGadget wrote:
>
>> I've been looking into the performance of git push for very large repos. Our
>> users are reporting that 60-80% of git push time is spent during the
>> "Enumerating objects" phase of git pack-objects.
>>
>> A git push process runs several processes during its run, but one includes
>> git send-pack which calls git pack-objects and passes the known have/wants
>> into stdin using object ids. However, the default setting for
>> core.warnAmbiguousRefs requires git pack-objects to check for ref names
>> matching the ref_rev_parse_rules array in refs.c. This means that every
>> object is triggering at least six "file exists?" queries.
>>
>> When there are a lot of refs, this can add up significantly! My PerfView
>> trace for a simple push measured 3 seconds spent checking these paths.
> Some of this might be useful in the commit message. :)
>
>> The fix for this is simple: set core.warnAmbiguousRefs to false for this
>> specific call of git pack-objects coming from git send-pack. We don't want
>> to default it to false for all calls to git pack-objects, as it is valid to
>> pass ref names instead of object ids. This helps regain these seconds during
>> a push.
> I don't think you actually care about the ambiguity check between refs
> here; you just care about avoiding the ref check when we've seen (and
> are mostly expecting) a 40-hex sha1. We have a more specific flag for
> that: warn_on_object_refname_ambiguity.
>
> And I think it would be OK to enable that all the time for pack-objects,
> which is plumbing that does typically expect object names. See prior art
> in 25fba78d36 (cat-file: disable object/refname ambiguity check for
> batch mode, 2013-07-12) and 4c30d50402 (rev-list: disable object/refname
> ambiguity check with --stdin, 2014-03-12).
Thanks for these pointers. Helps to know there is precedent for shutting 
down the
behavior without relying on "-c" flags.

> Whenever I see a change like this to the pack-objects invocation for
> send-pack, it makes me wonder if upload-pack would want the same thing.
>
> It's a moot point if we just set the flag directly in inside
> pack-objects, though.
I'll send a v2 that does just that.

Thanks,
-Stolee

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/1] send-pack: set core.warnAmbiguousRefs=false
  2018-11-06 19:51   ` Jeff King
@ 2018-11-06 20:16     ` Derrick Stolee
  0 siblings, 0 replies; 12+ messages in thread
From: Derrick Stolee @ 2018-11-06 20:16 UTC (permalink / raw)
  To: Jeff King, Derrick Stolee via GitGitGadget
  Cc: Derrick Stolee, git, Junio C Hamano

On 11/6/2018 2:51 PM, Jeff King wrote:
> On Tue, Nov 06, 2018 at 02:44:42PM -0500, Jeff King wrote:
>
>>> The fix for this is simple: set core.warnAmbiguousRefs to false for this
>>> specific call of git pack-objects coming from git send-pack. We don't want
>>> to default it to false for all calls to git pack-objects, as it is valid to
>>> pass ref names instead of object ids. This helps regain these seconds during
>>> a push.
>> I don't think you actually care about the ambiguity check between refs
>> here; you just care about avoiding the ref check when we've seen (and
>> are mostly expecting) a 40-hex sha1. We have a more specific flag for
>> that: warn_on_object_refname_ambiguity.
>>
>> And I think it would be OK to enable that all the time for pack-objects,
>> which is plumbing that does typically expect object names. See prior art
>> in 25fba78d36 (cat-file: disable object/refname ambiguity check for
>> batch mode, 2013-07-12) and 4c30d50402 (rev-list: disable object/refname
>> ambiguity check with --stdin, 2014-03-12).
> I'd probably do it here:
>
> diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
> index e50c6cd1ff..d370638a5d 100644
> --- a/builtin/pack-objects.c
> +++ b/builtin/pack-objects.c
> @@ -3104,6 +3104,7 @@ static void get_object_list(int ac, const char **av)

Scoping the change into get_object_list does make sense. I was doing it 
a level higher, which is not worth it. I'll reproduce your change here.

>   	struct rev_info revs;
>   	char line[1000];
>   	int flags = 0;
> +	int save_warning;
>   
>   	repo_init_revisions(the_repository, &revs, NULL);
>   	save_commit_buffer = 0;
> @@ -3112,6 +3113,9 @@ static void get_object_list(int ac, const char **av)
>   	/* make sure shallows are read */
>   	is_repository_shallow(the_repository);
>   
> +	save_warning = warn_on_object_refname_ambiguity;
> +	warn_on_object_refname_ambiguity = 0;
> +
>   	while (fgets(line, sizeof(line), stdin) != NULL) {
>   		int len = strlen(line);
>   		if (len && line[len - 1] == '\n')
> @@ -3138,6 +3142,8 @@ static void get_object_list(int ac, const char **av)
>   			die(_("bad revision '%s'"), line);
>   	}
>   
> +	warn_on_object_refname_ambiguity = save_warning;
> +
>   	if (use_bitmap_index && !get_object_list_from_bitmap(&revs))
>   		return;
>   
>
> But I'll leave it to you to wrap that up in a patch, since you probably
> should re-check your timings (which it would be interesting to include
> in the commit message, if you have reproducible timings).

The timings change a lot depending on the disk cache and the remote 
refs, which is unfortunate, but I have measured a three-second improvement.

Thanks,
-Stolee

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v2 0/1] send-pack: set core.warnAmbiguousRefs=false
  2018-11-06 19:13 [PATCH 0/1] send-pack: set core.warnAmbiguousRefs=false Derrick Stolee via GitGitGadget
  2018-11-06 19:13 ` [PATCH 1/1] " Derrick Stolee via GitGitGadget
  2018-11-06 19:44 ` [PATCH 0/1] " Jeff King
@ 2018-11-06 20:34 ` " Derrick Stolee via GitGitGadget
  2018-11-06 20:34   ` [PATCH v2 1/1] pack-objects: ignore ambiguous object warnings Derrick Stolee via GitGitGadget
  2 siblings, 1 reply; 12+ messages in thread
From: Derrick Stolee via GitGitGadget @ 2018-11-06 20:34 UTC (permalink / raw)
  To: git; +Cc: peff, Junio C Hamano

I've been looking into the performance of git push for very large repos. Our
users are reporting that 60-80% of git push time is spent during the
"Enumerating objects" phase of git pack-objects.

A git push process runs several processes during its run, but one includes 
git send-pack which calls git pack-objects and passes the known have/wants
into stdin using object ids. However, the default setting for 
core.warnAmbiguousRefs requires git pack-objects to check for ref names
matching the ref_rev_parse_rules array in refs.c. This means that every
object is triggering at least six "file exists?" queries.

When there are a lot of refs, this can add up significantly! My PerfView
trace for a simple push measured 3 seconds spent checking these paths.

The fix is to set the global warn_on_object_refname_ambiguity to 0 for the
section that is performing these object reads.

In addition to this patch submission, we are looking into merging it into
our fork sooner [1].

[1] https://github.com/Microsoft/git/pull/67

Changes in V2: Instead of using the "-c" flag from send-pack, just set the
global. I left the name of the cover letter the same to not confuse anyone
viewing the message without threading.

Derrick Stolee (1):
  pack-objects: ignore ambiguous object warnings

 builtin/pack-objects.c | 6 ++++++
 1 file changed, 6 insertions(+)


base-commit: cae598d9980661a978e2df4fb338518f7bf09572
Published-As: https://github.com/gitgitgadget/git/releases/tags/pr-68%2Fderrickstolee%2Fsend-pack-config-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-68/derrickstolee/send-pack-config-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/68

Range-diff vs v1:

 1:  1ef2c51550 < -:  ---------- send-pack: set core.warnAmbiguousRefs=false
 -:  ---------- > 1:  002868ee6b pack-objects: ignore ambiguous object warnings

-- 
gitgitgadget

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v2 1/1] pack-objects: ignore ambiguous object warnings
  2018-11-06 20:34 ` [PATCH v2 " Derrick Stolee via GitGitGadget
@ 2018-11-06 20:34   ` Derrick Stolee via GitGitGadget
  2018-11-06 21:12     ` Jeff King
  0 siblings, 1 reply; 12+ messages in thread
From: Derrick Stolee via GitGitGadget @ 2018-11-06 20:34 UTC (permalink / raw)
  To: git; +Cc: peff, Junio C Hamano, Derrick Stolee

From: Derrick Stolee <dstolee@microsoft.com>

A git push process runs several processes during its run, but one
includes git send-pack which calls git pack-objects and passes
the known have/wants into stdin using object ids. However, the
default setting for core.warnAmbiguousRefs requires git pack-objects
to check for ref names matching the ref_rev_parse_rules array in
refs.c. This means that every object is triggering at least six
"file exists?" queries.  When there are a lot of refs, this can
add up significantly! I observed a simple push spending three
seconds checking these paths.

The fix here is similar to 4c30d50 "rev-list: disable object/refname
ambiguity check with --stdin". Save the value of the global
warn_on_object_refname_ambiguity variable (which is usually set to
the boolean config variable core.warnAmbiguousRefs) and change the
state to false. Do this only during the get_object_list() method
which reads the objects from stdin.

Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
---
 builtin/pack-objects.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index d1144a8f7e..f703e6df9b 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -2988,6 +2988,7 @@ static void get_object_list(int ac, const char **av)
 	struct rev_info revs;
 	char line[1000];
 	int flags = 0;
+	int save_warning;
 
 	init_revisions(&revs, NULL);
 	save_commit_buffer = 0;
@@ -2996,6 +2997,9 @@ static void get_object_list(int ac, const char **av)
 	/* make sure shallows are read */
 	is_repository_shallow(the_repository);
 
+	save_warning = warn_on_object_refname_ambiguity;
+	warn_on_object_refname_ambiguity = 0;
+
 	while (fgets(line, sizeof(line), stdin) != NULL) {
 		int len = strlen(line);
 		if (len && line[len - 1] == '\n')
@@ -3022,6 +3026,8 @@ static void get_object_list(int ac, const char **av)
 			die(_("bad revision '%s'"), line);
 	}
 
+	warn_on_object_refname_ambiguity = save_warning;
+
 	if (use_bitmap_index && !get_object_list_from_bitmap(&revs))
 		return;
 
-- 
gitgitgadget

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 1/1] pack-objects: ignore ambiguous object warnings
  2018-11-06 20:34   ` [PATCH v2 1/1] pack-objects: ignore ambiguous object warnings Derrick Stolee via GitGitGadget
@ 2018-11-06 21:12     ` Jeff King
  2018-11-07  1:54       ` Junio C Hamano
  0 siblings, 1 reply; 12+ messages in thread
From: Jeff King @ 2018-11-06 21:12 UTC (permalink / raw)
  To: Derrick Stolee via GitGitGadget; +Cc: git, Junio C Hamano, Derrick Stolee

On Tue, Nov 06, 2018 at 12:34:47PM -0800, Derrick Stolee via GitGitGadget wrote:

> From: Derrick Stolee <dstolee@microsoft.com>
> 
> A git push process runs several processes during its run, but one
> includes git send-pack which calls git pack-objects and passes
> the known have/wants into stdin using object ids. However, the
> default setting for core.warnAmbiguousRefs requires git pack-objects
> to check for ref names matching the ref_rev_parse_rules array in
> refs.c. This means that every object is triggering at least six
> "file exists?" queries.  When there are a lot of refs, this can
> add up significantly! I observed a simple push spending three
> seconds checking these paths.

Thanks, this fills out the details from the cover letter a bit better.

> The fix here is similar to 4c30d50 "rev-list: disable object/refname
> ambiguity check with --stdin". Save the value of the global
> warn_on_object_refname_ambiguity variable (which is usually set to
> the boolean config variable core.warnAmbiguousRefs) and change the
> state to false. Do this only during the get_object_list() method
> which reads the objects from stdin.

I think this parenthetical isn't quite right. We never change the value
of warn_on_object_refname_ambiguity based on user config. It's just that
if warn_ambiguous_refs is off, we do not even bother looking at the
object_refname variant.

So we'd never expect to see anything except "1" in our save_warning
variable. Doing a save/restore is just about code hygiene and
maintainability.

Other than that minor nit, this whole thing looks good to me.

-Peff

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 1/1] pack-objects: ignore ambiguous object warnings
  2018-11-06 21:12     ` Jeff King
@ 2018-11-07  1:54       ` Junio C Hamano
  2018-11-07  8:52         ` Junio C Hamano
  0 siblings, 1 reply; 12+ messages in thread
From: Junio C Hamano @ 2018-11-07  1:54 UTC (permalink / raw)
  To: Jeff King; +Cc: Derrick Stolee via GitGitGadget, git, Derrick Stolee

Jeff King <peff@peff.net> writes:

> So we'd never expect to see anything except "1" in our save_warning
> variable. Doing a save/restore is just about code hygiene and
> maintainability.

Here is what I plan to queue.  Thanks, both.

-- >8 --
From: Derrick Stolee <dstolee@microsoft.com>
Date: Tue, 6 Nov 2018 12:34:47 -0800
Subject: [PATCH] pack-objects: ignore ambiguous object warnings

A git push process runs several processes during its run, but one
includes git send-pack which calls git pack-objects and passes
the known have/wants into stdin using object ids. However, the
default setting for core.warnAmbiguousRefs requires git pack-objects
to check for ref names matching the ref_rev_parse_rules array in
refs.c. This means that every object is triggering at least six
"file exists?" queries.  When there are a lot of refs, this can
add up significantly! I observed a simple push spending three
seconds checking these paths.

The fix here is similar to 4c30d50 "rev-list: disable object/refname
ambiguity check with --stdin".  While the get_object_list() method
reads the objects from stdin, turn warn_on_object_refname_ambiguity
flag (which is usually true) to false.  Just for code hygiene, save
away the original at the beginning and restore it once we are done.

Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin/pack-objects.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index d1144a8f7e..f703e6df9b 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -2988,6 +2988,7 @@ static void get_object_list(int ac, const char **av)
 	struct rev_info revs;
 	char line[1000];
 	int flags = 0;
+	int save_warning;
 
 	init_revisions(&revs, NULL);
 	save_commit_buffer = 0;
@@ -2996,6 +2997,9 @@ static void get_object_list(int ac, const char **av)
 	/* make sure shallows are read */
 	is_repository_shallow(the_repository);
 
+	save_warning = warn_on_object_refname_ambiguity;
+	warn_on_object_refname_ambiguity = 0;
+
 	while (fgets(line, sizeof(line), stdin) != NULL) {
 		int len = strlen(line);
 		if (len && line[len - 1] == '\n')
@@ -3022,6 +3026,8 @@ static void get_object_list(int ac, const char **av)
 			die(_("bad revision '%s'"), line);
 	}
 
+	warn_on_object_refname_ambiguity = save_warning;
+
 	if (use_bitmap_index && !get_object_list_from_bitmap(&revs))
 		return;
 
-- 
2.19.1-856-g8858448bb4


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 1/1] pack-objects: ignore ambiguous object warnings
  2018-11-07  1:54       ` Junio C Hamano
@ 2018-11-07  8:52         ` Junio C Hamano
  2018-11-07  9:21           ` Jeff King
  0 siblings, 1 reply; 12+ messages in thread
From: Junio C Hamano @ 2018-11-07  8:52 UTC (permalink / raw)
  To: Jeff King; +Cc: Derrick Stolee via GitGitGadget, git, Derrick Stolee

Junio C Hamano <gitster@pobox.com> writes:

> The fix here is similar to 4c30d50 "rev-list: disable object/refname
> ambiguity check with --stdin".  While the get_object_list() method
> reads the objects from stdin, turn warn_on_object_refname_ambiguity
> flag (which is usually true) to false.  Just for code hygiene, save
> away the original at the beginning and restore it once we are done.

I actually think this is a bit too broad.  The calling process of
this program does know that it is feeding list of raw object names
(prefixed with ^ for negative ones), but the codepath this patch
touches does not know who is calling it with what.  It would be
safer to introduce a mechanism for the caller to tell this codepath
not to bother checking refnames, as it knows it is feeding the raw
object names and not refnames.

After all, you can feed things like "refs/heads/master" from the
standard input of "git pack-objects --revs", no?

> Helped-by: Jeff King <peff@peff.net>
> Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>  builtin/pack-objects.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
> index d1144a8f7e..f703e6df9b 100644
> --- a/builtin/pack-objects.c
> +++ b/builtin/pack-objects.c
> @@ -2988,6 +2988,7 @@ static void get_object_list(int ac, const char **av)
>  	struct rev_info revs;
>  	char line[1000];
>  	int flags = 0;
> +	int save_warning;
>  
>  	init_revisions(&revs, NULL);
>  	save_commit_buffer = 0;
> @@ -2996,6 +2997,9 @@ static void get_object_list(int ac, const char **av)
>  	/* make sure shallows are read */
>  	is_repository_shallow(the_repository);
>  
> +	save_warning = warn_on_object_refname_ambiguity;
> +	warn_on_object_refname_ambiguity = 0;
> +
>  	while (fgets(line, sizeof(line), stdin) != NULL) {
>  		int len = strlen(line);
>  		if (len && line[len - 1] == '\n')
> @@ -3022,6 +3026,8 @@ static void get_object_list(int ac, const char **av)
>  			die(_("bad revision '%s'"), line);
>  	}
>  
> +	warn_on_object_refname_ambiguity = save_warning;
> +
>  	if (use_bitmap_index && !get_object_list_from_bitmap(&revs))
>  		return;

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 1/1] pack-objects: ignore ambiguous object warnings
  2018-11-07  8:52         ` Junio C Hamano
@ 2018-11-07  9:21           ` Jeff King
  0 siblings, 0 replies; 12+ messages in thread
From: Jeff King @ 2018-11-07  9:21 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Derrick Stolee via GitGitGadget, git, Derrick Stolee

On Wed, Nov 07, 2018 at 05:52:05PM +0900, Junio C Hamano wrote:

> Junio C Hamano <gitster@pobox.com> writes:
> 
> > The fix here is similar to 4c30d50 "rev-list: disable object/refname
> > ambiguity check with --stdin".  While the get_object_list() method
> > reads the objects from stdin, turn warn_on_object_refname_ambiguity
> > flag (which is usually true) to false.  Just for code hygiene, save
> > away the original at the beginning and restore it once we are done.
> 
> I actually think this is a bit too broad.  The calling process of
> this program does know that it is feeding list of raw object names
> (prefixed with ^ for negative ones), but the codepath this patch
> touches does not know who is calling it with what.  It would be
> safer to introduce a mechanism for the caller to tell this codepath
> not to bother checking refnames, as it knows it is feeding the raw
> object names and not refnames.
> 
> After all, you can feed things like "refs/heads/master" from the
> standard input of "git pack-objects --revs", no?

Keep in mind that this is not disallowing "refs/heads/master", nor even
disabling the ambiguity checking if we feed a "foo" that exists as both
a tag and a branch.

It is only disabling the check that when the caller feeds a 40-hex sha1,
we do not double-check to make sure that there is not a ref of the same
name (which is not even really an ambiguity, but just an informational
message for the user; the object id has always and must always take
precedence).

So yes, the caller does know better "I am only going to feed object
ids". But you can likewise look from the callee's perspective: "I am
going to take a lot of inputs, and spending time for an informational
message for each one is not worth doing".

So I think it's justifiable from that point of view. And from a
practical point of view, it's much simpler: we do not have teach every
caller to specify its input, or risk being slowed down by a low-value
informational check.

-Peff

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, back to index

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-06 19:13 [PATCH 0/1] send-pack: set core.warnAmbiguousRefs=false Derrick Stolee via GitGitGadget
2018-11-06 19:13 ` [PATCH 1/1] " Derrick Stolee via GitGitGadget
2018-11-06 19:44 ` [PATCH 0/1] " Jeff King
2018-11-06 19:51   ` Jeff King
2018-11-06 20:16     ` Derrick Stolee
2018-11-06 20:00   ` Derrick Stolee
2018-11-06 20:34 ` [PATCH v2 " Derrick Stolee via GitGitGadget
2018-11-06 20:34   ` [PATCH v2 1/1] pack-objects: ignore ambiguous object warnings Derrick Stolee via GitGitGadget
2018-11-06 21:12     ` Jeff King
2018-11-07  1:54       ` Junio C Hamano
2018-11-07  8:52         ` Junio C Hamano
2018-11-07  9:21           ` Jeff King

git@vger.kernel.org mailing list mirror (one of many)

Archives are clonable:
	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.org/gmane.comp.version-control.git

 note: .onion URLs require Tor: https://www.torproject.org/
       or Tor2web: https://www.tor2web.org/

AGPL code for this site: git clone https://public-inbox.org/ public-inbox