From: "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Johannes Schindelin <johannes.schindelin@gmx.de>,
Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: [PATCH] commit-graph: warn about incompatibilities only when trying to write
Date: Fri, 26 Feb 2021 14:50:35 +0000 [thread overview]
Message-ID: <pull.888.git.1614351036334.gitgitgadget@gmail.com> (raw)
From: Johannes Schindelin <johannes.schindelin@gmx.de>
In c85eec7fc37 (commit-graph: when incompatible with graphs, indicate
why, 2021-02-11), we started warning the user if they tried to write a
commit-graph in a shallow repository, or one containing replace objects.
However, this patch was a bit overzealous, as Git now _also_ warns when
merely checking whether there _is_ a usable commit graph, not only when
writing one.
Let's suppress that warning unless we want to write a commit-graph.
Reported-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
commit-graph: warn about incompatibilities only when trying to write
As pointed out by Ævar in
https://lore.kernel.org/git/87pn0o6y1e.fsf@evledraar.gmail.com, my
recent patch to trigger warnings in repositories that are incompatible
with the commit-graph was a bit too overzealous. Here is a fix for that.
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-888%2Fdscho%2Fwarn-a-little-less-if-commit-graph-is-skipped-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-888/dscho/warn-a-little-less-if-commit-graph-is-skipped-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/888
commit-graph.c | 20 ++++++++++++--------
t/t5318-commit-graph.sh | 13 +++++++++++++
2 files changed, 25 insertions(+), 8 deletions(-)
diff --git a/commit-graph.c b/commit-graph.c
index 8fd480434353..245b7108e0d1 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -198,7 +198,7 @@ static struct commit_graph *alloc_commit_graph(void)
extern int read_replace_refs;
-static int commit_graph_compatible(struct repository *r)
+static int commit_graph_compatible(struct repository *r, int quiet)
{
if (!r->gitdir)
return 0;
@@ -206,8 +206,9 @@ static int commit_graph_compatible(struct repository *r)
if (read_replace_refs) {
prepare_replace_object(r);
if (hashmap_get_size(&r->objects->replace_map->map)) {
- warning(_("repository contains replace objects; "
- "skipping commit-graph"));
+ if (!quiet)
+ warning(_("repository contains replace "
+ "objects; skipping commit-graph"));
return 0;
}
}
@@ -215,12 +216,15 @@ static int commit_graph_compatible(struct repository *r)
prepare_commit_graft(r);
if (r->parsed_objects &&
(r->parsed_objects->grafts_nr || r->parsed_objects->substituted_parent)) {
- warning(_("repository contains (deprecated) grafts; "
- "skipping commit-graph"));
+ if (!quiet)
+ warning(_("repository contains (deprecated) grafts; "
+ "skipping commit-graph"));
return 0;
}
if (is_repository_shallow(r)) {
- warning(_("repository is shallow; skipping commit-graph"));
+ if (!quiet)
+ warning(_("repository is shallow; skipping "
+ "commit-graph"));
return 0;
}
@@ -652,7 +656,7 @@ static int prepare_commit_graph(struct repository *r)
*/
return 0;
- if (!commit_graph_compatible(r))
+ if (!commit_graph_compatible(r, 1))
return 0;
prepare_alt_odb(r);
@@ -2123,7 +2127,7 @@ int write_commit_graph(struct object_directory *odb,
warning(_("attempting to write a commit-graph, but 'core.commitGraph' is disabled"));
return 0;
}
- if (!commit_graph_compatible(the_repository))
+ if (!commit_graph_compatible(the_repository, 0))
return 0;
ctx = xcalloc(1, sizeof(struct write_commit_graph_context));
diff --git a/t/t5318-commit-graph.sh b/t/t5318-commit-graph.sh
index 2ed0c1544da1..2699c55e9a93 100755
--- a/t/t5318-commit-graph.sh
+++ b/t/t5318-commit-graph.sh
@@ -741,4 +741,17 @@ test_expect_success 'corrupt commit-graph write (missing tree)' '
)
'
+test_expect_success 'warn about incompatibilities (only) when writing' '
+ git init warn &&
+ test_commit -C warn initial &&
+ test_commit -C warn second &&
+ git -C warn replace --graft second &&
+ test_config -C warn gc.writecommitgraph true &&
+
+ git -C warn gc 2>err &&
+ test_i18ngrep "skipping commit-graph" err &&
+ git -C warn rev-list -1 second 2>err &&
+ test_i18ngrep ! "skipping commit-graph" err
+'
+
test_done
base-commit: c85eec7fc37e1ca79072f263ae6ea1ee305ba38c
--
gitgitgadget
next reply other threads:[~2021-02-26 14:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-26 14:50 Johannes Schindelin via GitGitGadget [this message]
2021-02-26 16:00 ` [PATCH] commit-graph: warn about incompatibilities only when trying to write Ævar Arnfjörð Bjarmason
2021-02-26 22:39 ` Junio C Hamano
2021-02-28 16:20 ` Ævar Arnfjörð Bjarmason
2021-03-01 17:18 ` Junio C Hamano
2021-03-01 22:10 ` Johannes Schindelin
2021-03-01 22:21 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=pull.888.git.1614351036334.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=git@vger.kernel.org \
--cc=johannes.schindelin@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).