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

Re: [PATCH] describe: Refresh the index when run with --dirty

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 2, 2011, 21:59 UTC
Message-ID
<7v1ux3eapk.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1312163561-77072-1-git-send-email-allan.caffee@gmail.com>
Thanks.

Here is a minor fix-up on top, that can be squashed in a re-roll (if you plan to do one).

diff --git a/builtin/describe.c b/builtin/describe.c
index 792af76..9f63067 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -24,7 +24,6 @@ static int longformat;
 static int abbrev = -1; /* unspecified */
 static int max_candidates = 10;
 static struct hash_table names;
-static struct lock_file index_lock; /* real index */
 static int have_util;
 static const char *pattern;
 static int always;
@@ -400,7 +399,6 @@ static void describe(const char *arg, int last_one)
 int cmd_describe(int argc, const char **argv, const char *prefix)
 {
 	int contains = 0;
-	int fd;
 	struct option options[] = {
 		OPT_BOOLEAN(0, "contains",   &contains, "find the tag that comes after the commit"),
 		OPT_BOOLEAN(0, "debug",      &debug, "debug search strategy on stderr"),
@@ -465,13 +463,18 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
 
 	if (argc == 0) {
 		if (dirty) {
-			read_cache();
-			refresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED, NULL, NULL, NULL);
+			static struct lock_file index_lock;
+			int fd;
+
+			read_cache_preload(NULL);
+			refresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED,
+				      NULL, NULL, NULL);
 			fd = hold_locked_index(&index_lock, 0);
 			if (0 <= fd)
 				update_index_if_able(&the_index, &index_lock);
 
-			if (!cmd_diff_index(ARRAY_SIZE(diff_index_args) - 1, diff_index_args, prefix))
+			if (!cmd_diff_index(ARRAY_SIZE(diff_index_args) - 1,
+					    diff_index_args, prefix))
 				dirty = NULL;
 		}
 		describe("HEAD", 1);
Previous: Jeff KingNext: Allan Caffee
Message 9 of 10 in “Unusual behavior from git describe”
  1. Allan CaffeeJul 29, 2011
  2. Sverre RabbelierJul 29, 2011
  3. Allan CaffeeJul 30, 2011
  4. Sverre RabbelierJul 30, 2011
  5. Allan CaffeeJul 30, 2011
  6. Jeff KingJul 31, 2011
  7. describe: Refresh the index when run with --dirtyAllan Caffee, Aug 1, 2011
  8. Jeff KingAug 1, 2011
  9. Junio C HamanoAug 2, 2011
  10. Allan CaffeeAug 2, 2011

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.