Tools for working in the OpenStack Oslo community.
Go to file
Scott Little 6b06d7d7e1 filter_git_history.sh passes broken parent-filter to git filter-branch
Problem:
    filter_git_history.sh, when passed a list if directories to filter,
 sometimes passes a bad arguement to git filter-branch.

e.g.

filter_git_history.sh <dir1> <dir2> <dir3>

results in ...

git filter-branch ... --parent-filter '<bad arg>' ...

resulting in logs ....

Rewrite 1a32385367efab7a2bccf63981993b322e0d4b4c (1/866)/usr/lib/git-core/git-filter-branch: line 340: [: missing `]'
/usr/lib/git-core/git-filter-branch: line 341: -o: command not found
Rewrite 3cd12006bb6e7c9157f6b0f82a10d0c8cd63e334 (2/866)/usr/lib/git-core/git-filter-branch: line 340: [: missing `]'
/usr/lib/git-core/git-filter-branch: line 341: -o: command not found

The issue appears to be carriage returns in variable 'set_roots'.
Specifically the expresion within the '[' ']' pair seems to be incompatible with
carriage returns.

If I run with bash debugging turned on, I see the for loop at
line 45 iterated twice, producing the following output.

+ set_roots='
if [ 1 -eq 0  -o "$GIT_COMMIT" = '\''1232ac58be82479ddf1af7f7eb335103cb883356'\''
 -o "$GIT_COMMIT" = '\''ffe029ef99c501a0076ad6106a364bbb9c0d80ea'\''  ]; then
    echo '\'''\'';
else
    cat;
fi'

Note that there is a carriage return prior to the second -o clause.
My theory is that within git-filter-branch, bash is being invoked twice.

First call:
    if [ 1 -eq 0  -o "$GIT_COMMIT" = '\''1232ac58be82479ddf1af7f7eb335103cb883356'\''

resulting in:
    git-filter-branch: line 340: [: missing `]'

Second call:
     -o "$GIT_COMMIT" = '\''ffe029ef99c501a0076ad6106a364bbb9c0d80ea'\''  ]; then
        echo '\'''\'';
    else
        cat;
    fi

resulting in:
   git-filter-branch: line 341: -o: command not found

Other details:
   bash 4.3-7ubuntu1.7
   git  1:1.9.1-1ubuntu0.10

Solution
   Use 'echo -n' rather than 'echo' when constructing 'set_roots'.

Which results in ...

+ set_roots='
if [ 1 -eq 0  -o "$GIT_COMMIT" = '\''1232ac58be82479ddf1af7f7eb335103cb883356'\'' -o "$GIT_COMMIT" = '\''ffe029ef99c501a0076ad6106a364bbb9c0d80ea'\''  ]; then
    echo '\'''\'';
else
    cat;
fi'

The entire '[' ']' expression is on the same line, and the git-filter-branch go away.

Change-Id: I3a21fd0841f093495cf4727a9f5633a6f80c1690
Signed-off-by: Scott Little <scott.little@windriver.com>
2019-07-12 10:50:11 -04:00
oslobot Trivial: Update pypi url to new url 2018-04-21 13:27:41 +08:00
.gitreview OpenDev Migration Patch 2019-04-19 19:29:42 +00:00
README.rst Update links in README 2018-02-28 01:18:29 +08:00
filter_git_history.sh filter_git_history.sh passes broken parent-filter to git filter-branch 2019-07-12 10:50:11 -04:00
list_latest_releases.sh Remove obsolete comments from tool scripts 2015-02-17 18:19:27 -05:00
list_oslo_projects.py Replaces yaml.load() with yaml.safe_load() 2018-02-13 09:29:48 +00:00
oslo_tool_config.py Switch from oslo.config to oslo_config 2015-02-13 14:27:57 -05:00
requirements.txt Switch to stestr 2018-07-03 13:39:32 +07:00

README.rst

Team and repository tags

image

Oslo tools

Tools for working in the openstack oslo community.