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

[PATCH 2/5] refs/ref-cache.[ch]: remove unused remove_entry_from_dir()

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Sep 28, 2021, 13:02 UTC
Message-ID
<patch-2.5-001a1335ab4-20210928T130032Z-avarab@gmail.com>
In-Reply-To
<cover-0.5-00000000000-20210928T130032Z-avarab@gmail.com>

This function was missed in 9939b33d6a3 (packed-backend: rip out some now-unused code, 2017-09-08), and has been orphaned since then. Let's delete it.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 refs/ref-cache.c | 35 -----------------------------------
 refs/ref-cache.h | 16 ----------------
 2 files changed, 51 deletions(-)
diff --git a/refs/ref-cache.c b/refs/ref-cache.c
index 49d732f6db9..e0feebf628f 100644
--- a/refs/ref-cache.c
+++ b/refs/ref-cache.c
@@ -212,41 +212,6 @@ struct ref_entry *find_ref_entry(struct ref_dir *dir, const char *refname)
 	return (entry->flag & REF_DIR) ? NULL : entry;
 }
 
-int remove_entry_from_dir(struct ref_dir *dir, const char *refname)
-{
-	int refname_len = strlen(refname);
-	int entry_index;
-	struct ref_entry *entry;
-	int is_dir = refname[refname_len - 1] == '/';
-	if (is_dir) {
-		/*
-		 * refname represents a reference directory.  Remove
-		 * the trailing slash; otherwise we will get the
-		 * directory *representing* refname rather than the
-		 * one *containing* it.
-		 */
-		char *dirname = xmemdupz(refname, refname_len - 1);
-		dir = find_containing_dir(dir, dirname, 0);
-		free(dirname);
-	} else {
-		dir = find_containing_dir(dir, refname, 0);
-	}
-	if (!dir)
-		return -1;
-	entry_index = search_ref_dir(dir, refname, refname_len);
-	if (entry_index == -1)
-		return -1;
-	entry = dir->entries[entry_index];
-
-	MOVE_ARRAY(&dir->entries[entry_index],
-		   &dir->entries[entry_index + 1], dir->nr - entry_index - 1);
-	dir->nr--;
-	if (dir->sorted > entry_index)
-		dir->sorted--;
-	free_ref_entry(entry);
-	return dir->nr;
-}
-
 int add_ref_entry(struct ref_dir *dir, struct ref_entry *ref)
 {
 	dir = find_containing_dir(dir, ref->name, 1);
diff --git a/refs/ref-cache.h b/refs/ref-cache.h
index 3bfb89d2b34..bd1ff578ea2 100644
--- a/refs/ref-cache.h
+++ b/refs/ref-cache.h
@@ -199,22 +199,6 @@ void free_ref_cache(struct ref_cache *cache);
  */
 void add_entry_to_dir(struct ref_dir *dir, struct ref_entry *entry);
 
-/*
- * Remove the entry with the given name from dir, recursing into
- * subdirectories as necessary.  If refname is the name of a directory
- * (i.e., ends with '/'), then remove the directory and its contents.
- * If the removal was successful, return the number of entries
- * remaining in the directory entry that contained the deleted entry.
- * If the name was not found, return -1.  Please note that this
- * function only deletes the entry from the cache; it does not delete
- * it from the filesystem or ensure that other cache entries (which
- * might be symbolic references to the removed entry) are updated.
- * Nor does it remove any containing dir entries that might be made
- * empty by the removal.  dir must represent the top-level directory
- * and must already be complete.
- */
-int remove_entry_from_dir(struct ref_dir *dir, const char *refname);
-
 /*
  * Add a ref_entry to the ref_dir (unsorted), recursing into
  * subdirectories as necessary.  dir must represent the top-level
-- 
2.33.0.1340.ge9f77250f2b
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 3 of 8 in “refs: remove long-dead code”
  1. 0/5 refs: remove long-dead codeÆvar Arnfjörð Bjarmason, Sep 28, 2021
  2. 1/5 refs.[ch]: remove unused ref_storage_backend_exists()Ævar Arnfjörð Bjarmason, Sep 28, 2021
  3. 2/5 refs/ref-cache.[ch]: remove unused remove_entry_from_dir()Ævar Arnfjörð Bjarmason, Sep 28, 2021
  4. 3/5 refs/ref-cache.[ch]: remove unused add_ref_entry()Ævar Arnfjörð Bjarmason, Sep 28, 2021
  5. 4/5 refs/ref-cache.c: remove "mkdir" parameter from find_containing_dir()Ævar Arnfjörð Bjarmason, Sep 28, 2021
  6. 5/5 refs/ref-cache.[ch]: remove "incomplete" from create_dir_entry()Ævar Arnfjörð Bjarmason, Sep 28, 2021
  7. Jeff KingSep 28, 2021
  8. Junio C HamanoSep 28, 2021

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.