Skip to content

Commit

Permalink
Merge branch 'ac/describe-dirty-refresh'
Browse files Browse the repository at this point in the history
* ac/describe-dirty-refresh:
  describe: Refresh the index when run with --dirty
  • Loading branch information
Junio C Hamano committed Aug 25, 2011
2 parents e11fa9a + bb57148 commit 22f6578
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions builtin/describe.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down

0 comments on commit 22f6578

Please sign in to comment.