summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Allan Caffee <allan.caffee@gmail.com>2011-07-31 21:52:41 -0400
committerLibravatar Junio C Hamano <gitster@pobox.com>2011-09-23 14:28:17 -0700
commit85b3c75f4fd3aa4da976bac702827dc8d7d1bf15 (patch)
treebbe7ffb76e23605b6103637c2dfb7f95c51fafe6
parentMerge branch 'jc/maint-clone-alternates' into maint (diff)
downloadtgif-85b3c75f4fd3aa4da976bac702827dc8d7d1bf15.tar.xz
describe: Refresh the index when run with --dirty
When running git describe --dirty the index should be refreshed. Previously the cached index would cause describe to think that the index was dirty when, in reality, it was just stale. The issue was exposed by python setuptools which hardlinks files into another directory when building a distribution. Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--builtin/describe.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/builtin/describe.c b/builtin/describe.c
index 66fc291c8a..9f63067f50 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -462,8 +462,21 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
die(_("No names found, cannot describe anything."));
if (argc == 0) {
- if (dirty && !cmd_diff_index(ARRAY_SIZE(diff_index_args) - 1, diff_index_args, prefix))
- dirty = NULL;
+ if (dirty) {
+ 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))
+ dirty = NULL;
+ }
describe("HEAD", 1);
} else if (dirty) {
die(_("--dirty is incompatible with committishes"));