Subject: [PATCH 0/2] fetch, reflogs, and bare repositories

From: Jeff King <[email-masked]>
Date: Tue, 4 Nov 2014 08:10:07 -0500

I ran into a rather confusing case of fetching into a bare repository
with reflogs turned on:

    # make a repo with a two-component branch name
    git init -q &&
    git commit -q --allow-empty -m one &&
    git branch foo/bar &&
    
    # now fetch it all into a bare repo with reflogs
    git init -q --bare parent.git &&
    cd parent.git &&
    git config core.logallrefupdates true &&
    git fetch --prune .. +refs/*:refs/* &&
    
    # now replace the branch with one that has a d/f conflict
    cd .. &&
    git branch -d foo/bar &&
    git branch foo &&
    
    # and fetch again
    cd parent.git &&
    git fetch --prune .. +refs/*:refs/*

The final fetch fails and produces this output:

    From ..
     x [deleted]         (none)     -> foo/bar
    error: Unable to append to ./logs/refs/heads/foo: Is a directory
     ! [new branch]      foo        -> foo  (unable to update local ref)

This turns out to be caused by two subtle bugs: one that makes "git
fetch" use reflogs inconsistently, and the other that causes some ref
updates to fail when reflogs are turned on and off. Details are in the
fixes themselves.

  [1/2]: fetch: load all default config at startup
  [2/2]: ignore stale directories when checking reflog existence

-Peff