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

[PATCH] Improved example "To move the whole tree into a subdirectory...".

From
Brett Randall <javabrett@gmail.com>
Date
Jun 1, 2015, 13:04 UTC
Message-ID
<CALeEUB57ou3xd85wHb=KVkrHJv2XZc+oeMA3LnNrwPgH_icrkA@mail.gmail.com>

Previously this example would fail if the history contained any empty commit, because the index would not change, and the mv would fail with:

mv: cannot stat <redacted>/index.new': No such file or directory

The updated example checks whether the index file has been created before attempting the mv. The empty commit is retained.

See http://stackoverflow.com/questions/7798142/error-combining-git-repositories-into-subdirs for an example and explanation.

Signed-off-by: Brett Randall <javabrett@gmail.com>
---
 Documentation/git-filter-branch.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Documentation/git-filter-branch.txt
b/Documentation/git-filter-branch.txt
index 73fd9e8..0b9e690 100644
--- a/Documentation/git-filter-branch.txt
+++ b/Documentation/git-filter-branch.txt
@@ -385,7 +385,7 @@ 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
+        if [ -f "$GIT_INDEX_FILE.new" ]; then mv
"$GIT_INDEX_FILE.new" "$GIT_INDEX_FILE"; fi' HEAD
 ---------------------------------------------------------------
-- 
2.3.5
Message 1 of 1 in “Improved example "To move the whole tree into a subdirectory...".”
  1. Improved example "To move the whole tree into a subdirectory...".Brett Randall, Jun 1, 2015

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.