{"thread":{"id":"3290","subject":"[PATCH 1/3] Call extended-semantics commands through variables.","startedAt":"2006-02-10T23:35:06Z","lastAt":"2006-02-14T06:13:05Z","messageCount":7,"participants":["Jason Riedy","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"15880","messageId":"1091.1139614506@lotus.CS.Berkeley.EDU","threadId":"3290","inReplyTo":null,"subject":"[PATCH 1/3] Call extended-semantics commands through variables.","fromName":"Jason Riedy","fromEmail":"ejr@eecs.berkeley.edu","sentAt":"2006-02-10T23:35:06Z","receivedAt":"2006-02-10T23:35:06Z","isPatch":true,"sender":{"key":"ejr@eecs.berkeley.edu","avatar":"https://gravatar.com/avatar/547fa56f887cab01599edab4e9f813c949c1269e02714f20e0496c56185d9837?d=mp&s=160"},"body":"In some places, git shell scripts rely on semantics for\nxargs, find, and cpio that do not exist in all versions\nof those commands.  Both xargs and find rely on -0 for\nhandling multi-word names, and for some reason the cpio\ncalls do not work with pkgsrc's default cpio.\n\nReplacing all such calls with calls through variables\nallows more portability.  Also, the variables can point\nto debugging scripts that log arguments, outputs, etc.\n\nThe variables are just XARGS, FIND, and CPIO.  No GIT_\nwas appended so a user can set those once for all scripts\nthat may use them (e.g. configure).  A follow-on patch\nwill modify the Makefile to allow installation-specific\ndefaults.\n\nTested on Solaris 8 with those arguments pointing at\nGNU tools as well as some Linux versions.  (The AIX\nmachine I use is down for maintenance right now.)\n\nSigned-off-by: Jason Riedy <ejr@cs.berkeley.edu>\n\n---\n\n git-add.sh           |    3 ++-\n git-clone.sh         |   10 ++++++----\n git-count-objects.sh |    8 +++++---\n git-grep.sh          |    3 ++-\n git-ls-remote.sh     |    4 +++-\n git-merge.sh         |    5 +++--\n git-prune.sh         |    5 +++--\n git-push.sh          |    5 +++--\n git-repack.sh        |    3 ++-\n 9 files changed, 29 insertions(+), 17 deletions(-)\n\n846024657d04675a762fd9edaba3c0612f616a41\ndiff --git a/git-add.sh b/git-add.sh\nindex f719b4b..bd79b4f 100755\n--- a/git-add.sh\n+++ b/git-add.sh\n@@ -3,6 +3,7 @@\n USAGE='[-n] [-v] <file>...'\n SUBDIRECTORY_OK='Yes'\n . git-sh-setup\n+: ${XARGS:=xargs}\n \n show_only=\n verbose=\n@@ -35,7 +36,7 @@ else\n fi |\n case \"$show_only\" in\n true)\n-\txargs -0 echo ;;\n+\t${XARGS} -0 echo ;;\n *)\n \tgit-update-index --add $verbose -z --stdin ;;\n esac\ndiff --git a/git-clone.sh b/git-clone.sh\nindex 47f3ec9..2c9b45e 100755\n--- a/git-clone.sh\n+++ b/git-clone.sh\n@@ -7,6 +7,8 @@\n \n # See git-sh-setup why.\n unset CDPATH\n+: ${FIND:=find}\n+: ${CPIO:=cpio}\n \n usage() {\n \techo >&2 \"Usage: $0 [--bare] [-l [-s]] [-q] [-u <upload-pack>] [-o <name>] [-n] <repo> [<dir>]\"\n@@ -141,19 +143,19 @@ yes,yes)\n \tno)\n \t    # See if we can hardlink and drop \"l\" if not.\n \t    sample_file=$(cd \"$repo\" && \\\n-\t\t\t  find objects -type f -print | sed -e 1q)\n+\t\t\t  ${FIND} objects -type f -print | sed -e 1q)\n \n \t    # objects directory should not be empty since we are cloning!\n \t    test -f \"$repo/$sample_file\" || exit\n \n \t    l=\n-\t    if ln \"$repo/$sample_file\" \"$GIT_DIR/objects/sample\" 2>/dev/null\n+\t    if ln \"$repo/$sample_file\" \"$DIR/objects/sample\" 2>/dev/null\n \t    then\n \t\t    l=l\n \t    fi &&\n \t    rm -f \"$GIT_DIR/objects/sample\" &&\n \t    cd \"$repo\" &&\n-\t    find objects -depth -print | cpio -puamd$l \"$GIT_DIR/\" || exit 1\n+\t    ${FIND} objects -depth -print | ${CPIO} -puamd$l \"$GIT_DIR/\" || exit 1\n \t    ;;\n \tyes)\n \t    mkdir -p \"$GIT_DIR/objects/info\"\n@@ -234,7 +236,7 @@ then\n \t\t\"URL: $repo\n Pull: $head_points_at:$origin\" &&\n \t\tgit-update-ref \"refs/heads/$origin\" $(git-rev-parse HEAD) &&\n-\t\t(cd \"$GIT_DIR\" && find \"refs/heads\" -type f -print) |\n+\t\t(cd \"$GIT_DIR\" && ${FIND} \"refs/heads\" -type f -print) |\n \t\twhile read ref\n \t\tdo\n \t\t\thead=`expr \"$ref\" : 'refs/heads/\\(.*\\)'` &&\ndiff --git a/git-count-objects.sh b/git-count-objects.sh\nindex 40c58ef..5a4550c 100755\n--- a/git-count-objects.sh\n+++ b/git-count-objects.sh\n@@ -4,6 +4,8 @@\n #\n \n GIT_DIR=`git-rev-parse --git-dir` || exit $?\n+: ${FIND:=find}\n+: ${XARGS:=xargs}\n \n dc </dev/null 2>/dev/null || {\n \t# This is not a real DC at all -- it just knows how\n@@ -20,12 +22,12 @@ dc </dev/null 2>/dev/null || {\n \t}\n }\n \n-echo $(find \"$GIT_DIR/objects\"/?? -type f -print 2>/dev/null | wc -l) objects, \\\n+echo $(${GIT_FIND} \"$GIT_DIR/objects\"/?? -type f -print 2>/dev/null | wc -l) objects, \\\n $({\n     echo 0\n     # \"no-such\" is to help Darwin folks by not using xargs -r.\n-    find \"$GIT_DIR/objects\"/?? -type f -print 2>/dev/null |\n-    xargs du -k \"$GIT_DIR/objects/no-such\" 2>/dev/null |\n+    ${FIND} \"$GIT_DIR/objects\"/?? -type f -print 2>/dev/null |\n+    ${XARGS} du -k \"$GIT_DIR/objects/no-such\" 2>/dev/null |\n     sed -e 's/[ \t].*/ +/'\n     echo p\n } | dc) kilobytes\ndiff --git a/git-grep.sh b/git-grep.sh\nindex ad4f2fe..a58ab37 100755\n--- a/git-grep.sh\n+++ b/git-grep.sh\n@@ -6,6 +6,7 @@\n USAGE='[<option>...] [-e] <pattern> [<path>...]'\n SUBDIRECTORY_OK='Yes'\n . git-sh-setup\n+: ${XARGS:=xargs}\n \n got_pattern () {\n \tif [ -z \"$no_more_patterns\" ]\n@@ -59,4 +60,4 @@ done\n \tusage\n }\n git-ls-files -z \"${git_flags[@]}\" -- \"$@\" |\n-\txargs -0 grep \"${flags[@]}\" -e \"$pattern\" --\n+\t${XARGS} -0 grep \"${flags[@]}\" -e \"$pattern\" --\ndiff --git a/git-ls-remote.sh b/git-ls-remote.sh\nindex 2c9a588..340bde0 100755\n--- a/git-ls-remote.sh\n+++ b/git-ls-remote.sh\n@@ -1,6 +1,8 @@\n #!/bin/sh\n #\n \n+: ${FIND:=find}\n+\n usage () {\n     echo >&2 \"usage: $0 [--heads] [--tags] [-u|--upload-pack <upload-pack>]\"\n     echo >&2 \"          <repository> <refs>...\"\n@@ -63,7 +65,7 @@ rsync://* )\n \t\techo \"failed\tslurping\"\n \t\texit\n \t}\n-\t(cd $tmpdir && find refs -type f) |\n+\t(cd $tmpdir && ${FIND} refs -type f) |\n \twhile read path\n \tdo\n \t\tcat \"$tmpdir/$path\" | tr -d '\\012'\ndiff --git a/git-merge.sh b/git-merge.sh\nindex dc17baf..c9b03c8 100755\n--- a/git-merge.sh\n+++ b/git-merge.sh\n@@ -6,6 +6,7 @@\n \n USAGE='[-n] [--no-commit] [-s <strategy>]... <merge-message> <head> <remote>+'\n . git-sh-setup\n+: ${CPIO:=cpio}\n \n LF='\n '\n@@ -22,14 +23,14 @@ dropsave() {\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+\t${CPIO} -0 -o >\"$GIT_DIR/MERGE_SAVE\"\n }\n \n restorestate() {\n         if test -f \"$GIT_DIR/MERGE_SAVE\"\n \tthen\n \t\tgit reset --hard $head\n-\t\tcpio -iuv <\"$GIT_DIR/MERGE_SAVE\"\n+\t\t${CPIO} -iuv <\"$GIT_DIR/MERGE_SAVE\"\n \t\tgit-update-index --refresh >/dev/null\n \tfi\n }\ndiff --git a/git-prune.sh b/git-prune.sh\nindex c5a5d29..781393f 100755\n--- a/git-prune.sh\n+++ b/git-prune.sh\n@@ -2,6 +2,7 @@\n \n USAGE='[-n] [--] [<head>...]'\n . git-sh-setup\n+: ${XARGS:=xargs}\n \n dryrun=\n echo=\n@@ -27,7 +28,7 @@ sed -ne '/unreachable /{\n     s|\\(..\\)|\\1/|p\n }' | {\n \tcd \"$GIT_OBJECT_DIRECTORY\" || exit\n-\txargs $echo rm -f\n+\t${XARGS} $echo rm -f\n \trmdir 2>/dev/null [0-9a-f][0-9a-f]\n }\n \n@@ -37,7 +38,7 @@ if redundant=$(git-pack-redundant --all \n then\n \tif test \"\" = \"$dryrun\"\n \tthen\n-\t\techo \"$redundant\" | xargs rm -f\n+\t\techo \"$redundant\" | ${XARGS} rm -f\n \telse\n \t\techo rm -f \"$redundant\"\n \tfi\ndiff --git a/git-push.sh b/git-push.sh\nindex 706db99..1a6c96d 100755\n--- a/git-push.sh\n+++ b/git-push.sh\n@@ -2,6 +2,7 @@\n \n USAGE='[--all] [--tags] [--force] <repository> [<refspec>...]'\n . git-sh-setup\n+: ${FIND:=find}\n \n # Parse out parameters and then stop at remote, so that we can\n # translate it using .git/branches information\n@@ -46,9 +47,9 @@ case \"$has_all\" in\n '')\n \tcase \"$do_tags,$#\" in\n \tyes,1)\n-\t\tset x $(cd \"$GIT_DIR/refs\" && find tags -type f -print) ;;\n+\t\tset x $(cd \"$GIT_DIR/refs\" && ${FIND} tags -type f -print) ;;\n \tyes,*)\n-\t\tset x $(cd \"$GIT_DIR/refs\" && find tags -type f -print) \\\n+\t\tset x $(cd \"$GIT_DIR/refs\" && ${FIND} tags -type f -print) \\\n \t\t    $(get_remote_refs_for_push \"$@\") ;;\n \t,*)\n \t\tset x $(get_remote_refs_for_push \"$@\") ;;\ndiff --git a/git-repack.sh b/git-repack.sh\nindex 1fafb6e..56a33a7 100755\n--- a/git-repack.sh\n+++ b/git-repack.sh\n@@ -5,6 +5,7 @@\n \n USAGE='[-a] [-d] [-l] [-n]'\n . git-sh-setup\n+: ${FIND:=find}\n \t\n no_update_info= all_into_one= remove_redundant= local=\n while case \"$#\" in 0) break ;; esac\n@@ -36,7 +37,7 @@ case \",$all_into_one,\" in\n \n \t# Redundancy check in all-into-one case is trivial.\n \texisting=`cd \"$PACKDIR\" && \\\n-\t    find . -type f \\( -name '*.pack' -o -name '*.idx' \\) -print`\n+\t    ${FIND} . -type f \\( -name '*.pack' -o -name '*.idx' \\) -print`\n \t;;\n esac\n if [ \"$local\" ]; then\n-- \n1.1.6.g0d39d\n"},{"id":"15908","messageId":"7vwtg2mmx5.fsf@assigned-by-dhcp.cox.net","threadId":"3290","inReplyTo":"1091.1139614506@lotus.CS.Berkeley.EDU","subject":"Re: [PATCH 1/3] Call extended-semantics commands through variables.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-02-11T06:25:58Z","receivedAt":"2006-02-11T06:25:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jason Riedy <ejr@EECS.Berkeley.EDU> writes:\n\n> The variables are just XARGS, FIND, and CPIO.  No GIT_\n> was appended so a user can set those once for all scripts\n> that may use them (e.g. configure).  A follow-on patch\n> will modify the Makefile to allow installation-specific\n> defaults.\n\nThe use of FIND or CPIO in git clone does not need -0 (and the\ncode does not use -0, nor your patch adds -0), so you should not\nhave to override them this way.  Except refnames, the file names\nare not something under arbitrary user control and usual LF\ntermination would work fine.  Even refnames cannot contain LF in\nthem.  Same thing for FIND in ls-remote and git-push.\n\nFIND in count-objects only lists .git/objects/?? so filenames\nthere are already well-behaved and you do not need -0 there for\nFIND nor XARGS.  Same thing for XARGS in git-prune.sh and FIND\nin repack (BTW, you got count-objects one wrong; there is a\nleftover GIT_FIND there).\n\nAlthough most of what your patch does seems to be unnecessary,\nreviewing this patch gave me an opportunity to see if we fail to\nuse -0 where we should, and I am grateful for it.\n\nI did not see any place we did not use -0 when we should, except\none.  The places we _do_ use -0 currently should be converted\nwith something like your patch to use -0 capable version of the\ntool.\n\nThe exception is where finding refnames from rsync'ed copy of a\nremote (the remote may have screwed-up refnames just to be\nhostile), but nobody should be using rsync transfer anyway,\nso...\n"},{"id":"15942","messageId":"4230.1139699411@lotus.CS.Berkeley.EDU","threadId":"3290","inReplyTo":"7vwtg2mmx5.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH 1/3] Call extended-semantics commands through variables.","fromName":"Jason Riedy","fromEmail":"ejr@eecs.berkeley.edu","sentAt":"2006-02-11T23:10:11Z","receivedAt":"2006-02-11T23:10:11Z","isPatch":true,"sender":{"key":"ejr@eecs.berkeley.edu","avatar":"https://gravatar.com/avatar/547fa56f887cab01599edab4e9f813c949c1269e02714f20e0496c56185d9837?d=mp&s=160"},"body":"And Junio C Hamano writes:\n - The use of FIND or CPIO in git clone does not need -0 (and the\n - code does not use -0, nor your patch adds -0), so you should not\n - have to override them this way.\n\nI'm not sure what's up with cpio, but git causes pkgsrc's \ndefault cpio to segfault on my Solaris machines.  It's \neasier to point CPIO at a different cpio than debug a \nutility I've never really used.  ;)  I thought it was\ngit-clone breaking in the tests, but it could have been\ngit-merge.  I'll check again when I get a chance.\n\nAnd I worry about using different programs in different \nscripts, so I just changed all of them.\n\n - (BTW, you got count-objects one wrong; there is a leftover \n - GIT_FIND there).\n\nFriday afternoon patching, sorry.  That also means either \nthat count-objects has no test cases or that branch of it \nis not exercised by tests.\n\n - The places we _do_ use -0 currently should be converted\n - with something like your patch to use -0 capable version of the\n - tool.\n\nAgain, I'm not very comfortable using different finds or \nxargs in different places.  But if you want, I'll re-do the\npatch with just those locations changed, and I'll double-\ncheck which cpio invocation is breaking.\n\n - [...] but nobody should be using rsync transfer anyway,\n - so...\n\nIs there a better way of grabbing all the tags now?  I haven't\nkept track, as I haven't had to do that in a while.\n\nJason\n"},{"id":"15943","messageId":"7v64nllbdj.fsf@assigned-by-dhcp.cox.net","threadId":"3290","inReplyTo":"4230.1139699411@lotus.CS.Berkeley.EDU","subject":"Re: [PATCH 1/3] Call extended-semantics commands through variables.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-02-11T23:32:56Z","receivedAt":"2006-02-11T23:32:56Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jason Riedy <ejr@EECS.Berkeley.EDU> writes:\n\n> And I worry about using different programs in different \n> scripts, so I just changed all of them.\n\nThat's a good point.  I stand corrected.\n"},{"id":"15944","messageId":"7vzmkxjtvd.fsf@assigned-by-dhcp.cox.net","threadId":"3290","inReplyTo":"4230.1139699411@lotus.CS.Berkeley.EDU","subject":"Re: [PATCH 1/3] Call extended-semantics commands through variables.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-02-12T00:36:22Z","receivedAt":"2006-02-12T00:36:22Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jason Riedy <ejr@EECS.Berkeley.EDU> writes:\n\n> Is there a better way of grabbing all the tags now?  I haven't\n> kept track, as I haven't had to do that in a while.\n\nRecent 'git-fetch' automatically follows tags that are attached\nto commits you slurp (following example set by Cogito), to\nreduce the need to grab all tags to begin with.  That would not\nhelp tags that are attached to objects that are not part of\nbranches you are tracking; you can use 'git-fetch --tags' for\nthem.\n"},{"id":"16087","messageId":"12579.1139893961@lotus.CS.Berkeley.EDU","threadId":"3290","inReplyTo":"7v64nllbdj.fsf@assigned-by-dhcp.cox.net","subject":"git 1.2 works on Solaris, AIX [was Re: [PATCH 1/3] Call extended-semantics commands through variables.]","fromName":"Jason Riedy","fromEmail":"ejr@eecs.berkeley.edu","sentAt":"2006-02-14T05:12:41Z","receivedAt":"2006-02-14T05:12:41Z","isPatch":true,"sender":{"key":"ejr@eecs.berkeley.edu","avatar":"https://gravatar.com/avatar/547fa56f887cab01599edab4e9f813c949c1269e02714f20e0496c56185d9837?d=mp&s=160"},"body":"The AIX machines I work on are back, and it looks like my \npatches are unnecessary, at least for my use.  It'd be cute \nto allow builders to point at GNU tools, but not terribly \nuseful.  The File::Find patch to git-archimport.perl might \nbe nice, but it functions as-is.\n\nTo have diff and merge on my path with this AIX platform, I have \nto pull *all* the GNU tools into my path.  (NERSC uses modules.)  \nI suspect that is a rather common setup, so it's not worth the \nserious surgery to redirect diff and merge.  diff is used in C \nand shell, and merge is in shell, Perl, and Python sources.\n\nAnd pkgsrc on Solaris appears happy using GNU's cpio (under\narchivers/gcpio) rather than its default, plain one.  I hadn't \nrealized I could replace it easily.\n\nSo with the GNU tools in the path and a properly built Python, \nthe mainline code works on Solaris 8 and AIX.\n\nFor posterity: Any problems with git-merge-recursive.py on AIX\nlikely are a yucky Python/AIX problem.  The sha has 'sem_trywait: \nPermission denied\\n' prepended to it a few times.  You need to \nrebuild Python with HAVE_BROKEN_POSIX_SEMAPHORES:\n  https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1106262&group_id=5470\n\nIf anyone really wants to point at particular tools but not \nrequire them in the user's path, the simplest way would be to \nlink the correct tools (or wrappers) into the GIT_EXEC_PATH \nand prepend that to the PATH *everywhere*.  But it's not worth \nthe effort until someone really needs it.\n\nJason\n"},{"id":"16092","messageId":"7vr766v572.fsf@assigned-by-dhcp.cox.net","threadId":"3290","inReplyTo":"12579.1139893961@lotus.CS.Berkeley.EDU","subject":"Re: git 1.2 works on Solaris, AIX","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-02-14T06:13:05Z","receivedAt":"2006-02-14T06:13:05Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks.  So let's leave the 1.2.X maintenance series as is at\nleast for now.\n"}]}