{"thread":{"id":"2735","subject":"Is reserving the branch name \"bisect\" a good thing?","startedAt":"2005-12-02T23:25:55Z","lastAt":"2005-12-03T19:15:07Z","messageCount":4,"participants":["linux@horizon.com","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"13126","messageId":"20051202232555.13082.qmail@science.horizon.com","threadId":"2735","inReplyTo":null,"subject":"Is reserving the branch name \"bisect\" a good thing?","fromName":"","fromEmail":"linux@horizon.com","sentAt":"2005-12-02T23:25:55Z","receivedAt":"2005-12-02T23:25:55Z","isPatch":false,"sender":{"key":"linux@horizon.com","avatar":null},"body":"Just wondering... most of the \"magic\" references are in $GIT_DIR\ndirectly, and ALL_CAPS.  \"git bisect start\" begins with\n\"rm -f $GIT_DIR/refs/heads/bisect\", which could catch someone\ntrying to implement a bisection algorithm in their own code.\n\nWould it be better if \"git bisect\" followed that rule as well?\nOtherwise, we really should document the reserved word.\n\nEither that, or use refs/bisect/current and avoid the issue entirely.\n\nSomething like (untested):\n\ndiff --git a/git-bisect.sh b/git-bisect.sh\nindex 68838f3..19a8f36 100755\n--- a/git-bisect.sh\n+++ b/git-bisect.sh\n@@ -50,7 +50,7 @@ bisect_start() {\n \thead=$(GIT_DIR=\"$GIT_DIR\" git-symbolic-ref HEAD) ||\n \tdie \"Bad HEAD - I need a symbolic ref\"\n \tcase \"$head\" in\n-\trefs/heads/bisect*)\n+\tBISECT*)\n \t\tgit checkout master || exit\n \t\t;;\n \trefs/heads/*)\n@@ -63,7 +63,7 @@ bisect_start() {\n \t#\n \t# Get rid of any old bisect state\n \t#\n-\trm -f \"$GIT_DIR/refs/heads/bisect\"\n+\trm -f \"$GIT_DIR/BISECT\"\n \trm -rf \"$GIT_DIR/refs/bisect/\"\n \tmkdir \"$GIT_DIR/refs/bisect\"\n \t{\n@@ -146,10 +146,10 @@ bisect_next() {\n \tfi\n \tnr=$(eval \"git-rev-list $rev $good -- $(cat $GIT_DIR/BISECT_NAMES)\" | wc -l) || exit\n \techo \"Bisecting: $nr revisions left to test after this\"\n-\techo \"$rev\" > \"$GIT_DIR/refs/heads/new-bisect\"\n-\tgit checkout new-bisect || exit\n-\tmv \"$GIT_DIR/refs/heads/new-bisect\" \"$GIT_DIR/refs/heads/bisect\" &&\n-\tGIT_DIR=\"$GIT_DIR\" git-symbolic-ref HEAD refs/heads/bisect\n+\techo \"$rev\" > \"$GIT_DIR/NEW-BISECT\"\n+\tgit checkout NEW-BISECT || exit\n+\tmv \"$GIT_DIR/NEW-BISECT\" \"$GIT_DIR/BISECT\" &&\n+\tGIT_DIR=\"$GIT_DIR\" git-symbolic-ref HEAD BISECT\n \tgit-show-branch \"$rev\"\n }\n \n@@ -172,7 +172,7 @@ bisect_reset() {\n \tesac\n \tgit checkout \"$branch\" &&\n \trm -fr \"$GIT_DIR/refs/bisect\"\n-\trm -f \"$GIT_DIR/refs/heads/bisect\"\n+\trm -f \"$GIT_DIR/BISECT\"\n \trm -f \"$GIT_DIR/BISECT_LOG\"\n }\n \n"},{"id":"13127","messageId":"loom.20051203T004324-557@post.gmane.org","threadId":"2735","inReplyTo":"20051202232555.13082.qmail@science.horizon.com","subject":"Re: Is reserving the branch name \"bisect\" a good thing?","fromName":"Junio C Hamano","fromEmail":"junkio@twinsun.com","sentAt":"2005-12-02T23:44:07Z","receivedAt":"2005-12-02T23:44:07Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":" <linux <at> horizon.com> writes:\n\n> Would it be better if \"git bisect\" followed that rule as well?\n> Otherwise, we really should document the reserved word.\n\nI wonder if you broke \"git bisect visualize\" with that patch.\n"},{"id":"13144","messageId":"20051203134136.31524.qmail@science.horizon.com","threadId":"2735","inReplyTo":"20051202232555.13082.qmail@science.horizon.com","subject":"Re: Is reserving the branch name \"bisect\" a good thing?","fromName":"","fromEmail":"linux@horizon.com","sentAt":"2005-12-03T13:41:36Z","receivedAt":"2005-12-03T13:41:36Z","isPatch":false,"sender":{"key":"linux@horizon.com","avatar":null},"body":">> Would it be better if \"git bisect\" followed that rule as well?\n>> Otherwise, we really should document the reserved word.\n\n> I wonder if you broke \"git bisect visualize\" with that patch.\n\nI don't know, but I sure broke git-bisect.\n\nThe problem is that git-checkout won't switch branches if the\nref given is not in $GIT_DIR/refs/heads.  (Try to include a \"heads/\"\nprefix on a non-selected existing branch to see.)\n\nWithout changing this policy in git-checkout, or replicating most\nof git-checkout's code in git-bisect, I can't get away from using\na head name in refs/heads/.  :-(\n\nStepping back, the problem is that\n- git has a policy against allowing checkins against a ref not in refs/heads/\n- git-commit doesn't have a concept of an unwriteable HEAD, so\n- git-checkout refuses to set HEAD to an unwriteable ref (not in refs/heads/)\nBut \"git bisect\" wants exactly this sort of historical snapshot.\n\nActually, this leads to a question... suppose I want to manually\ncheck out some old revision (like \"v.2.6.12\") for some reason\n(performance testing, say).  How do I do that?\nDo I have to create a branch just to do that?\n\nIt might be nicer to allow such a checkout and do the checking in\ngit-commit, telling you to \"git-checkout -b <new_branch>\" before\nyou check in your edits.\n\n\nIn git-bisect, I finally managed to do a bit of a hack, but it's\na bit annoying for doing the above from the command line.\n(Error handling could also probably use improvement.)\n\nSee the \"@@ -146,10 +160,12 @@ bisect_next() {\" chunk, third\nfrom the end, for the meat.\n\n\ndiff --git a/git-bisect.sh b/git-bisect.sh\nindex 68838f3..c8b9d7b 100755\n--- a/git-bisect.sh\n+++ b/git-bisect.sh\n@@ -1,6 +1,9 @@\n #!/bin/sh\n . git-sh-setup\n \n+# Put arguments in single quotes to they can be re-interpreted by the shell.\n+# (To put a single quote in a single-quoted string, you need to write\n+# 'wasn'\\''t' = 'wasn' + \\' + 't'.)\n sq() {\n \tperl -e '\n \t\tfor (@ARGV) {\n@@ -42,6 +45,18 @@ bisect_autostart() {\n \t}\n }\n \n+# Not generally needed, but provide a cleanup function\n+bisect_stop() {\n+\tcase \"$(cat \"$GIT_DIR/HEAD\")\" in\n+\trefs/bisect/*)\n+\t\techo \"Resetting HEAD to master\"\n+\t\tgit checkout master || exit\n+\t\t;;\n+\tesac\n+\trm -rf \"$GIT_DIR/refs/bisect/\"\n+\trm -f \"$GIT_DIR/BISECT_LOG\" \"$GIT_DIR/BISECT_NAMES\"\n+}\n+\n bisect_start() {\n \t#\n \t# Verify HEAD. If we were bisecting before this, reset to the\n@@ -50,7 +65,7 @@ bisect_start() {\n \thead=$(GIT_DIR=\"$GIT_DIR\" git-symbolic-ref HEAD) ||\n \tdie \"Bad HEAD - I need a symbolic ref\"\n \tcase \"$head\" in\n-\trefs/heads/bisect*)\n+\trefs/bisect/*)\n \t\tgit checkout master || exit\n \t\t;;\n \trefs/heads/*)\n@@ -63,7 +78,6 @@ bisect_start() {\n \t#\n \t# Get rid of any old bisect state\n \t#\n-\trm -f \"$GIT_DIR/refs/heads/bisect\"\n \trm -rf \"$GIT_DIR/refs/bisect/\"\n \tmkdir \"$GIT_DIR/refs/bisect\"\n \t{\n@@ -146,10 +160,12 @@ bisect_next() {\n \tfi\n \tnr=$(eval \"git-rev-list $rev $good -- $(cat $GIT_DIR/BISECT_NAMES)\" | wc -l) || exit\n \techo \"Bisecting: $nr revisions left to test after this\"\n-\techo \"$rev\" > \"$GIT_DIR/refs/heads/new-bisect\"\n-\tgit checkout new-bisect || exit\n-\tmv \"$GIT_DIR/refs/heads/new-bisect\" \"$GIT_DIR/refs/heads/bisect\" &&\n-\tGIT_DIR=\"$GIT_DIR\" git-symbolic-ref HEAD refs/heads/bisect\n+\tnext=\"$(TMPDIR=\"$GIT_DIR/refs/heads\" tempfile -p bisect)\"\n+\techo \"$rev\" > \"$next\"\n+\t# checkout refuses to deal with a head name not in refs/heads...\n+\tgit checkout $(basename \"$next\")\n+\tmv \"$next\" \"$GIT_DIR/refs/bisect/current\" &&\n+\tGIT_DIR=\"$GIT_DIR\" git-symbolic-ref HEAD refs/bisect/current\n \tgit-show-branch \"$rev\"\n }\n \n@@ -172,7 +188,6 @@ bisect_reset() {\n \tesac\n \tgit checkout \"$branch\" &&\n \trm -fr \"$GIT_DIR/refs/bisect\"\n-\trm -f \"$GIT_DIR/refs/heads/bisect\"\n \trm -f \"$GIT_DIR/BISECT_LOG\"\n }\n \n@@ -217,6 +232,8 @@ case \"$#\" in\n     case \"$cmd\" in\n     start)\n         bisect_start \"$@\" ;;\n+    stop)\n+        bisect_stop \"$@\" ;;\n     bad)\n         bisect_bad \"$@\" ;;\n     good)\n"},{"id":"13149","messageId":"7vbqzyxa9w.fsf@assigned-by-dhcp.cox.net","threadId":"2735","inReplyTo":"20051203134136.31524.qmail@science.horizon.com","subject":"Re: Is reserving the branch name \"bisect\" a good thing?","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-12-03T19:15:07Z","receivedAt":"2005-12-03T19:15:07Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"linux@horizon.com writes:\n\n> Without changing this policy in git-checkout, or replicating most\n> of git-checkout's code in git-bisect, I can't get away from using\n> a head name in refs/heads/.  :-(\n\nI tend to think the above \"restriction\" a conscious design decision.\n\n> Actually, this leads to a question... suppose I want to manually\n> check out some old revision (like \"v.2.6.12\") for some reason\n> (performance testing, say).  How do I do that?\n> Do I have to create a branch just to do that?\n\nAbsolutely, and that is deliberately so.  You do not want to:\n\n\tgit checkout v2.6.12\n        work work work\n        git commit\n\nand move tag v2.6.12 to something that is not v2.6.12.  As you\noutlined, that \"not moving the tag\" check can be done in git\ncommit and have the user do:\n\n\tgit checkout v2.6.12\n        work work work\n        git commit ;# fails\n\tgit checkout -b oops-i-needed-a-branch-after-all\n\tgit commit\n\nbut that feels ugly and wrong.\n\nBranches are cheap (just a single file which is a pointer), so\nif you prefer neatness:\n\n\tgit checkout -b test-build v2.6.12\n        work work work\n        git checkout master ;# when you are done\n        git branch -d test-build\n\nOr if you are lazy like me, just keep a single throwaway branch\naround, and whenever you feel like:\n\n\tgit branch -f ta v2.6.12\n        git checkout ta\n        work work work\n        git checkout master ;# when you are done\n\nTo test and possibly further develop the git-daemon update topic\nbranch, which is two revs before the tip of proposed updates\nbranch:\n\n\tgit branch -f daemon-updates pu~2\n        git checkout daemon-updates\n        make\n\twork work work, find problems and do enhancements\n        git commit\n\nthen you can say \"Hey, Junio I found problem in your daemon\nupdates topic branch, and if you want my fixes you can pull from\nmy daemon-updates branch\".\n\n> It might be nicer to allow such a checkout and do the checking in\n> git-commit, telling you to \"git-checkout -b <new_branch>\" before\n> you check in your edits.\n\nThat may be, but it is too confusing.  Everybody needs to be\naware HEAD can point at random place, not necessarily on some\nbranch.  You happen to have noticed git-commit wants HEAD to be\npointing at a branch and no other random place, but are you\nabsolutely sure no other tools care?  I don't.\n\n> +# Not generally needed, but provide a cleanup function\n> +bisect_stop() {\n\nWhy isn't this part of bisect reset?\n"}]}