{"thread":{"id":"26119","subject":"FIX/COMMENT: git remote manual page","startedAt":"2010-12-22T01:15:46Z","lastAt":"2010-12-25T13:00:21Z","messageCount":4,"participants":["Michel Briand","Nguyen Thai Ngoc Duy"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"158468","messageId":"20101222021546.4b24c4e9@eana.kheb.homelinux.org","threadId":"26119","inReplyTo":null,"subject":"FIX/COMMENT: git remote manual page","fromName":"Michel Briand","fromEmail":"michelbriand@free.fr","sentAt":"2010-12-22T01:15:46Z","receivedAt":"2010-12-22T01:15:46Z","isPatch":false,"sender":{"key":"michelbriand@free.fr","avatar":null},"body":"Hello,\n\nI tried the example given at the bottom if the manual page of git\nremote.\n\n·   Imitate git clone but track only selected branches\n\n$ mkdir project.git\n$ cd project.git\n$ git init\n$ git remote add -f -t master -m master origin git://example.com/git.git/\n$ git merge origin\n\nIt works like it is written.\n\nBut it seems this does not work with my special setup:\n- I use GIT_DIR and GIT_WORK_TREE to specify another location for my\n  repository, and to work from another directory,\n- I name my remote with a custom name (not origin).\n\nIt fails at the last command :\n\n    fatal: <my name> - not something we can merge\n\nBut if I try the command :\n\n    git merge <my name>/master\n\nthe error message is different :\n\n    fatal: This operation must be run in a work tree\n    fatal: read-tree failed\n\nI cd to the work tree and issue the same last command.\nThen it works.\n\nI suspect the first error message is related to the remote name. And\nthe second to the work tree not being the current directory.\n\nCheers,\nMichel\n"},{"id":"158569","messageId":"AANLkTim_pHYEZ+7-Rm5N4Ycw2MTHD8AhvZrZqNhttkck@mail.gmail.com","threadId":"26119","inReplyTo":"20101222021546.4b24c4e9@eana.kheb.homelinux.org","subject":"Re: FIX/COMMENT: git remote manual page","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-12-25T10:48:58Z","receivedAt":"2010-12-25T10:48:58Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Wed, Dec 22, 2010 at 8:15 AM, Michel Briand <michelbriand@free.fr> wrote:\n> Hello,\n>\n> I tried the example given at the bottom if the manual page of git\n> remote.\n>\n> ·   Imitate git clone but track only selected branches\n>\n> $ mkdir project.git\n> $ cd project.git\n> $ git init\n> $ git remote add -f -t master -m master origin git://example.com/git.git/\n> $ git merge origin\n>\n> It works like it is written.\n>\n> But it seems this does not work with my special setup:\n> - I use GIT_DIR and GIT_WORK_TREE to specify another location for my\n>  repository, and to work from another directory,\n> - I name my remote with a custom name (not origin).\n\nSo you set GIT_DIR and GIT_WORK_TREE before running \"git remote add\"?\n\n> It fails at the last command :\n>\n>    fatal: <my name> - not something we can merge\n\nIt fails to see \"<my name>\" points to a commit. Maybe it fails to read\nremote information from config..\n\n> But if I try the command :\n>\n>    git merge <my name>/master\n>\n> the error message is different :\n>\n>    fatal: This operation must be run in a work tree\n>    fatal: read-tree failed\n>\n> I cd to the work tree and issue the same last command.\n> Then it works.\n\nWhat git version are use using? I did\n\nGIT_DIR=git/.git GIT_WORK_TREE=git git/git merge origin # or a specific branch\n\nand it worked fine here (recent master). That message means work-tree\nsettings are not propagated to git-read-tree (run by git-merge).\n-- \nDuy\n"},{"id":"158570","messageId":"20101225124104.06a4f83c@eana.kheb.homelinux.org","threadId":"26119","inReplyTo":"AANLkTim_pHYEZ+7-Rm5N4Ycw2MTHD8AhvZrZqNhttkck@mail.gmail.com","subject":"Re: FIX/COMMENT: git remote manual page","fromName":"Michel Briand","fromEmail":"michelbriand@free.fr","sentAt":"2010-12-25T11:41:04Z","receivedAt":"2010-12-25T11:41:04Z","isPatch":false,"sender":{"key":"michelbriand@free.fr","avatar":null},"body":"\nNguyen Thai Ngoc Duy <pclouds@gmail.com> - Sat, 25 Dec 2010 17:48:58\n+0700\n\n>On Wed, Dec 22, 2010 at 8:15 AM, Michel Briand <michelbriand@free.fr> wrote:\n>> Hello,\n>>\n>> I tried the example given at the bottom if the manual page of git\n>> remote.\n>>\n>> ·   Imitate git clone but track only selected branches\n>>\n>> $ mkdir project.git\n>> $ cd project.git\n>> $ git init\n>> $ git remote add -f -t master -m master origin git://example.com/git.git/\n>> $ git merge origin\n>>\n>> It works like it is written.\n>>\n>> But it seems this does not work with my special setup:\n>> - I use GIT_DIR and GIT_WORK_TREE to specify another location for my\n>>  repository, and to work from another directory,\n>> - I name my remote with a custom name (not origin).\n>\n>So you set GIT_DIR and GIT_WORK_TREE before running \"git remote add\"?\n>\n\nYes.\n\n>> It fails at the last command :\n>>\n>>    fatal: <my name> - not something we can merge\n>\n>It fails to see \"<my name>\" points to a commit. Maybe it fails to read\n>remote information from config..\n>\n\nHuh, I don't know.\n\n>> But if I try the command :\n>>\n>>    git merge <my name>/master\n>>\n>> the error message is different :\n>>\n>>    fatal: This operation must be run in a work tree\n>>    fatal: read-tree failed\n>>\n>> I cd to the work tree and issue the same last command.\n>> Then it works.\n>\n>What git version are use using? I did\n>\n>GIT_DIR=git/.git GIT_WORK_TREE=git git/git merge origin # or a specific branch\n>\n>and it worked fine here (recent master). That message means work-tree\n>settings are not propagated to git-read-tree (run by git-merge).\n\nHi,\n\nI'm running Debian squeeze. Git is version 1.7.2.3.\n\nHere is the complete command sequence I used:\n\n~/tmp/git $ mkdir toto toto_wk\n~/tmp/git $ GIT_DIR=toto GIT_WORK_TREE=toto_wk git init\nInitialized empty Git repository in xxxxxxxxxxxxxxxx/tmp/git/toto/\n~/tmp/git $ GIT_DIR=toto GIT_WORK_TREE=toto_wk git remote add -f -t master -m master TOTO xxxxxx/shlib \nUpdating TOTO\nremote: Counting objects: 36, done.\nremote: Compressing objects: 100% (32/32), done.\nremote: Total 36 (delta 9), reused 0 (delta 0)\nUnpacking objects: 100% (36/36), done.\nFrom xxxxxxxxxxxxxxxxx/shlib\n * [new branch]      master     -> TOTO/master\nFrom xxxxxxxxxxxxxxxxx/shlib\n * [new tag]         1.0        -> 1.0\n * [new tag]         1.0.1      -> 1.0.1\n~/tmp/git $ GIT_DIR=toto GIT_WORK_TREE=toto_wk git merge TOTO\nfatal: This operation must be run in a work tree\nfatal: read-tree failed\n~/tmp/git $ ls toto_wk/\n<NOTHING>\n\nI re-issue the latest command :\n\n~/tmp/git $ GIT_DIR=toto GIT_WORK_TREE=toto_wk git merge TOTO\nAlready up-to-date.\n\nStrange isn't it ?\n\nBut directory is still empty\n~/tmp/git $ ls toto_wk/\n<NOTHING>\n\nTrying to recover :\n\n~/tmp/git $ GIT_DIR=toto GIT_WORK_TREE=toto_wk git reset --hard\n\nThe directory is correct (in sync with my master branch).\n\nIf I do :\n\n...git init\n...git remote add...\ncd toto_wk\nGIT_DIR=../toto GIT_WORK_TREE=. git merge TOTO\n\nIt works !\n\nAdding /master after remote name doesn't make any difference. Please\nforget this idea.\n\nThe problem seems to reside in the work tree parameter (. or not).\n\nCheers,\nMichel\n"},{"id":"158574","messageId":"AANLkTik_x+FcdRs7ac1X45OE7_9E8W-y44HJU=XUuRog@mail.gmail.com","threadId":"26119","inReplyTo":"20101225124104.06a4f83c@eana.kheb.homelinux.org","subject":"Re: FIX/COMMENT: git remote manual page","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-12-25T13:00:21Z","receivedAt":"2010-12-25T13:00:21Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Sat, Dec 25, 2010 at 6:41 PM, Michel Briand <michelbriand@free.fr> wrote:\n> Hi,\n>\n> I'm running Debian squeeze. Git is version 1.7.2.3.\n>\n> Here is the complete command sequence I used:\n>\n> ~/tmp/git $ mkdir toto toto_wk\n> ~/tmp/git $ GIT_DIR=toto GIT_WORK_TREE=toto_wk git init\n\nNote that this also sets core.worktree=`cwd`/toto_wk so you only need\nto set GIT_DIR in the following commands. But I wouldn't recommend it,\njust set GIT_WORK_TREE the way you are doing, until maybe 1.7.4.\ncore.worktree is buggy.\n\n> ~/tmp/git $ GIT_DIR=toto GIT_WORK_TREE=toto_wk git merge TOTO\n> fatal: This operation must be run in a work tree\n> fatal: read-tree failed\n\nThanks for the instructions. We've got a problem with $GIT_WORK_TREE\nvs cwd here. I'll send a patch later.\n\n> ~/tmp/git $ ls toto_wk/\n> <NOTHING>\n>\n> I re-issue the latest command :\n>\n> ~/tmp/git $ GIT_DIR=toto GIT_WORK_TREE=toto_wk git merge TOTO\n> Already up-to-date.\n>\n> Strange isn't it ?\n\nActually no. 'git-merge' is successful and its last step is to call\n'git read-tree --reset -u SHA-1' to update worktree. Unfortunately,\ngit's internal cwd has been moved to ~/tmp/git/toto_wk while\n$GIT_WORK_TREE is still \"toto_wk\". When git-read-tree is run, it tries\nto find a worktree at ~/tmp/git/toto_wk/toto_wk.\n\n> But directory is still empty\n> ~/tmp/git $ ls toto_wk/\n> <NOTHING>\n\nBecause git-read-tree fails to run.\n\n> Trying to recover :\n>\n> ~/tmp/git $ GIT_DIR=toto GIT_WORK_TREE=toto_wk git reset --hard\n\nOr you can try this until new git release:\n\nGIT_DIR=toto GIT_WORK_TREE=$HOME/tmp/toto_wk git merge TOTO\n\nor\n\nGIT_DIR=toto git merge TOTO\n\nIn other words, making worktree absolute should work (core.worktree is\nalways set absolute by git-init).\n-- \nDuy\n"}]}