git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3] submodule: suppress checking for file name and ref ambiguity for object ids

From
Orgad Shaneh via GitGitGadget <gitgitgadget@gmail.com>
Date
Sep 6, 2020, 20:47 UTC
Message-ID
<pull.725.v3.git.1599425259773.gitgitgadget@gmail.com>
In-Reply-To
<pull.725.v2.git.1599370473141.gitgitgadget@gmail.com>
From: Orgad Shaneh <orgads@gmail.com>

The argv argument of collect_changed_submodules() contains obly object ids (the objects references of all the refs).

Notify setup_revisions() that the input is not filenames by passing assume_dashdash, so it can avoid redundant stat for each ref.

Also suppress refname_ambiguity flag to avoid filesystem lookups for each object. Similar logic can be found in cat-file, pack-objects and more.

Signed-off-by: Orgad Shaneh <orgads@gmail.com>
---
    submodule: suppress checking for file name and ref ambiguity for object
    ids
    
    The argv argument of collect_changed_submodules() contains obly object
    ids (submodule references).
    
    Notify setup_revisions() that the input is not filenames by passing
    assume_dashdash, so it can avoid redundant stat for each ref.
    
    A better improvement would be to pass oid_array instead of stringified
    argv, but that will require a larger change, which can be done later.
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-725%2Forgads%2Fsubmodule-not-filename-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-725/orgads/submodule-not-filename-v3
Pull-Request: https://github.com/gitgitgadget/git/pull/725
Range-diff vs v2:
 1:  501ce90e9a ! 1:  128a7244f9 submodule: suppress checking for file name ambiguity for object ids
     @@ Metadata
      Author: Orgad Shaneh <orgads@gmail.com>
      
       ## Commit message ##
     -    submodule: suppress checking for file name ambiguity for object ids
     +    submodule: suppress checking for file name and ref ambiguity for object ids
      
          The argv argument of collect_changed_submodules() contains obly object ids
          (the objects references of all the refs).
     @@ Commit message
          Notify setup_revisions() that the input is not filenames by passing
          assume_dashdash, so it can avoid redundant stat for each ref.
      
     -    A better improvement would be to pass oid_array instead of stringified argv,
     -    but that will require a larger change, which can be done later.
     +    Also suppress refname_ambiguity flag to avoid filesystem lookups for
     +    each object. Similar logic can be found in cat-file, pack-objects and more.
      
          Signed-off-by: Orgad Shaneh <orgads@gmail.com>
      
     @@ submodule.c: static void collect_changed_submodules(struct repository *r,
       {
       	struct rev_info rev;
       	const struct commit *commit;
     ++	int save_warning;
      +	struct setup_revision_opt s_r_opt = {
      +		.assume_dashdash = 1,
      +	};
       
     ++	save_warning = warn_on_object_refname_ambiguity;
     ++	warn_on_object_refname_ambiguity = 0;
       	repo_init_revisions(r, &rev, NULL);
      -	setup_revisions(argv->nr, argv->v, &rev, NULL);
      +	setup_revisions(argv->nr, argv->v, &rev, &s_r_opt);
     ++	warn_on_object_refname_ambiguity = save_warning;
       	if (prepare_revision_walk(&rev))
       		die(_("revision walk setup failed"));
       
 submodule.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/submodule.c b/submodule.c
index 3cbcf40dfc..e48710e423 100644
--- a/submodule.c
+++ b/submodule.c
@@ -840,9 +840,16 @@ static void collect_changed_submodules(struct repository *r,
 {
 	struct rev_info rev;
 	const struct commit *commit;
+	int save_warning;
+	struct setup_revision_opt s_r_opt = {
+		.assume_dashdash = 1,
+	};
 
+	save_warning = warn_on_object_refname_ambiguity;
+	warn_on_object_refname_ambiguity = 0;
 	repo_init_revisions(r, &rev, NULL);
-	setup_revisions(argv->nr, argv->v, &rev, NULL);
+	setup_revisions(argv->nr, argv->v, &rev, &s_r_opt);
+	warn_on_object_refname_ambiguity = save_warning;
 	if (prepare_revision_walk(&rev))
 		die(_("revision walk setup failed"));
 

base-commit: 3a238e539bcdfe3f9eb5010fd218640c1b499f7a
-- 
gitgitgadget
Previous: Orgad ShanehNext: Orgad Shaneh via GitGitGadget
Message 4 of 7 in “submodule: suppress checking for file name ambiguity for object ids”
  1. submodule: suppress checking for file name ambiguity for object idsOrgad Shaneh via GitGitGadget, Sep 4, 2020
  2. submodule: suppress checking for file name ambiguity for object idsOrgad Shaneh via GitGitGadget, Sep 6, 2020
  3. Orgad ShanehSep 6, 2020
  4. submodule: suppress checking for file name and ref ambiguity for object idsOrgad Shaneh via GitGitGadget, Sep 6, 2020
  5. submodule: suppress checking for file name and ref ambiguity for object idsOrgad Shaneh via GitGitGadget, Sep 6, 2020
  6. Ramsay JonesSep 6, 2020
  7. Junio C HamanoSep 6, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.