{"thread":{"id":"200","subject":"[PATCH] Allow \"git cancel\" to change branches","startedAt":"2005-04-21T13:31:24Z","lastAt":"2005-04-21T20:00:09Z","messageCount":3,"participants":["Matthias Urlichs","Petr Baudis","Pavel Roskin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"1127","messageId":"E1DObsr-0006Au-MA@server.smurf.noris.de","threadId":"200","inReplyTo":null,"subject":"[PATCH] Allow \"git cancel\" to change branches","fromName":"Matthias Urlichs","fromEmail":"smurf@smurf.noris.de","sentAt":"2005-04-21T13:31:24Z","receivedAt":"2005-04-21T13:31:24Z","isPatch":true,"sender":{"key":"matthias@urlichs.de","avatar":"https://gravatar.com/avatar/2708905af227313eba6f2b2ae0f7d0259b5ac5d71baef58fe5a13c699ce0bbf0?d=mp&s=160"},"body":"\"git cancel\" may not be named correctly for this job, but it does almost\neverything you'd need for switching between one branch and another\nwithin a repository, so...\n\nSigned-Off-By: Matthias Urlichs <smurf@smurf.noris.de>\n\n--- f29be8140c5f1175052ec96ad2fa2b2901fd6ba5/git  (mode:100755 sha1:5f23301eb97a0fadd505a6e9cc851e98741a512a)\n+++ 42a073eb6b5bb397a3e8768a032463a7fa02e6b9/git  (mode:100755 sha1:557122dfb05580e4af2c55767f3d6f92b9110edd)\n@@ -28,7 +28,7 @@\n \tadd\t\tFILE...\n \taddremote\tRNAME RSYNC_URL\n \tapply\t\t\t\t< patch on stdin\n-\tcancel\n+\tcancel\t\t[NAME]\n \tci, commit\t[FILE]...\t< log message on stdin\n \tdiff\t\t[-p] [-r FROM_ID[:TO_ID]] [FILE]...\n \texport\t\tDESTDIR [TREE_ID]\nIndex: gitcancel.sh\n===================================================================\n--- f29be8140c5f1175052ec96ad2fa2b2901fd6ba5/gitcancel.sh  (mode:100755 sha1:a78cf8ccab98861ef7aecb4cb5a79e47d3a84b67)\n+++ 42a073eb6b5bb397a3e8768a032463a7fa02e6b9/gitcancel.sh  (mode:100755 sha1:2fc3e522132ef6a5f71352ab67005c93b5efc04f)\n@@ -9,6 +9,9 @@\n # Basically, this is the opposite of git commit in some sense.\n #\n # Takes no arguments and the evil changes from the tree.\n+# \n+# ... actually, if you do give it an argument, it'll switch the HEAD to\n+# that branch -- or create a new one.\n \n [ -s \".git/add-queue\" ] && rm $(cat .git/add-queue)\n rm -f .git/add-queue .git/rm-queue\n@@ -29,6 +32,11 @@\n \tfi\n fi\n \n+if [ \"$1\" ] ; then\n+\ttest -f .git/heads/$1 || cp .git/HEAD .git/heads/$1\n+\tln -sf \"heads/$1\" .git/HEAD\n+fi\n+\n rm -f .git/blocked .git/merging .git/merging-sym .git/merge-base\n read-tree $(tree-id)\n \n"},{"id":"1139","messageId":"20050421160526.GB30991@pasky.ji.cz","threadId":"200","inReplyTo":"E1DObsr-0006Au-MA@server.smurf.noris.de","subject":"Re: [PATCH] Allow \"git cancel\" to change branches","fromName":"Petr Baudis","fromEmail":"pasky@ucw.cz","sentAt":"2005-04-21T16:05:26Z","receivedAt":"2005-04-21T16:05:26Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Thu, Apr 21, 2005 at 03:31:24PM CEST, I got a letter\nwhere Matthias Urlichs <smurf@smurf.noris.de> told me that...\n> \"git cancel\" may not be named correctly for this job, but it does almost\n> everything you'd need for switching between one branch and another\n> within a repository, so...\n\nNO. That is something completely different, although technically it can\nlook similar.\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nC++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor\n"},{"id":"1183","messageId":"1114113609.29603.24.camel@dv","threadId":"200","inReplyTo":"E1DObsr-0006Au-MA@server.smurf.noris.de","subject":"Re: [PATCH] Allow \"git cancel\" to change branches","fromName":"Pavel Roskin","fromEmail":"proski@gnu.org","sentAt":"2005-04-21T20:00:09Z","receivedAt":"2005-04-21T20:00:09Z","isPatch":true,"sender":{"key":"proski@gnu.org","avatar":null},"body":"Hi, Matthias!\n\nOn Thu, 2005-04-21 at 23:31 +1000, Matthias Urlichs wrote:\n> \"git cancel\" may not be named correctly for this job, but it does almost\n> everything you'd need for switching between one branch and another\n> within a repository, so...\n\nThis functionality is badly needed, but \"git cancel\" should probably\nremain what it is.\n\n> +if [ \"$1\" ] ; then\n> +\ttest -f .git/heads/$1 || cp .git/HEAD .git/heads/$1\n> +\tln -sf \"heads/$1\" .git/HEAD\n> +fi\n\nConsidering that the patch is essentially just this block of code, it\ncould be (in the first approximation) a separate command, e.g. \"git\nswitch\", that would call \"git cancel\" if needed.\n\nBut let's consider the fact that \"git cancel\" removes all local changes.\nThat's quite a serious side effect.  I don't always want to remove local\nchanges when I switch between branches in CVS.  Many users would prefer\ngit to do a merge.\n\nI think that \"git track\" needs to be redesigned.  There are at least\nthree properties of the working directory (related to branch tracking)\nthat users may want to change:\n\n1) Where new revisions are pulled from.  It could be more than one\nbranch (ideal implementation - with several copies of rsync run\nsimultaneously).\n\n2) What branch is \"checked out\" to the working directory, i.e. what\nbranch would \"git cancel\" restore.\n\n3) Whether new changes are merged automatically.\n\nI suggest following syntax:\n\ngit track -b WORKING-BRANCH [--cancel] [--active|--passive]\n[TRACK-BRANCH...|--notrack]\n\n--cancel would cancel changes rather than merge when the current branch\nchanges.\n\n--active enables automerge, --passive disables it\n\nEmpty list of branches to track should not disable tracking.  Only\n--notrack should do it.\n\nThen your \"git cancel BRANCH\" would become:\ngit track -b BRANCH --cancel\n\n-- \nRegards,\nPavel Roskin\n\n"}]}