git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Bug in filter-branch example for moving into a subdirectory

From
JKJesse Keating <jkeating@redhat.com>
Date
Dec 10, 2011, 00:07 UTC
Message-ID
<BD3976C6-7F37-40EF-9FB1-CF55828A807D@redhat.com>
I ran into a bug with the example in the man page for filter-branch, for moving everything into a subdir:
           git filter-branch --index-filter \
                   'git ls-files -s | sed "s-\t\"*-&newsubdir/-" |
                           GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
                                   git update-index --index-info &&
                    mv "$GIT_INDEX_FILE.new" "$GIT_INDEX_FILE"' HEAD
The problem seems to be when a commit happens that is just a file removal with no added file.  In those cases, git ls-files doesn't output anything.  Trying to throw a -d option in doesn't seem to improve matters.
So the problem is that if a commit is just file removals, this example will actually crash.  Unfortunately I don't have a suggested solution at the moment.

-- Jesse Keating Fedora -- Freedom² is a feature! identi.ca: http://identi.ca/jkeating

Message 1 of 1 in “Bug in filter-branch example for moving into a subdirectory”
  1. Jesse KeatingDec 10, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.