{"thread":{"id":"31863","subject":"git subtree error (just how do you expect me to merge 0 trees?)","startedAt":"2012-10-18T23:04:57Z","lastAt":"2013-01-01T05:54:01Z","messageCount":7,"participants":["Drew Crawford","greened@obbligato.org","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"201536","messageId":"FBE22FDC-5800-40C8-9778-82DFD27579F6@drewcrawfordapps.com","threadId":"31863","inReplyTo":null,"subject":"git subtree error (just how do you expect me to merge 0 trees?)","fromName":"Drew Crawford","fromEmail":"drew@drewcrawfordapps.com","sentAt":"2012-10-18T23:04:57Z","receivedAt":"2012-10-18T23:04:57Z","isPatch":false,"sender":{"key":"drew@drewcrawfordapps.com","avatar":null},"body":"I noticed today that if you leave off the branch name from git subtree like so:\n\n$ git subtree add --prefix somewhere -m \"adding CDH as subtree\" path/to/repo\nwarning: read-tree: emptying the index with no arguments is deprecated; use --empty\nfatal: just how do you expect me to merge 0 trees?\n\nThe error message is not particularly helpful (and seems to actually be in read-subtree?)  The solution in my case was to add the branch name on the end of the command.\n\nIdeally it would be better to emit an error-message from a script higher up the calling chain that would be more descriptive about the problem (such as suggesting no branch is specified)."},{"id":"205722","messageId":"87wqvx3cel.fsf@waller.obbligato.org","threadId":"31863","inReplyTo":"FBE22FDC-5800-40C8-9778-82DFD27579F6@drewcrawfordapps.com","subject":"Re: git subtree error (just how do you expect me to merge 0 trees?)","fromName":"","fromEmail":"greened@obbligato.org","sentAt":"2013-01-01T01:44:18Z","receivedAt":"2013-01-01T01:44:18Z","isPatch":false,"sender":{"key":"greened@obbligato.org","avatar":"https://avatars.githubusercontent.com/u/5291869?v=4"},"body":"Drew Crawford <drew@drewcrawfordapps.com> writes:\n\n> I noticed today that if you leave off the branch name from git subtree like so:\n>\n> $ git subtree add --prefix somewhere -m \"adding CDH as subtree\" path/to/repo\n> warning: read-tree: emptying the index with no arguments is deprecated; use --empty\n> fatal: just how do you expect me to merge 0 trees?\n>\n> The error message is not particularly helpful (and seems to actually be in read-subtree?)  The solution in my case was to add the branch name on the end of the command.\n>\n> Ideally it would be better to emit an error-message from a script higher up the calling chain that would be more descriptive about the problem (such as suggesting no branch is specified).--\n\nGood idea.  I'll code it up.\n\n                        -David\n"},{"id":"205724","messageId":"87licd3b7w.fsf@waller.obbligato.org","threadId":"31863","inReplyTo":"FBE22FDC-5800-40C8-9778-82DFD27579F6@drewcrawfordapps.com","subject":"Re: git subtree error (just how do you expect me to merge 0 trees?)","fromName":"","fromEmail":"greened@obbligato.org","sentAt":"2013-01-01T02:09:55Z","receivedAt":"2013-01-01T02:09:55Z","isPatch":false,"sender":{"key":"greened@obbligato.org","avatar":"https://avatars.githubusercontent.com/u/5291869?v=4"},"body":"Drew Crawford <drew@drewcrawfordapps.com> writes:\n\n> Ideally it would be better to emit an error-message from a script\n> higher up the calling chain that would be more descriptive about the\n> problem (such as suggesting no branch is specified).--\n\nI'm looking at implementing this but I need a bit of help from the git\nexperts.\n\ngit-subtree add accepts either a refspec or a path to a repository and a\nrefspec.  With one positional option, git-subtree add simply assumes\nit's a refspec.  Is there an easy way to check whether a string is a\nproper refspec?  Even better would be a way to check if a string is a\npath to a git repository.\n\n                         -David\n"},{"id":"205725","messageId":"87ehi539vb.fsf@waller.obbligato.org","threadId":"31863","inReplyTo":"FBE22FDC-5800-40C8-9778-82DFD27579F6@drewcrawfordapps.com","subject":"Re: git subtree error (just how do you expect me to merge 0 trees?)","fromName":"","fromEmail":"greened@obbligato.org","sentAt":"2013-01-01T02:39:04Z","receivedAt":"2013-01-01T02:39:04Z","isPatch":false,"sender":{"key":"greened@obbligato.org","avatar":"https://avatars.githubusercontent.com/u/5291869?v=4"},"body":"Drew Crawford <drew@drewcrawfordapps.com> writes:\n\n> Ideally it would be better to emit an error-message from a script\n> higher up the calling chain that would be more descriptive about the\n> problem (such as suggesting no branch is specified).--\n\nOk, I used git rev-parse --verify and I have this working now.  Will\nsend to Junio in the batch with fixes from other folks.\n\nThanks for catching this!\n\n                         -David\n"},{"id":"205743","messageId":"7v7gnxd24h.fsf@alter.siamese.dyndns.org","threadId":"31863","inReplyTo":"87licd3b7w.fsf@waller.obbligato.org","subject":"Re: git subtree error (just how do you expect me to merge 0 trees?)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-01-01T03:16:14Z","receivedAt":"2013-01-01T03:16:14Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"greened@obbligato.org writes:\n\n> git-subtree add accepts either a refspec or a path to a repository and a\n> refspec.\n\n> With one positional option, git-subtree add simply assumes\n> it's a refspec.  Is there an easy way to check whether a string is a\n> proper refspec?  Even better would be a way to check if a string is a\n> path to a git repository.\n\nDo you literally mean \"a path to a repository\" in the above, or do\nyou mean \"a remote that is like what is accepted by 'git fetch'\"?\nIf you literary mean it is is a path to a git repository, you could\nobviously use \"cd $there && git rev-parse --git-dir\" or something.\n\nOn the other hand, if you mean the command takes a remote and an\noptional list of refspecs just like \"git fetch\" does, then I am not\nsure it is a good design in the first place to allow \"refspecs\nonly\", if only to keep the interface similar to \"git fetch\" (you\ncannot omit remote and give refspecs, as you cannot interpret\nrefspecs without knowing in the context of which remote they are to\nbe interpreted).\n\nI would imagine you could disambiguate and default to \"origin\" or\nsomething when you guessed that remote was omitted if you really\nwanted to, with a syntacitical heuristics, such as \"a refspec will\nnever have two colons in it\", \"a URL tends to begin with a short\nalphabet word, a colon and double-slash\", etc.\n"},{"id":"205754","messageId":"87d2xpwnty.fsf@waller.obbligato.org","threadId":"31863","inReplyTo":"7v7gnxd24h.fsf@alter.siamese.dyndns.org","subject":"Re: git subtree error (just how do you expect me to merge 0 trees?)","fromName":"","fromEmail":"greened@obbligato.org","sentAt":"2013-01-01T04:04:41Z","receivedAt":"2013-01-01T04:04:41Z","isPatch":false,"sender":{"key":"greened@obbligato.org","avatar":"https://avatars.githubusercontent.com/u/5291869?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n>> With one positional option, git-subtree add simply assumes\n>> it's a refspec.  Is there an easy way to check whether a string is a\n>> proper refspec?  Even better would be a way to check if a string is a\n>> path to a git repository.\n>\n> Do you literally mean \"a path to a repository\" in the above, or do\n> you mean \"a remote that is like what is accepted by 'git fetch'\"?\n\nIt's the latter as git-subtree calls git-fetch to do the work of\ngetting revisions.\n\n> On the other hand, if you mean the command takes a remote and an\n> optional list of refspecs just like \"git fetch\" does, then I am not\n> sure it is a good design in the first place to allow \"refspecs\n> only\", if only to keep the interface similar to \"git fetch\" (you\n> cannot omit remote and give refspecs, as you cannot interpret\n> refspecs without knowing in the context of which remote they are to\n> be interpreted).\n\nIf just a refspec is given, git-subtree does a rev-parse in the current\ndirectory and that seems to work fine.  It's what I as a user would\nexpect to happen.\n\n> I would imagine you could disambiguate and default to \"origin\" or\n> something when you guessed that remote was omitted if you really\n> wanted to, with a syntacitical heuristics, such as \"a refspec will\n> never have two colons in it\", \"a URL tends to begin with a short\n> alphabet word, a colon and double-slash\", etc.\n\nHmm...I haven't added code to verify the repository/remote argument if\ngiven.  I suppose a rev-parse --verify would suffice?\n\n                        -David\n"},{"id":"205757","messageId":"7vy5gdbg92.fsf@alter.siamese.dyndns.org","threadId":"31863","inReplyTo":"87d2xpwnty.fsf@waller.obbligato.org","subject":"Re: git subtree error (just how do you expect me to merge 0 trees?)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-01-01T05:54:01Z","receivedAt":"2013-01-01T05:54:01Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"greened@obbligato.org writes:\n\n> Junio C Hamano <gitster@pobox.com> writes:\n>\n>>> With one positional option, git-subtree add simply assumes\n>>> it's a refspec.  Is there an easy way to check whether a string is a\n>>> proper refspec?  Even better would be a way to check if a string is a\n>>> path to a git repository.\n>>\n>> Do you literally mean \"a path to a repository\" in the above, or do\n>> you mean \"a remote that is like what is accepted by 'git fetch'\"?\n>\n> It's the latter as git-subtree calls git-fetch to do the work of\n> getting revisions.\n\nIf that is the case, t should behave similar to 'git fetch' for\nconsistency.  If you want to name \"current repository\", you can\nsimply give \".\" as the repository parameter; this has long been\nsupported by 'git fetch' (as 'git pull . $branch' has been the way\nto say 'git merge' for a long time).\n"}]}