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

Re: [PATCH] cherry-pick/revert: transparently refresh index

From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Date
Nov 1, 2010, 08:44 UTC
Message-ID
<AANLkTimqpwgvHS7+Q98RPrtD+j7gN7T3-ZrJDCLBq0sF@mail.gmail.com>
In-Reply-To
<20101031195933.GA21240@burratino>
Show 7 quoted lines
> +static void read_and_refresh_cache(const char *me)
> +{
> +       static struct lock_file index_lock;
> +       int index_fd = hold_locked_index(&index_lock, 0);
> +       if (read_index_preload(&the_index, NULL) < 0)
> +               die("git %s: failed to read the index", me);
> +       refresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED, NULL, NULL, NULL);

Can we refresh only index entries that are cherry-picked/reverted? Full refresh can be expensive on large repos while these operations don't usually touch the whole repo.

I'm thinking of adding ce_really_uptodate() and converting most of ce_uptodate() call sites to the new one.

diff --git a/cache.h b/cache.h
index 123dd4b..81dc5cf 100644
--- a/cache.h
+++ b/cache.h
@@ -240,6 +240,7 @@ static inline size_t ce_namelen(const struct
cache_entry *ce)
 			    ondisk_cache_entry_size(ce_namelen(ce)))
 #define ce_stage(ce) ((CE_STAGEMASK & (ce)->ce_flags) >> CE_STAGESHIFT)
 #define ce_uptodate(ce) ((ce)->ce_flags & CE_UPTODATE)
+#define ce_really_uptodate(ce) (ce_uptodate(ce) ||
(refresh_cache_entry(ce), ce_uptodate(ce)))
 #define ce_skip_worktree(ce) ((ce)->ce_flags & CE_SKIP_WORKTREE)
 #define ce_mark_uptodate(ce) ((ce)->ce_flags |= CE_UPTODATE)

@@ -512,6 +513,7 @@ extern void fill_stat_cache_info(struct
cache_entry *ce, struct stat *st);
 #define REFRESH_IGNORE_SUBMODULES	0x0010	/* ignore submodules */
 #define REFRESH_IN_PORCELAIN	0x0020	/* user friendly output, not
"needs update" */
 extern int refresh_index(struct index_state *, unsigned int flags,
const char **pathspec, char *seen, char *header_msg);
+extern struct cache_entry *refresh_cache_entry(struct cache_entry
*ce, int really);

 struct lock_file {
 	struct lock_file *next;
diff --git a/read-cache.c b/read-cache.c
index 1f42473..76525a9 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1156,7 +1156,7 @@ int refresh_index(struct index_state *istate,
unsigned int flags, const char **p
 	return has_errors;
 }

-static struct cache_entry *refresh_cache_entry(struct cache_entry
*ce, int really)
+struct cache_entry *refresh_cache_entry(struct cache_entry *ce, int really)
 {
 	return refresh_cache_ent(&the_index, ce, really, NULL);
 }
-- 
Duy
Previous: Johannes Sixt
Message 16 of 16 in “index rebuild for cloned repo”
  1. Pete WyckoffOct 31, 2010
  2. Jonathan NiederOct 31, 2010
  3. cherry-pick/revert: transparently refresh indexJonathan Nieder, Oct 31, 2010
  4. Andreas SchwabOct 31, 2010
  5. Jonathan NiederOct 31, 2010
  6. Pete WyckoffOct 31, 2010
  7. teach update-index --refresh about --data-unchangedPete Wyckoff, Oct 31, 2010
  8. Junio C HamanoNov 3, 2010
  9. Jonathan NiederNov 3, 2010
  10. Pete WyckoffNov 3, 2010
  11. Pete WyckoffNov 14, 2010
  12. Jonathan NiederNov 14, 2010
  13. Johannes SixtNov 1, 2010
  14. Junio C HamanoNov 3, 2010
  15. Johannes SixtNov 3, 2010
  16. Nguyen Thai Ngoc DuyNov 1, 2010

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.