Revision a5406125cc3989a7007d4fad7e5757cdb9837ebf authored by Junio C Hamano on 28 October 2016, 16:01:16 UTC, committed by Junio C Hamano on 28 October 2016, 16:01:16 UTC
In a worktree connected to a repository elsewhere, created via "git worktree", "git checkout" attempts to protect users from confusion by refusing to check out a branch that is already checked out in another worktree. However, this also prevented checking out a branch, which is designated as the primary branch of a bare reopsitory, in a worktree that is connected to the bare repository. The check has been corrected to allow it. * dk/worktree-dup-checkout-with-bare-is-ok: worktree: allow the main brach of a bare repository to be checked out
mru.c
#include "cache.h"
#include "mru.h"
void mru_append(struct mru *mru, void *item)
{
struct mru_entry *cur = xmalloc(sizeof(*cur));
cur->item = item;
cur->prev = mru->tail;
cur->next = NULL;
if (mru->tail)
mru->tail->next = cur;
else
mru->head = cur;
mru->tail = cur;
}
void mru_mark(struct mru *mru, struct mru_entry *entry)
{
/* If we're already at the front of the list, nothing to do */
if (mru->head == entry)
return;
/* Otherwise, remove us from our current slot... */
if (entry->prev)
entry->prev->next = entry->next;
if (entry->next)
entry->next->prev = entry->prev;
else
mru->tail = entry->prev;
/* And insert us at the beginning. */
entry->prev = NULL;
entry->next = mru->head;
if (mru->head)
mru->head->prev = entry;
mru->head = entry;
}
void mru_clear(struct mru *mru)
{
struct mru_entry *p = mru->head;
while (p) {
struct mru_entry *to_free = p;
p = p->next;
free(to_free);
}
mru->head = mru->tail = NULL;
}
Computing file changes ...