{"thread":{"id":"18472","subject":"[PATCH] Improve error message about fetch into current branch","startedAt":"2009-03-22T22:07:33Z","lastAt":"2009-03-22T22:07:33Z","messageCount":1,"participants":["Alex Riesen"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"108942","messageId":"20090322220732.GA6736@blimp.localdomain","threadId":"18472","inReplyTo":null,"subject":"[PATCH] Improve error message about fetch into current branch","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2009-03-22T22:07:33Z","receivedAt":"2009-03-22T22:07:33Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Otherwise, it is hard to guess why the fetch failed.\nMake sure we at least mention that the repository must be bare.\nAlso the current branch is printed.\n\nSigned-off-by: Alex Riesen <raa.lkml@gmail.com>\n---\n\nIn particular, a repository not marked bare with core.bare is, for\nsome reason, considered non-bare even if there is no work tree nor\nindex. I found about the message while trying to run git remote,\nin an essentially bare repository without core.bare set. Funny,\ngit --bare fetch worked properly, but git --bare remote update failed:\n\n    $ GIT_TRACE=1 ~/projects/git/git --bare remote -v update\n    trace: built-in: git 'remote' '-v' 'update'\n    Updating origin\n    trace: run_command: 'fetch' '-v' 'origin'\n    trace: exec: 'git' 'fetch' '-v' 'origin'\n    trace: built-in: git 'fetch' '-v' 'origin'\n    fatal: Refusing to fetch into current branch refs/heads/master\n    error: Could not fetch origin\n    $ git --bare fetch -v origin\n    From git://git.kernel.org/pub/scm/linux/hotplug/udev\n     = [up to date]      master     -> master\n    $\n\nLooks like --bare is lost somewhere.\n\n builtin-fetch.c |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-fetch.c b/builtin-fetch.c\nindex 7fb35fc..7293146 100644\n--- a/builtin-fetch.c\n+++ b/builtin-fetch.c\n@@ -544,7 +544,8 @@ static void check_not_current_branch(struct ref *ref_map)\n \tfor (; ref_map; ref_map = ref_map->next)\n \t\tif (ref_map->peer_ref && !strcmp(current_branch->refname,\n \t\t\t\t\tref_map->peer_ref->name))\n-\t\t\tdie(\"Refusing to fetch into current branch\");\n+\t\t\tdie(\"Refusing to fetch into current branch %s \"\n+\t\t\t    \"of non-bare repository\", current_branch->refname);\n }\n \n static int do_fetch(struct transport *transport,\n-- \n1.6.2.1.316.g4241\n"}]}