{"thread":{"id":"8970","subject":"git-filter-branch exits early","startedAt":"2007-07-10T20:52:02Z","lastAt":"2007-07-18T14:05:14Z","messageCount":7,"participants":["Alex Riesen","Johannes Schindelin","Sven Verdoolaege","David Kastrup"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"46983","messageId":"20070710205202.GA3212@steel.home","threadId":"8970","inReplyTo":null,"subject":"git-filter-branch exits early","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-07-10T20:52:02Z","receivedAt":"2007-07-10T20:52:02Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"I have a Debian system where git-filter-branch exits immediately after\n\"unset CDPATH\" in git-sh-setup (the command exits with 1, as CDPATH is\nnot defined). The system still has bash-2.05a.\n\ngit-filter-branch has \"set -e\", which is why the script finishes\nprematurely. If this is not really needed, maybe it can be removed?\n\nI'll see if the system can be upgraded, but I suspect someone can get\na similar problem.\n"},{"id":"46987","messageId":"Pine.LNX.4.64.0707102222430.4047@racer.site","threadId":"8970","inReplyTo":"20070710205202.GA3212@steel.home","subject":"Re: git-filter-branch exits early","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-07-10T21:57:44Z","receivedAt":"2007-07-10T21:57:44Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 10 Jul 2007, Alex Riesen wrote:\n\n> I have a Debian system where git-filter-branch exits immediately after\n> \"unset CDPATH\" in git-sh-setup (the command exits with 1, as CDPATH is\n> not defined). The system still has bash-2.05a.\n> \n> git-filter-branch has \"set -e\", which is why the script finishes\n> prematurely. If this is not really needed, maybe it can be removed?\n> \n> I'll see if the system can be upgraded, but I suspect someone can get\n> a similar problem.\n\nI do not really understand why \"unset CDPATH\" should trigger an error.  I \nguess that this is one of the nice braindamages in dash, right?\n\nAnyway, \"set -e\" was one thing I wanted to fix.  But I'm not sure I want \nto work on filter-branch now, what with skimo (possibly? hopefully?) \nworking on my wishlist for rewrite-commits.  If rewrite-commits gets the \nfeatures I wished for, IMHO filter-branch is obsolete.\n\nUsing rewrite-commits would have a couple of advantages:\n\n- the name is much better,\n\n- since we have reflogs enabled by default now, there is really no good \n  reason why you should have to copy the rewritten branches back to their \n  original name (we would need a way to redirect that, though, for \n  example for subdirectory filters),\n\n- it is faster,\n\n- since it is a C program, it should be more stable, eventually, than a \n  shell script, where you have to work around limitations all the time,\n\n- with the trick I described in the mail to skimo, you can have \n  convenience functions (think \"map\") in the commit filter, too,\n\n- and it would be less work for me.\n\nYour case is a really good illustration for why C is a better language \nthan shell in the long run.\n\nOh, BTW, if the index filter gets the current (original) commit SHA1 as an \nenvironment variable, like it does in filter-branch, it can act as a \nthe first half of a subdirectory filter:\n\n\t--index-filter \"git read-tree $COMMIT_SHA1:sub/directory/\"\n\nThe second half of it is to add \"-- sub/directory/\" to the command line.\n\nCiao,\nDscho\n"},{"id":"47006","messageId":"81b0412b0707102302i34a51baax464f8c7c69087b7d@mail.gmail.com","threadId":"8970","inReplyTo":"Pine.LNX.4.64.0707102222430.4047@racer.site","subject":"Re: git-filter-branch exits early","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-07-11T06:02:54Z","receivedAt":"2007-07-11T06:02:54Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On 7/10/07, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> On Tue, 10 Jul 2007, Alex Riesen wrote:\n>\n> > I have a Debian system where git-filter-branch exits immediately after\n> > \"unset CDPATH\" in git-sh-setup (the command exits with 1, as CDPATH is\n> > not defined). The system still has bash-2.05a.\n> >\n> > git-filter-branch has \"set -e\", which is why the script finishes\n> > prematurely. If this is not really needed, maybe it can be removed?\n> >\n> > I'll see if the system can be upgraded, but I suspect someone can get\n> > a similar problem.\n>\n> I do not really understand why \"unset CDPATH\" should trigger an error.  I\n> guess that this is one of the nice braindamages in dash, right?\n\nin bash. Bash-2.05.a\n\n> Anyway, \"set -e\" was one thing I wanted to fix. ...\n\nBTW, what can break if I just go on and remove it?\n\n> - since it is a C program, it should be more stable, eventually, than a\n>   shell script, where you have to work around limitations all the time,\n\nright :)\n"},{"id":"47011","messageId":"20070711075536.GB1528MdfPADPa@greensroom.kotnet.org","threadId":"8970","inReplyTo":"Pine.LNX.4.64.0707102222430.4047@racer.site","subject":"Re: git-filter-branch exits early","fromName":"Sven Verdoolaege","fromEmail":"skimo@kotnet.org","sentAt":"2007-07-11T07:55:36Z","receivedAt":"2007-07-11T07:55:36Z","isPatch":false,"sender":{"key":"skimo@kotnet.org","avatar":null},"body":"On Tue, Jul 10, 2007 at 10:57:44PM +0100, Johannes Schindelin wrote:\n> Anyway, \"set -e\" was one thing I wanted to fix.  But I'm not sure I want \n> to work on filter-branch now, what with skimo (possibly? hopefully?) \n> working on my wishlist for rewrite-commits.\n\nI'm working on it, but only evenings (and weekends).\n\nskimo\n"},{"id":"47733","messageId":"Pine.LNX.4.64.0707181416050.14781@racer.site","threadId":"8970","inReplyTo":"20070710205202.GA3212@steel.home","subject":"[PATCH] filter-branch: get rid of \"set -e\"","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-07-18T13:17:43Z","receivedAt":"2007-07-18T13:17:43Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nIt was reported by Alex Riesen that \"set -e\" can break something as \ntrivial as \"unset CDPATH\" in bash.\n\nSo get rid of \"set -e\".\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n\n\tOn Tue, 10 Jul 2007, Alex Riesen wrote:\n\n\t> I have a Debian system where git-filter-branch exits immediately \n\t> after \"unset CDPATH\" in git-sh-setup (the command exits with 1, \n\t> as CDPATH is not defined). The system still has bash-2.05a.\n\t> \n\t> git-filter-branch has \"set -e\", which is why the script finishes\n\t> prematurely. If this is not really needed, maybe it can be \n\t> removed?\n\n\tI hope I got all of the interesting places equipped by the \n\tappropriate conditional die() calls.\n\n git-filter-branch.sh |   31 +++++++++++++++++--------------\n 1 files changed, 17 insertions(+), 14 deletions(-)\n\ndiff --git a/git-filter-branch.sh b/git-filter-branch.sh\nindex 5401970..0d000ed 100755\n--- a/git-filter-branch.sh\n+++ b/git-filter-branch.sh\n@@ -8,8 +8,6 @@\n # a new branch. You can specify a number of filters to modify the commits,\n # files and trees.\n \n-set -e\n-\n USAGE=\"git-filter-branch [-d TEMPDIR] [FILTERS] DESTBRANCH [REV-RANGE]\"\n . git-sh-setup\n \n@@ -141,9 +139,10 @@ git show-ref \"refs/heads/$dstbranch\" 2> /dev/null &&\n \tdie \"branch $dstbranch already exists\"\n \n test ! -e \"$tempdir\" || die \"$tempdir already exists, please remove it\"\n-mkdir -p \"$tempdir/t\"\n-cd \"$tempdir/t\"\n-workdir=\"$(pwd)\"\n+mkdir -p \"$tempdir/t\" &&\n+cd \"$tempdir/t\" &&\n+workdir=\"$(pwd)\" ||\n+die \"\"\n \n case \"$GIT_DIR\" in\n /*)\n@@ -155,12 +154,12 @@ esac\n export GIT_DIR GIT_WORK_TREE=.\n \n export GIT_INDEX_FILE=\"$(pwd)/../index\"\n-git read-tree # seed the index file\n+git read-tree || die \"Could not seed the index\"\n \n ret=0\n \n-\n-mkdir ../map # map old->new commit ids for rewriting parents\n+# map old->new commit ids for rewriting parents\n+mkdir ../map || die \"Could not create map/ directory\"\n \n case \"$filter_subdir\" in\n \"\")\n@@ -170,7 +169,7 @@ case \"$filter_subdir\" in\n *)\n \tgit rev-list --reverse --topo-order --default HEAD \\\n \t\t--parents --full-history \"$@\" -- \"$filter_subdir\"\n-esac > ../revs\n+esac > ../revs || die \"Could not get the commits\"\n commits=$(wc -l <../revs | tr -d \" \")\n \n test $commits -eq 0 && die \"Found nothing to rewrite\"\n@@ -186,10 +185,11 @@ while read commit parents; do\n \t\t;;\n \t*)\n \t\tgit read-tree -i -m $commit:\"$filter_subdir\"\n-\tesac\n+\tesac || die \"Could not initialize the index\"\n \n \texport GIT_COMMIT=$commit\n-\tgit cat-file commit \"$commit\" >../commit\n+\tgit cat-file commit \"$commit\" >../commit ||\n+\t\tdie \"Cannot read commit $commit\"\n \n \teval \"$(set_ident AUTHOR <../commit)\" ||\n \t\tdie \"setting author failed for commit $commit\"\n@@ -199,7 +199,8 @@ while read commit parents; do\n \t\tdie \"env filter failed: $filter_env\"\n \n \tif [ \"$filter_tree\" ]; then\n-\t\tgit checkout-index -f -u -a\n+\t\tgit checkout-index -f -u -a ||\n+\t\t\tdie \"Could not checkout the index\"\n \t\t# files that $commit removed are now still in the working tree;\n \t\t# remove them, else they would be added again\n \t\tgit ls-files -z --others | xargs -0 rm -f\n@@ -240,7 +241,8 @@ case \"$target_head\" in\n \techo Nothing rewritten\n \t;;\n *)\n-\tgit update-ref refs/heads/\"$dstbranch\" $target_head\n+\tgit update-ref refs/heads/\"$dstbranch\" $target_head ||\n+\t\tdie \"Could not update $dstbranch with $target_head\"\n \tif [ $(wc -l <../map/$src_head) -gt 1 ]; then\n \t\techo \"WARNING: Your commit filter caused the head commit to expand to several rewritten commits. Only the first such commit was recorded as the current $dstbranch head but you will need to resolve the situation now (probably by manually merging the other commits). These are all the commits:\" >&2\n \t\tsed 's/^/\t/' ../map/$src_head >&2\n@@ -277,7 +279,8 @@ if [ \"$filter_tag_name\" ]; then\n \t\t\twarn \"unreferencing tag object $sha1t\"\n \t\tfi\n \n-\t\tgit update-ref \"refs/tags/$new_ref\" \"$new_sha1\"\n+\t\tgit update-ref \"refs/tags/$new_ref\" \"$new_sha1\" ||\n+\t\t\tdie \"Could not write tag $new_ref\"\n \tdone\n fi\n \n-- \n1.5.3.rc1.16.g9d6f-dirty\n"},{"id":"47734","messageId":"86vechj0zz.fsf@lola.quinscape.zz","threadId":"8970","inReplyTo":"Pine.LNX.4.64.0707181416050.14781@racer.site","subject":"Re: [PATCH] filter-branch: get rid of \"set -e\"","fromName":"David Kastrup","fromEmail":"dak@gnu.org","sentAt":"2007-07-18T13:27:12Z","receivedAt":"2007-07-18T13:27:12Z","isPatch":true,"sender":{"key":"dak@gnu.org","avatar":"https://avatars.githubusercontent.com/u/52141349?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> It was reported by Alex Riesen that \"set -e\" can break something as \n> trivial as \"unset CDPATH\" in bash.\n\nNot in bash.  Just tried it.  But there are Bourne shells that do get\nannoyed.\n\n> So get rid of \"set -e\".\n\nI'd rather write\n\n[ \"X$CDPATH\" = \"X\" ] || unset CDPATH\n\n\nWith regard to shells, there is an interesting document\n(info \"(autoconf) Portable Shell\")\nwhich is rather disillusioning.\n\nA real horror show is\n(info \"(autoconf) Limitations of Builtins\")\nwhere one learns that using if without else can lead to bad exit\nstatus, too.\n\n-- \nDavid Kastrup\n"},{"id":"47735","messageId":"Pine.LNX.4.64.0707181503500.14781@racer.site","threadId":"8970","inReplyTo":"86vechj0zz.fsf@lola.quinscape.zz","subject":"Re: [PATCH] filter-branch: get rid of \"set -e\"","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-07-18T14:05:14Z","receivedAt":"2007-07-18T14:05:14Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\n[please Cc me]\n\nOn Wed, 18 Jul 2007, David Kastrup wrote:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n> > It was reported by Alex Riesen that \"set -e\" can break something as \n> > trivial as \"unset CDPATH\" in bash.\n> \n> Not in bash.  Just tried it.  But there are Bourne shells that do get\n> annoyed.\n\nThe mail I was replying to _explicitely_ stated that it _was_ with bash.  \nNot your version of it, but some version.\n\n> > So get rid of \"set -e\".\n> \n> I'd rather write\n> \n> [ \"X$CDPATH\" = \"X\" ] || unset CDPATH\n\nWe would write that as \"test\", not \"[\".\n\nBut it is much cleaner to get rid of \"set -e\" anyway.\n\nCiao,\nDscho\n"}]}