{"thread":{"id":"43586","subject":"[PATCH] git-reset [--mixed] <tree> [--] <paths>...","startedAt":"2006-12-14T09:24:47Z","lastAt":"2006-12-14T20:41:39Z","messageCount":4,"participants":["Junio C Hamano","Peter Baumann"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"295730","messageId":"7vwt4u96e8.fsf@assigned-by-dhcp.cox.net","threadId":"43586","inReplyTo":null,"subject":"[PATCH] git-reset [--mixed] <tree> [--] <paths>...","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-12-14T09:24:47Z","receivedAt":"2006-12-14T09:24:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sometimes it is asked on the list how to revert selected path in\nthe index from a tree, most often HEAD, without affecting the\nfiles in the working tree.  A similar operation that also\naffects the working tree files has been available in the form of\n\"git checkout <tree> -- <paths>...\".\n\nBy definition --soft would never affect either the index nor the\nworking tree files, and --hard is the way to make the working\ntree files as close to pristine, so this new option is available\nonly for the default --mixed case.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\n * I haven't looked at Documentation/git-reset.txt recently.  It\n   most likely needs not just addition to describe this new\n   format, but more a heavier rewrite similar to what we made to\n   git-commit documentation recently.\n\n git-reset.sh |   68 +++++++++++++++++++++++++++++++++++++++------------------\n 1 files changed, 46 insertions(+), 22 deletions(-)\n\ndiff --git a/git-reset.sh b/git-reset.sh\nindex 03d2c3b..e95c252 100755\n--- a/git-reset.sh\n+++ b/git-reset.sh\n@@ -1,35 +1,59 @@\n #!/bin/sh\n-\n-USAGE='[--mixed | --soft | --hard]  [<commit-ish>]'\n+#\n+# Copyright (c) 2005, 2006 Linus Torvalds and Junio C Hamano\n+#\n+USAGE='[--mixed | --soft | --hard]  [<commit-ish>] [ [--] <paths>...]'\n SUBDIRECTORY_OK=Yes\n . git-sh-setup\n \n+update= rev= reset_type=--mixed\n+\n+while case $# in 0) break ;; esac\n+do\n+\tcase \"$1\" in\n+\t--mixed | --soft | --hard)\n+\t\treset_type=\"$1\"\n+\t\t;;\n+\t--)\n+\t\tbreak\n+\t\t;;\n+\t-*)\n+\t\tusage\n+\t\t;;\n+\t*)\n+\t\trev=$(git-rev-parse --verify \"$1\") || exit\n+\t\tshift\n+\t\tbreak\n+\t\t;;\n+\tesac\n+\tshift\n+done\n+\n+: ${rev=HEAD}\n+rev=$(git-rev-parse --verify $rev^0) || exit\n+\n+# Skip -- in \"git reset HEAD -- foo\" and \"git reset -- foo\".\n+case \"$1\" in --) shift ;; esac\n+\n+# git reset --mixed tree [--] paths... can be used to\n+# load chosen paths from the tree into the index without\n+# affecting the working tree nor HEAD.\n+if test $# != 0\n+then\n+\ttest \"$reset_type\" == \"--mixed\" ||\n+\t\tdie \"Cannot do partial $reset_type reset.\"\n+\tgit ls-tree -r --full-name $rev -- \"$@\" |\n+\tgit update-index --add --index-info || exit\n+\tgit update-index --refresh\n+\texit\n+fi\n+\n TOP=$(git-rev-parse --show-cdup)\n if test ! -z \"$TOP\"\n then\n \tcd \"$TOP\"\n fi\n \n-update=\n-reset_type=--mixed\n-case \"$1\" in\n---mixed | --soft | --hard)\n-\treset_type=\"$1\"\n-\tshift\n-\t;;\n--*)\n-        usage ;;\n-esac\n-\n-case $# in\n-0) rev=HEAD ;;\n-1) rev=$(git-rev-parse --verify \"$1\") || exit ;;\n-*) usage ;;\n-esac\n-rev=$(git-rev-parse --verify $rev^0) || exit\n-\n-# We need to remember the set of paths that _could_ be left\n-# behind before a hard reset, so that we can remove them.\n if test \"$reset_type\" = \"--hard\"\n then\n \tupdate=-u\n-- \n1.4.4.2.g86bd\n\n"},{"id":"296512","messageId":"7virge94nq.fsf@assigned-by-dhcp.cox.net","threadId":"43586","inReplyTo":"7vwt4u96e8.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] git-reset [--mixed] <tree> [--] <paths>...","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-12-14T10:02:17Z","receivedAt":"2006-12-14T10:02:17Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <junkio@cox.net> writes:\n\n> Sometimes it is asked on the list how to revert selected path in\n> the index from a tree, most often HEAD, without affecting the\n> files in the working tree...\n\nThe patch depends on another one that allows the command to work\nfrom a subdirectory (and also has one bug).  Updated one will\nappear in 'next'.\n"},{"id":"295952","messageId":"slrneo2atm.nqa.Peter.B.Baumann@xp.machine.xx","threadId":"43586","inReplyTo":"7vwt4u96e8.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] git-reset [--mixed] <tree> [--] <paths>...","fromName":"Peter Baumann","fromEmail":"peter.b.baumann@stud.informatik.uni-erlangen.de","sentAt":"2006-12-14T10:47:18Z","receivedAt":"2006-12-14T10:47:18Z","isPatch":true,"sender":{"key":"waste.manager@gmx.de","avatar":null},"body":"On 2006-12-14, Junio C Hamano <junkio@cox.net> wrote:\n> Sometimes it is asked on the list how to revert selected path in\n> the index from a tree, most often HEAD, without affecting the\n> files in the working tree.  A similar operation that also\n> affects the working tree files has been available in the form of\n> \"git checkout <tree> -- <paths>...\".\n>\n> By definition --soft would never affect either the index nor the\n> working tree files, and --hard is the way to make the working\n> tree files as close to pristine, so this new option is available\n> only for the default --mixed case.\n>\n> Signed-off-by: Junio C Hamano <junkio@cox.net>\n> ---\n>\n>  * I haven't looked at Documentation/git-reset.txt recently.  It\n>    most likely needs not just addition to describe this new\n>    format, but more a heavier rewrite similar to what we made to\n>    git-commit documentation recently.\n>\n>  git-reset.sh |   68 +++++++++++++++++++++++++++++++++++++++------------------\n>  1 files changed, 46 insertions(+), 22 deletions(-)\n>\n> diff --git a/git-reset.sh b/git-reset.sh\n> index 03d2c3b..e95c252 100755\n> --- a/git-reset.sh\n> +++ b/git-reset.sh\n> @@ -1,35 +1,59 @@\n>  #!/bin/sh\n> -\n> -USAGE='[--mixed | --soft | --hard]  [<commit-ish>]'\n> +#\n> +# Copyright (c) 2005, 2006 Linus Torvalds and Junio C Hamano\n> +#\n> +USAGE='[--mixed | --soft | --hard]  [<commit-ish>] [ [--] <paths>...]'\n>  SUBDIRECTORY_OK=Yes\n>  . git-sh-setup\n>  \n> +update= rev= reset_type=--mixed\n> +\n> +while case $# in 0) break ;; esac\n> +do\n> +\tcase \"$1\" in\n> +\t--mixed | --soft | --hard)\n> +\t\treset_type=\"$1\"\n> +\t\t;;\n> +\t--)\n> +\t\tbreak\n> +\t\t;;\n> +\t-*)\n> +\t\tusage\n> +\t\t;;\n> +\t*)\n> +\t\trev=$(git-rev-parse --verify \"$1\") || exit\n> +\t\tshift\n> +\t\tbreak\n> +\t\t;;\n> +\tesac\n> +\tshift\n> +done\n> +\n> +: ${rev=HEAD}\n> +rev=$(git-rev-parse --verify $rev^0) || exit\n> +\n> +# Skip -- in \"git reset HEAD -- foo\" and \"git reset -- foo\".\n> +case \"$1\" in --) shift ;; esac\n> +\n> +# git reset --mixed tree [--] paths... can be used to\n> +# load chosen paths from the tree into the index without\n> +# affecting the working tree nor HEAD.\n> +if test $# != 0\n> +then\n> +\ttest \"$reset_type\" == \"--mixed\" ||\n> +\t\tdie \"Cannot do partial $reset_type reset.\"\n> +\tgit ls-tree -r --full-name $rev -- \"$@\" |\n> +\tgit update-index --add --index-info || exit\n> +\tgit update-index --refresh\n> +\texit\n> +fi\n> +\n\nWhy not make\n\n\tgit-reset --hard <treeish> -- file\n\naquivalent to\n\n\tgit-checkout <treeish> -- file\n\n-Peter\n\nPS:\tYour patch didn't apply cleanly. And I couldn't find the blobs\n\t03d2c3b..e95c252 even after pulling (pu, next, master) in my\n\tgit repository\n"},{"id":"297820","messageId":"7v3b7i2osc.fsf@assigned-by-dhcp.cox.net","threadId":"43586","inReplyTo":"slrneo2atm.nqa.Peter.B.Baumann@xp.machine.xx","subject":"Re: [PATCH] git-reset [--mixed] <tree> [--] <paths>...","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-12-14T20:41:39Z","receivedAt":"2006-12-14T20:41:39Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Peter Baumann <Peter.B.Baumann@stud.informatik.uni-erlangen.de>\nwrites:\n\n> Why not make\n>\n> \tgit-reset --hard <treeish> -- file\n>\n> aquivalent to\n>\n> \tgit-checkout <treeish> -- file\n\nTheoretically we could, but I'd rather keep \"reset --hard\"\nsomething that people would think a bit about before actually\nrunning (I am not enthused about giving \"reset --mixed\" this\nfeature for the same reason, but I think it is safe enough).\n\nI'd want to avoid overloading different meanings to the --hard\nform.  Mis-typing checkout (say, accidentally having <RETURN>\nbefore \"-- file\" part while cut & paste) would not be so\ndangeous; mis-typing \"reset --hard\" the same way could be\ndisastrous.\n\n> PS:\tYour patch didn't apply cleanly.\n\nAs I said there is one bug I've fixed in my tree but the\nbranches were not pushed out yet.\n"}]}