{"thread":{"id":"10544","subject":"[PATCH] Don't use cpio in git-clone when not installed","startedAt":"2007-10-31T20:05:45Z","lastAt":"2007-11-01T21:06:36Z","messageCount":16,"participants":["Mike Hommey","Junio C Hamano","Johannes Schindelin","Linus Torvalds","Jakub Narebski","Nguyen Thai Ngoc Duy","Alexander Skwar"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"57723","messageId":"1193861145-20357-1-git-send-email-mh@glandium.org","threadId":"10544","inReplyTo":null,"subject":"[PATCH] Don't use cpio in git-clone when not installed","fromName":"Mike Hommey","fromEmail":"mh@glandium.org","sentAt":"2007-10-31T20:05:45Z","receivedAt":"2007-10-31T20:05:45Z","isPatch":true,"sender":{"key":"mh@glandium.org","avatar":"https://avatars.githubusercontent.com/u/1038527?v=4"},"body":"\nSigned-off-by: Mike Hommey <mh@glandium.org>\n---\n git-clone.sh |    4 +++-\n 1 files changed, 3 insertions(+), 1 deletions(-)\n\ndiff --git a/git-clone.sh b/git-clone.sh\nindex 0ea3c24..57e96ae 100755\n--- a/git-clone.sh\n+++ b/git-clone.sh\n@@ -191,7 +191,9 @@ fi\n # it is local\n if base=$(get_repo_base \"$repo\"); then\n \trepo=\"$base\"\n-\tlocal=yes\n+\tif type cpio > /dev/null 2>&1; then\n+\t\tlocal=yes\n+\tfi\n fi\n \n dir=\"$2\"\n-- \n1.5.3.4\n"},{"id":"57724","messageId":"20071031201031.GA20626@glandium.org","threadId":"10544","inReplyTo":"1193861145-20357-1-git-send-email-mh@glandium.org","subject":"Re: [PATCH] Don't use cpio in git-clone when not installed","fromName":"Mike Hommey","fromEmail":"mh@glandium.org","sentAt":"2007-10-31T20:10:31Z","receivedAt":"2007-10-31T20:10:31Z","isPatch":true,"sender":{"key":"mh@glandium.org","avatar":"https://avatars.githubusercontent.com/u/1038527?v=4"},"body":"Damn, and I forgot git-send-email doesn't add the <> to In-Reply-To.\n\nMike\n"},{"id":"57754","messageId":"7v4pg6hq8u.fsf@gitster.siamese.dyndns.org","threadId":"10544","inReplyTo":"1193861145-20357-1-git-send-email-mh@glandium.org","subject":"Re: [PATCH] Don't use cpio in git-clone when not installed","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-10-31T22:29:53Z","receivedAt":"2007-10-31T22:29:53Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"type\"?  That's probably better than using \"which\", but sounds\nquite wrong.  Why not add Makefile target that the shell scripts\ndepend on to see if necessary tools are available and let the\nbuilder know if they are not?\n"},{"id":"57761","messageId":"Pine.LNX.4.64.0710312354180.4362@racer.site","threadId":"10544","inReplyTo":"7v4pg6hq8u.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] Don't use cpio in git-clone when not installed","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-10-31T23:55:58Z","receivedAt":"2007-10-31T23:55:58Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 31 Oct 2007, Junio C Hamano wrote:\n\n> \"type\"?  That's probably better than using \"which\", but sounds quite \n> wrong.  Why not add Makefile target that the shell scripts depend on to \n> see if necessary tools are available and let the builder know if they \n> are not?\n\nI thought the accord was that \"cpio\" is a _runtime_ dependency.  But yes, \nI agree \"type\" is not necessarily the best choice.  Maybe testing the exit \ncode for 127 (not found) is the better choice?\n\nCiao,\nDscho\n"},{"id":"57764","messageId":"alpine.LFD.0.999.0710311742170.3342@woody.linux-foundation.org","threadId":"10544","inReplyTo":"1193861145-20357-1-git-send-email-mh@glandium.org","subject":"Re: [PATCH] Don't use cpio in git-clone when not installed","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2007-11-01T00:46:40Z","receivedAt":"2007-11-01T00:46:40Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Wed, 31 Oct 2007, Mike Hommey wrote:\n> +\tif type cpio > /dev/null 2>&1; then\n> +\t\tlocal=yes\n> +\tfi\n\nIsn't \"type\" a bashism?\n\nMaybe just do\n\n\tif echo . | cpio -o > /dev/null 2>&1; then\n\ninstead? Maybe even doing this at install time to avoid the overhead of \nexecuting another process..\n\n\t\tLinus\n"},{"id":"57765","messageId":"fgb8b6$hqo$1@ger.gmane.org","threadId":"10544","inReplyTo":"alpine.LFD.0.999.0710311742170.3342@woody.linux-foundation.org","subject":"Re: [PATCH] Don't use cpio in git-clone when not installed","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2007-11-01T01:00:48Z","receivedAt":"2007-11-01T01:00:48Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Linus Torvalds wrote:\n\n> \n> \n> On Wed, 31 Oct 2007, Mike Hommey wrote:\n>> +    if type cpio > /dev/null 2>&1; then\n>> +            local=yes\n>> +    fi\n> \n> Isn't \"type\" a bashism?\n> \n> Maybe just do\n> \n>       if echo . | cpio -o > /dev/null 2>&1; then\n> \n> instead? Maybe even doing this at install time to avoid the overhead of \n> executing another process..\n\nOr perhaps trap / check actual execution of cpio in git-clone, and\nfallback to ln -s / link if it fails...\n\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"57766","messageId":"fcaeb9bf0710311805t2083bc75mcb6ed47ee1144ac0@mail.gmail.com","threadId":"10544","inReplyTo":"alpine.LFD.0.999.0710311742170.3342@woody.linux-foundation.org","subject":"Re: [PATCH] Don't use cpio in git-clone when not installed","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2007-11-01T01:05:44Z","receivedAt":"2007-11-01T01:05:44Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On 11/1/07, Linus Torvalds <torvalds@linux-foundation.org> wrote:\n>\n>\n> On Wed, 31 Oct 2007, Mike Hommey wrote:\n> > +     if type cpio > /dev/null 2>&1; then\n> > +             local=yes\n> > +     fi\n>\n> Isn't \"type\" a bashism?\n\nbusybox ash has \"type\". I'm happy.\n\n-- \nDuy\n"},{"id":"57767","messageId":"fcaeb9bf0710311809o41703bc5hda36a9d44a538eeb@mail.gmail.com","threadId":"10544","inReplyTo":"1193861145-20357-1-git-send-email-mh@glandium.org","subject":"Re: [PATCH] Don't use cpio in git-clone when not installed","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2007-11-01T01:09:20Z","receivedAt":"2007-11-01T01:09:20Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"BTW, you have workaround for git-merge also? It uses cpio to save/restore state.\n\nOn 11/1/07, Mike Hommey <mh@glandium.org> wrote:\n>\n> Signed-off-by: Mike Hommey <mh@glandium.org>\n> ---\n>  git-clone.sh |    4 +++-\n>  1 files changed, 3 insertions(+), 1 deletions(-)\n>\n> diff --git a/git-clone.sh b/git-clone.sh\n> index 0ea3c24..57e96ae 100755\n> --- a/git-clone.sh\n> +++ b/git-clone.sh\n> @@ -191,7 +191,9 @@ fi\n>  # it is local\n>  if base=$(get_repo_base \"$repo\"); then\n>         repo=\"$base\"\n> -       local=yes\n> +       if type cpio > /dev/null 2>&1; then\n> +               local=yes\n> +       fi\n>  fi\n>\n>  dir=\"$2\"\n> --\n> 1.5.3.4\n>\n> -\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n>\n\n\n-- \nDuy\n"},{"id":"57768","messageId":"7vlk9ig45q.fsf@gitster.siamese.dyndns.org","threadId":"10544","inReplyTo":"alpine.LFD.0.999.0710311742170.3342@woody.linux-foundation.org","subject":"Re: [PATCH] Don't use cpio in git-clone when not installed","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-01T01:12:17Z","receivedAt":"2007-11-01T01:12:17Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Linus Torvalds <torvalds@linux-foundation.org> writes:\n\n> On Wed, 31 Oct 2007, Mike Hommey wrote:\n>> +\tif type cpio > /dev/null 2>&1; then\n>> +\t\tlocal=yes\n>> +\tfi\n>\n> Isn't \"type\" a bashism?\n\nI seem to recall that it is in POSIX.\n"},{"id":"57769","messageId":"7vejfag40g.fsf@gitster.siamese.dyndns.org","threadId":"10544","inReplyTo":"fcaeb9bf0710311809o41703bc5hda36a9d44a538eeb@mail.gmail.com","subject":"Re: [PATCH] Don't use cpio in git-clone when not installed","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-01T01:15:27Z","receivedAt":"2007-11-01T01:15:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Nguyen Thai Ngoc Duy\" <pclouds@gmail.com> writes:\n\n> BTW, you have workaround for git-merge also? It uses cpio to save/restore state.\n\nWhy do people want \"workaround\"?  Is installing cpio such a\nhassle?\n"},{"id":"57770","messageId":"fcaeb9bf0710311825k715900a0sa32a95b87cb146c7@mail.gmail.com","threadId":"10544","inReplyTo":"7vejfag40g.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] Don't use cpio in git-clone when not installed","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2007-11-01T01:25:25Z","receivedAt":"2007-11-01T01:25:25Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On 11/1/07, Junio C Hamano <gitster@pobox.com> wrote:\n> \"Nguyen Thai Ngoc Duy\" <pclouds@gmail.com> writes:\n>\n> > BTW, you have workaround for git-merge also? It uses cpio to save/restore state.\n>\n> Why do people want \"workaround\"?  Is installing cpio such a\n> hassle?\n\nIt is on Windows because busybox cpio is not really good and busybox\ntar is even worse (for cpio emulation). Maybe I should just improve\nbusybox cpio :-)\n-- \nDuy\n"},{"id":"57785","messageId":"20071101063131.GA22401@glandium.org","threadId":"10544","inReplyTo":"alpine.LFD.0.999.0710311742170.3342@woody.linux-foundation.org","subject":"Re: [PATCH] Don't use cpio in git-clone when not installed","fromName":"Mike Hommey","fromEmail":"mh@glandium.org","sentAt":"2007-11-01T06:31:31Z","receivedAt":"2007-11-01T06:31:31Z","isPatch":true,"sender":{"key":"mh@glandium.org","avatar":"https://avatars.githubusercontent.com/u/1038527?v=4"},"body":"On Wed, Oct 31, 2007 at 05:46:40PM -0700, Linus Torvalds wrote:\n> \n> \n> On Wed, 31 Oct 2007, Mike Hommey wrote:\n> > +\tif type cpio > /dev/null 2>&1; then\n> > +\t\tlocal=yes\n> > +\tfi\n> \n> Isn't \"type\" a bashism?\n\nI think it's POSIX, and since I found the same construct in\ngit-mergetool.sh, I thought it would be okay for git.\n\nMike\n"},{"id":"57787","messageId":"7vejfacvkz.fsf@gitster.siamese.dyndns.org","threadId":"10544","inReplyTo":"fcaeb9bf0710311825k715900a0sa32a95b87cb146c7@mail.gmail.com","subject":"Re: [PATCH] Don't use cpio in git-clone when not installed","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-01T06:45:48Z","receivedAt":"2007-11-01T06:45:48Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Nguyen Thai Ngoc Duy\" <pclouds@gmail.com> writes:\n\n> It is on Windows because busybox cpio is not really good and busybox\n> tar is even worse (for cpio emulation). Maybe I should just improve\n> busybox cpio :-)\n\nSounds sensible, as it (at least its -p mode of operation) is\none of the programs that is very useful yet not so well known to\npeople new to UNIX.\n"},{"id":"57798","messageId":"20071101105318.GA4744@glandium.org","threadId":"10544","inReplyTo":"7vejfag40g.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] Don't use cpio in git-clone when not installed","fromName":"Mike Hommey","fromEmail":"mh@glandium.org","sentAt":"2007-11-01T10:53:18Z","receivedAt":"2007-11-01T10:53:18Z","isPatch":true,"sender":{"key":"mh@glandium.org","avatar":"https://avatars.githubusercontent.com/u/1038527?v=4"},"body":"On Wed, Oct 31, 2007 at 06:15:27PM -0700, Junio C Hamano wrote:\n> \"Nguyen Thai Ngoc Duy\" <pclouds@gmail.com> writes:\n> \n> > BTW, you have workaround for git-merge also? It uses cpio to save/restore state.\n> \n> Why do people want \"workaround\"?  Is installing cpio such a\n> hassle?\n\nNote that to do what git-merge does with cpio, i wonder if it wouldn't\nbe sensible to use git stash, now.\n\nMike\n"},{"id":"57817","messageId":"loom.20071101T130539-416@post.gmane.org","threadId":"10544","inReplyTo":"alpine.LFD.0.999.0710311742170.3342@woody.linux-foundation.org","subject":"Re: [PATCH] Don't use cpio in git-clone when not installed","fromName":"Alexander Skwar","fromEmail":"listen@alexander.skwar.name","sentAt":"2007-11-01T13:06:54Z","receivedAt":"2007-11-01T13:06:54Z","isPatch":true,"sender":{"key":"listen@alexander.skwar.name","avatar":null},"body":"Linus Torvalds <torvalds <at> linux-foundation.org> writes:\n\n> \n> \n> On Wed, 31 Oct 2007, Mike Hommey wrote:\n> > +\tif type cpio > /dev/null 2>&1; then\n> > +\t\tlocal=yes\n> > +\tfi\n> \n> Isn't \"type\" a bashism?\n\nksh also has type. But SUS states, that \"command -v\" can be used.\n\n   Options\n\n[...]\n\n   -v\n       (On systems supporting the User Portability Utilities option.)\n       Write a string to standard output that indicates the pathname or\n       command that will be used by the shell, in the current shell\n       execution environment (see Shell Execution Environment ), to\n       invoke command_name, but do not invoke command_name.\n\n           * Utilities, regular built-in utilities, command_names\n             including a slash character, and any implementation-defined\n             functions that are found using the PATH variable (as\n             described in Command Search and Execution ), shall be\n             written as absolute pathnames.\n\n           * Shell functions, special built-in utilities, regular\n             built-in utilities not associated with a PATH search, and\n             shell reserved words shall be written as just their names.\n\n           * An alias shall be written as a command line that represents\n             its alias definition.\n\n           * Otherwise, no output shall be written and the exit status\n             shall reflect that the name was not found.\n\nRegards,\nAlexander\n"},{"id":"57866","messageId":"7vlk9had5v.fsf@gitster.siamese.dyndns.org","threadId":"10544","inReplyTo":"20071101105318.GA4744@glandium.org","subject":"Re: [PATCH] Don't use cpio in git-clone when not installed","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-01T21:06:36Z","receivedAt":"2007-11-01T21:06:36Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Mike Hommey <mh@glandium.org> writes:\n\n> On Wed, Oct 31, 2007 at 06:15:27PM -0700, Junio C Hamano wrote:\n>> \"Nguyen Thai Ngoc Duy\" <pclouds@gmail.com> writes:\n>> \n>> > BTW, you have workaround for git-merge also? It uses cpio to save/restore state.\n>> \n>> Why do people want \"workaround\"?  Is installing cpio such a\n>> hassle?\n>\n> Note that to do what git-merge does with cpio, i wonder if it wouldn't\n> be sensible to use git stash, now.\n\nLike this?  That's an excellent suggestion.\n\nThe patch uses the 'git stash create' which is in 'next'\n(jc/stash-create topic).\n\nHaving said that, the savestate()/restorestate() codepaths are\nonly relevant to the \"try multiple strategies and pick the best\none\" feature of git-merge, and that is where cpio is used (and\nthe patch rewrites it to use stash).  I am not sure if anybody\never used it in practice.  I admit I am guilty of inventing it,\nbut I certainly do not.\n\nIt might make sense to remove that try-multiple-strategies\nfeature from git-merge and be done with it.  It would certainly\nmake the eventual rewrite to C much easier.\n\n---\n git-merge.sh |   11 +++++------\n 1 files changed, 5 insertions(+), 6 deletions(-)\n\ndiff --git a/git-merge.sh b/git-merge.sh\nindex 3a01db0..e8916cc 100755\n--- a/git-merge.sh\n+++ b/git-merge.sh\n@@ -28,20 +28,19 @@ allow_trivial_merge=t\n \n dropsave() {\n \trm -f -- \"$GIT_DIR/MERGE_HEAD\" \"$GIT_DIR/MERGE_MSG\" \\\n-\t\t \"$GIT_DIR/MERGE_SAVE\" || exit 1\n+\t\t \"$GIT_DIR/MERGE_STASH\" || exit 1\n }\n \n savestate() {\n \t# Stash away any local modifications.\n-\tgit diff-index -z --name-only $head |\n-\tcpio -0 -o >\"$GIT_DIR/MERGE_SAVE\"\n+\tgit stash create >\"$GIT_DIR/MERGE_STASH\"\n }\n \n restorestate() {\n-        if test -f \"$GIT_DIR/MERGE_SAVE\"\n+        if test -f \"$GIT_DIR/MERGE_STASH\"\n \tthen\n \t\tgit reset --hard $head >/dev/null\n-\t\tcpio -iuv <\"$GIT_DIR/MERGE_SAVE\"\n+\t\tgit stash apply --index $(cat \"$GIT_DIR/MERGE_STASH\")\n \t\tgit update-index --refresh >/dev/null\n \tfi\n }\n@@ -386,7 +385,7 @@ case \"$use_strategies\" in\n     single_strategy=no\n     ;;\n *)\n-    rm -f \"$GIT_DIR/MERGE_SAVE\"\n+    rm -f \"$GIT_DIR/MERGE_STASH\"\n     single_strategy=yes\n     ;;\n esac\n"}]}