git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Bug in filter-branch -d option, new files are dumped into parent
@ 2013-04-02 12:32 Martin Erik Werner
  2013-04-02 14:22 ` [PATCH] filter-branch: return to original dir after filtering Jeff King
  0 siblings, 1 reply; 2+ messages in thread
From: Martin Erik Werner @ 2013-04-02 12:32 UTC (permalink / raw)
  To: git

Hi,
I think I have stumbled on a bug in the -d option of git filter-branch.

It seems like in the final stage of filter-branch, regardless of where
-d is set, it will make updates to the "working directory" as being the
parent of the -d directory, and the actual working directory is left as
it were before the filtering.

For example if using -d /tmp/git-rewrite, the new checkout files are
dumped into /tmp.

A simple test scenario:

###
mkdir test
cd test
git init

echo foo >foo
git add foo
git commit -m"foo"
echo bar >bar
git add bar
git commit -m"bar"

git checkout -b rewrite
git filter-branch -d /tmp/git-rewrite --tree-filter 'echo baz >baz' --
rewrite
# git status
# shows 'baz' as unstaged-deleted in the working directory
#
# ls /tmp/
# shows the 'baz' file created in the root, above git-rewrite
#
# git log --stat --oneline
# does show expected result though
#
# if you run it again you'll get an error because of the /tmp/baz file
git reset --hard master
git filter-branch -f -d /tmp/git-rewrite --tree-filter 'echo baz >baz'
-- rewrite
# Rewrite afac18542ac3d432b647866f5ac6918b81b3bb78 (2/2)
# Ref 'refs/heads/rewrite' was rewritten
# error: Untracked working tree file 'baz' would be overwritten by
merge.
#
# At this point, 'baz' is instead staged-deleted in the working
directory
###

-- 
Martin Erik Werner <martinerikwerner@gmail.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-04-02 14:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-02 12:32 Bug in filter-branch -d option, new files are dumped into parent Martin Erik Werner
2013-04-02 14:22 ` [PATCH] filter-branch: return to original dir after filtering Jeff King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).