{"thread":{"id":"8049","subject":"[PATCH] checkout: allow full refnames for local branches","startedAt":"2007-05-09T08:40:03Z","lastAt":"2007-05-09T20:38:26Z","messageCount":9,"participants":["Lars Hjemli","Junio C Hamano","Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"41555","messageId":"11787000032830-git-send-email-hjemli@gmail.com","threadId":"8049","inReplyTo":null,"subject":"[PATCH] checkout: allow full refnames for local branches","fromName":"Lars Hjemli","fromEmail":"hjemli@gmail.com","sentAt":"2007-05-09T08:40:03Z","receivedAt":"2007-05-09T08:40:03Z","isPatch":true,"sender":{"key":"hjemli@gmail.com","avatar":null},"body":"This teaches git-checkout to strip the prefix 'refs/heads/' from the\nsupplied <branch> argument, to make\n\n\tgit-checkout refs/heads/master\n\nbehave like\n\n\tgit-checkout master\n\nThe former command would detach HEAD.\n\nSigned-off-by: Lars Hjemli <hjemli@gmail.com>\n---\n\nI'm undecided on wheter this is a bugfix or a new feature. It certainly\nintroduces new behaviour, but it passes all the tests.\n\n git-checkout.sh |    1 +\n 1 files changed, 1 insertions(+), 0 deletions(-)\n\ndiff --git a/git-checkout.sh b/git-checkout.sh\nindex ed7c2c5..6ff7b6e 100755\n--- a/git-checkout.sh\n+++ b/git-checkout.sh\n@@ -63,6 +63,7 @@ while [ \"$#\" != \"0\" ]; do\n \t\t\t\techo \"unknown flag $arg\"\n \t\t\t\texit 1\n \t\t\tfi\n+\t\t\targ=$(echo \"$arg\" | sed -e \"s|^refs/heads/||\")\n \t\t\tnew=\"$rev\"\n \t\t\tnew_name=\"$arg\"\n \t\t\tif git-show-ref --verify --quiet -- \"refs/heads/$arg\"\n-- \n1.5.2.rc2.21.g3082a\n"},{"id":"41558","messageId":"7v7iriwfeu.fsf@assigned-by-dhcp.cox.net","threadId":"8049","inReplyTo":"11787000032830-git-send-email-hjemli@gmail.com","subject":"Re: [PATCH] checkout: allow full refnames for local branches","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-05-09T08:48:57Z","receivedAt":"2007-05-09T08:48:57Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Lars Hjemli <hjemli@gmail.com> writes:\n\n> This teaches git-checkout to strip the prefix 'refs/heads/' from the\n> supplied <branch> argument, to make\n>\n> \tgit-checkout refs/heads/master\n>\n> behave like\n>\n> \tgit-checkout master\n>\n> The former command would detach HEAD.\n>\n> Signed-off-by: Lars Hjemli <hjemli@gmail.com>\n> ---\n>\n> I'm undecided on wheter this is a bugfix or a new feature. It certainly\n> introduces new behaviour, but it passes all the tests.\n\nWhy is this necessary, may I ask?\n"},{"id":"41561","messageId":"8c5c35580705090207y2979aaa5u7ce9de5fa1dfe658@mail.gmail.com","threadId":"8049","inReplyTo":"7v7iriwfeu.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] checkout: allow full refnames for local branches","fromName":"Lars Hjemli","fromEmail":"hjemli@gmail.com","sentAt":"2007-05-09T09:07:32Z","receivedAt":"2007-05-09T09:07:32Z","isPatch":true,"sender":{"key":"hjemli@gmail.com","avatar":null},"body":"On 5/9/07, Junio C Hamano <junkio@cox.net> wrote:\n> Lars Hjemli <hjemli@gmail.com> writes:\n>\n> > This teaches git-checkout to strip the prefix 'refs/heads/' from the\n> > supplied <branch> argument\n>\n> Why is this necessary, may I ask?\n>\n\nI'm playing around with a gui frontend, and there I use\ngit-for-each-ref to obtain possible arguments for git-checkout. That's\nhow I discovered the 'problem', and solved it by stripping\n'refs/heads/' in my frontend. But then I thought it would be nice if\n'git-checkout' did the stripping on my behalf, since this might bite\nothers too :)\n\n-- \nlarsh\n"},{"id":"41642","messageId":"20070509185440.GB3141@spearce.org","threadId":"8049","inReplyTo":"8c5c35580705090207y2979aaa5u7ce9de5fa1dfe658@mail.gmail.com","subject":"Re: [PATCH] checkout: allow full refnames for local branches","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-05-09T18:54:40Z","receivedAt":"2007-05-09T18:54:40Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Lars Hjemli <hjemli@gmail.com> wrote:\n> I'm playing around with a gui frontend, and there I use\n> git-for-each-ref to obtain possible arguments for git-checkout. That's\n> how I discovered the 'problem', and solved it by stripping\n> 'refs/heads/' in my frontend. But then I thought it would be nice if\n> 'git-checkout' did the stripping on my behalf, since this might bite\n> others too :)\n\nIf you are building \"porcelain\" to sit over Git and offer up a pretty\nview of things, I would encourage you to avoid the stock porcelain.\nDon't use git-checkout, its stock porcelain.  Instead go right to\nthe plumbing.  The plumbing doesn't really change behavior as often\n(if ever).\n\nYou can see in git-checkout.sh what actions you need to perform,\nbut its really quite simple if there's no file-level merge involved.\nHere's the relevent bits from git-gui:\n\n    set cmd [list git read-tree]\n    lappend cmd -m\n    lappend cmd -u\n    lappend cmd --exclude-per-directory=.gitignore\n    lappend cmd $HEAD\n    lappend cmd $new_branch\n    set fd_rt [open \"| $cmd\" r]\n    fconfigure $fd_rt -blocking 0 -translation binary\n    fileevent $fd_rt readable \\\n        [list switch_branch_readtree_wait $fd_rt $new_branch]\n\n    ...\n    git symbolic-ref HEAD \"refs/heads/$new_branch\"\n\nReally all I'm doing is building up an argument list for git\nread-tree, passing it the commit that is currently in HEAD and the\ncommit I want to switch to ($new_branch), and then I wait for it\nto finish its job.  When its done, I run git symbolic-ref to update\nthe current branch name.\n\n-- \nShawn.\n"},{"id":"41646","messageId":"7v8xbxu6u0.fsf@assigned-by-dhcp.cox.net","threadId":"8049","inReplyTo":"8c5c35580705090207y2979aaa5u7ce9de5fa1dfe658@mail.gmail.com","subject":"Re: [PATCH] checkout: allow full refnames for local branches","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-05-09T19:37:11Z","receivedAt":"2007-05-09T19:37:11Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Lars Hjemli\" <hjemli@gmail.com> writes:\n\n> On 5/9/07, Junio C Hamano <junkio@cox.net> wrote:\n>> Lars Hjemli <hjemli@gmail.com> writes:\n>>\n>> > This teaches git-checkout to strip the prefix 'refs/heads/' from the\n>> > supplied <branch> argument\n>>\n>> Why is this necessary, may I ask?\n>>\n>\n> I'm playing around with a gui frontend, and there I use\n> git-for-each-ref to obtain possible arguments for git-checkout. That's\n> how I discovered the 'problem', and solved it by stripping\n> 'refs/heads/' in my frontend.\n\nPathspec-less variant of \"git checkout\" takes two kinds of\nparameters and has two flavours in its behaviour:\n\n (1) an exact branch name, in which case it switches to the\n     branch; otherwise\n\n (2) any arbitrary commit object name, in whch case it checks\n     out and detaches HEAD.\n\nA tricky part is that an exact branch name is often a perfectly\nvalid commit object name, so rule (1) trumps the rule (2).  You\njust discovered a way to have a detached HEAD at a commit that\nhappens to be at an existing branch -- by naming that commit\nwithout using its exact branch name.\n\nAn easier way to spell that would be:\n\n\t$ git checkout master^0\n\nbut\n\n\tmaster^0\n        heads/master\n        refs/heads/master\n\nare all perfectly good ways to talk about the commit at the tip\nof the 'master' branch without spelling it as an exact\nbranch name (which is 'master').\n"},{"id":"41648","messageId":"8c5c35580705091255v2f85db3qcbf65904c278d17@mail.gmail.com","threadId":"8049","inReplyTo":"7v8xbxu6u0.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] checkout: allow full refnames for local branches","fromName":"Lars Hjemli","fromEmail":"hjemli@gmail.com","sentAt":"2007-05-09T19:55:53Z","receivedAt":"2007-05-09T19:55:53Z","isPatch":true,"sender":{"key":"hjemli@gmail.com","avatar":null},"body":"On 5/9/07, Junio C Hamano <junkio@cox.net> wrote:\n> \"Lars Hjemli\" <hjemli@gmail.com> writes:\n>\n> > On 5/9/07, Junio C Hamano <junkio@cox.net> wrote:\n> >> Lars Hjemli <hjemli@gmail.com> writes:\n> >>\n> >> > This teaches git-checkout to strip the prefix 'refs/heads/' from the\n> >> > supplied <branch> argument\n> >>\n> >> Why is this necessary, may I ask?\n> >>\n> >\n> > I'm playing around with a gui frontend, and there I use\n> > git-for-each-ref to obtain possible arguments for git-checkout. That's\n> > how I discovered the 'problem', and solved it by stripping\n> > 'refs/heads/' in my frontend.\n>\n> Pathspec-less variant of \"git checkout\" takes two kinds of\n> parameters and has two flavours in its behaviour:\n>\n>  (1) an exact branch name, in which case it switches to the\n>      branch; otherwise\n>\n>  (2) any arbitrary commit object name, in whch case it checks\n>      out and detaches HEAD.\n>\n> A tricky part is that an exact branch name is often a perfectly\n> valid commit object name, so rule (1) trumps the rule (2).  You\n> just discovered a way to have a detached HEAD at a commit that\n> happens to be at an existing branch -- by naming that commit\n> without using its exact branch name.\n\nOk. But if this is intended behaviour, maybe we would want do change\nthe detach-message in this case:\n\n[~/src/git] next$ git checkout refs/heads/master\nNote: moving to \"refs/heads/master\" which isn't a local branch\n\n(sorry for stealing your time with this unimportant stuff, it just\nsurprised me that refs/heads/$branch wasn't treated as a local branch\nname)\n\n-- \nlarsh\n"},{"id":"41649","messageId":"8c5c35580705091301s19dcd2e0q20a4c84e3dd23d82@mail.gmail.com","threadId":"8049","inReplyTo":"20070509185440.GB3141@spearce.org","subject":"Re: [PATCH] checkout: allow full refnames for local branches","fromName":"Lars Hjemli","fromEmail":"hjemli@gmail.com","sentAt":"2007-05-09T20:01:22Z","receivedAt":"2007-05-09T20:01:22Z","isPatch":true,"sender":{"key":"hjemli@gmail.com","avatar":null},"body":"On 5/9/07, Shawn O. Pearce <spearce@spearce.org> wrote:\n> Lars Hjemli <hjemli@gmail.com> wrote:\n> > I'm playing around with a gui frontend, and there I use\n> > git-for-each-ref to obtain possible arguments for git-checkout. That's\n> > how I discovered the 'problem', and solved it by stripping\n> > 'refs/heads/' in my frontend. But then I thought it would be nice if\n> > 'git-checkout' did the stripping on my behalf, since this might bite\n> > others too :)\n>\n> If you are building \"porcelain\" to sit over Git and offer up a pretty\n> view of things, I would encourage you to avoid the stock porcelain.\n> Don't use git-checkout, its stock porcelain.  Instead go right to\n> the plumbing.  The plumbing doesn't really change behavior as often\n> (if ever).\n\nThanks, I probably will (also to avoid the shell scripts, since my\nporcelain is aimed at my co-workers who are stuck on windows)\n\n-- \nlarsh\n"},{"id":"41652","messageId":"20070509201105.GF3141@spearce.org","threadId":"8049","inReplyTo":"8c5c35580705091301s19dcd2e0q20a4c84e3dd23d82@mail.gmail.com","subject":"Re: [PATCH] checkout: allow full refnames for local branches","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-05-09T20:11:05Z","receivedAt":"2007-05-09T20:11:05Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Lars Hjemli <hjemli@gmail.com> wrote:\n> On 5/9/07, Shawn O. Pearce <spearce@spearce.org> wrote:\n> >If you are building \"porcelain\" to sit over Git and offer up a pretty\n> >view of things, I would encourage you to avoid the stock porcelain.\n> >Don't use git-checkout, its stock porcelain.  Instead go right to\n> >the plumbing.  The plumbing doesn't really change behavior as often\n> >(if ever).\n> \n> Thanks, I probably will (also to avoid the shell scripts, since my\n> porcelain is aimed at my co-workers who are stuck on windows)\n\nAre you building a strictly Win32 native GUI?  Or something else?\nCan I ask what sort of features you are going after?  (And if\nthere's a git repository available, feel free to just point me at\nit and ignore my questions.)\n\nI'm just curious.  We seem to have a lot of user interface projects\ngoing on at once right now (Eclipse plugin, git-gui, gitk, qgit, tig,\ngitweb, blameview) and everyone's been learning from each other.\nI think the competition is good, there's no clear right way to do\nthings here.  As the primary author of git-gui, I do want to try\nand keep current with what the others are up to.  ;-)\n\n-- \nShawn.\n"},{"id":"41661","messageId":"8c5c35580705091338r63acc7aaw43248ad246670e8b@mail.gmail.com","threadId":"8049","inReplyTo":"20070509201105.GF3141@spearce.org","subject":"Re: [PATCH] checkout: allow full refnames for local branches","fromName":"Lars Hjemli","fromEmail":"hjemli@gmail.com","sentAt":"2007-05-09T20:38:26Z","receivedAt":"2007-05-09T20:38:26Z","isPatch":true,"sender":{"key":"hjemli@gmail.com","avatar":null},"body":"On 5/9/07, Shawn O. Pearce <spearce@spearce.org> wrote:\n> Lars Hjemli <hjemli@gmail.com> wrote:\n> > On 5/9/07, Shawn O. Pearce <spearce@spearce.org> wrote:\n> > >If you are building \"porcelain\" to sit over Git and offer up a pretty\n> > >view of things, I would encourage you to avoid the stock porcelain.\n> > >Don't use git-checkout, its stock porcelain.  Instead go right to\n> > >the plumbing.  The plumbing doesn't really change behavior as often\n> > >(if ever).\n> >\n> > Thanks, I probably will (also to avoid the shell scripts, since my\n> > porcelain is aimed at my co-workers who are stuck on windows)\n>\n> Are you building a strictly Win32 native GUI?  Or something else?\n\nIt's mono/.net, so I can test it on my linux box and push the binary\ndirectly to the poor souls on windows :)\n\n> Can I ask what sort of features you are going after?  (And if\n> there's a git repository available, feel free to just point me at\n> it and ignore my questions.)\n\nThe features I'm focusing on are mostly trivial day-to-day operations\nof your average coder: status, diff, commit, push, fetch, merge,\ncheckout, log. This should be enough to support our (planned) workflow\nof one public repo per developer + a shared integration repo with\nrestricted push access + active use of topic-branches.\n\nWe currently use subversion, so real branches + real merges are killer\narguments for a switch to git. But we also use tortoisesvn, and the\n\"simplicity\" of the gui must be met by some tool. Hence me playing\naround....\n\nIf/when it becomes useful, I'll put it up on http://hjemli.net/git/\n\n\n> I'm just curious.  We seem to have a lot of user interface projects\n> going on at once right now (Eclipse plugin, git-gui, gitk, qgit, tig,\n> gitweb, blameview) and everyone's been learning from each other.\n\nHeh, I actually considered calling it yagg (but it doesn't deserve a name yet)\n\n\n> I think the competition is good, there's no clear right way to do\n> things here.  As the primary author of git-gui, I do want to try\n> and keep current with what the others are up to.  ;-)\n\nAbsolutely, nice work btw.\n\n\n-- \nlarsh\n"}]}