filter-branch --subdirectory-filter fails on a branch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi there.

While splitting up a repository using git-filter-branch I stumbled upon
a tad weird case in which --subdirectory-filter refuses to filter out
a subdir on one of the branches, but succeeds on others. In addition,
in some cases git-filter-branch refuses to run unless git-status is
invoked first.

In a nutshell, I have 2 subdirs at top level which I want to turn into
separate repos, A and B. There are 2 topic branches in repo: Topic-A
modifying exclusively A subdir, Topic-B - modifying exclusively B
subdir, and master modifying both. Topic-B was branched off of Topic-A
which was branched off of master. Splitting out subdir A works without
a hitch, splitting out subdir B doesn't - Topic-A remains unchanged,
though master and Topic-B are transformed fine. Given full symmetry
of commits (at least in repro case), I find that strange.

Below please find the precise repro steps interleaved with git output,
with interesting points 1,2,3 and 4 commented. Sorry that it came out
quite longish and cluttered. "=====> " represents bash prompt (in vain
attempt to improve readability), grep-ping for it then sed-ding it out
ought to yield executable bash script, I think.

Am I somehow misusing git-filter-branch? Perusing its man page didn't
turn up anything immediately obvious that I might be overlooking. Any
ideas?

Thanks in advance.

V.Solo.


=====> git --version
git version 1.5.5.1
=====> mkdir zzz-both
=====> cd zzz-both
=====> pwd
/tmp/zzz-both
=====> git init
Initialized empty Git repository in .git/
=====> mkdir left
=====> mkdir right
=====> date > left/left.txt
=====> date > right/right.txt
=====> git add left right
=====> git commit -m "initial commit"
Created initial commit 525c08c: initial commit
 2 files changed, 2 insertions(+), 0 deletions(-)
 create mode 100644 left/left.txt
 create mode 100644 right/right.txt
=====> date > left/left.txt
=====> git commit -am "changed left"
Created commit 352e43c: changed left
 1 files changed, 1 insertions(+), 1 deletions(-)
=====> date > right/right.txt
=====> git commit -am "changed right"
Created commit 4c0decd: changed right
 1 files changed, 1 insertions(+), 1 deletions(-)
=====> date > left/left.txt
=====> date > right/right.txt
=====> git commit -am "changed both"
Created commit 4866710: changed both
 2 files changed, 2 insertions(+), 2 deletions(-)
=====> git checkout -b left-refact
Switched to a new branch "left-refact"
=====> date > left/left.txt
=====> git commit -am "left-refact: changed left"
Created commit 81fba4e: left-refact: changed left
 1 files changed, 1 insertions(+), 1 deletions(-)
=====> git show-branch
* [left-refact] left-refact: changed left
 ! [master] changed both
--
*  [left-refact] left-refact: changed left
*+ [master] changed both
=====> git checkout -b right-refact
Switched to a new branch "right-refact"
=====> date > right/right.txt
=====> git commit -am "right-refact: changed right"
Created commit 5cbddaa: right-refact: changed right
 1 files changed, 1 insertions(+), 1 deletions(-)
=====> git checkout master
Switched to branch "master"
=====> git show-branch --more=10
! [left-refact] left-refact: changed left
 * [master] changed both
  ! [right-refact] right-refact: changed right
---
  + [right-refact] right-refact: changed right
+ + [left-refact] left-refact: changed left
+*+ [master] changed both
+*+ [master^] changed right
+*+ [master~2] changed left
+*+ [master~3] initial commit
=====> ls *
left:
left.txt

right:
right.txt
=====> cp -r . ../zzz-left
=====> pwd
/tmp/zzz-both
=====> cd ../zzz-left/
=====> pwd
/tmp/zzz-left
=====> git branch
  left-refact
* master
  right-refact
=====> # (1) weirdness #1 : why do I have to "git status" first?
=====> git filter-branch --subdirectory-filter left HEAD left-refact
right-refact
Cannot rewrite branch(es) with a dirty working directory.
=====> git status
# On branch master
nothing to commit (working directory clean)
=====> git filter-branch --subdirectory-filter left HEAD left-refact
right-refact
Rewrite 81fba4e28d8b18bfcc4b139479ce547017a25dce (4/4)
Ref 'refs/heads/master' was rewritten
Ref 'refs/heads/left-refact' was rewritten
Ref 'refs/heads/right-refact' was rewritten
=====> git reset --hard
HEAD is now at 91fdc32 changed both
=====> ls
left.txt
=====> git show-branch --more=10
! [left-refact] left-refact: changed left
 * [master] changed both
  ! [right-refact] left-refact: changed left
---
+ + [left-refact] left-refact: changed left
+*+ [master] changed both
+*+ [master^] changed left
+*+ [master~2] initial commit
=====> git log --pretty=oneline --name-status left-refact
ea1d9b2391a94952658c0a1ccc7fd6f1b7fb9348 left-refact: changed left
M   left.txt
91fdc32587a7e688970fe8b77aac51820a53aed0 changed both
M   left.txt
c62bf71dc9f6684598212beb056a8ad2e17fea91 changed left
M   left.txt
360b8064403f7e86075eb6722919776e2d6981c5 initial commit
A   left.txt
=====> cp ../zzz-both/ ../zzz-right
cp: omitting directory `../zzz-both/'
=====> cp -r ../zzz-both/ ../zzz-right
=====> pwd
/tmp/zzz-left
=====> cd ../zzz-right/
=====> pwd
/tmp/zzz-right
=====> git branch
  left-refact
* master
  right-refact
=====> # (2) weirdness #1 : why do I have to "git status" first?
=====> git filter-branch --subdirectory-filter right HEAD left-refact
right-refact
Cannot rewrite branch(es) with a dirty working directory.
=====> git status
# On branch master
nothing to commit (working directory clean)
=====> # (3) weirdness #2 : filter-branch fails
=====> git filter-branch --subdirectory-filter right HEAD left-refact
right-refact
Rewrite 5cbddaa45ae4fa53170dbbd1adcf86d841709c36 (4/4)
Ref 'refs/heads/master' was rewritten
WARNING: Ref 'refs/heads/left-refact' is unchanged
Ref 'refs/heads/right-refact' was rewritten
=====> git reset --hard
HEAD is now at 9a16605 changed both
=====> ls
right.txt
=====> # (4) weirdness #2 : indeed, left-refact is intact
=====> git show-branch --more=10
! [left-refact] left-refact: changed left
 * [master] changed both
  ! [right-refact] right-refact: changed right
---
  + [right-refact] right-refact: changed right
 *+ [master] changed both
 *+ [master^] changed right
 *+ [master~2] initial commit
+   [left-refact] left-refact: changed left
+   [left-refact^] changed both
+   [left-refact~2] changed right
+   [left-refact~3] changed left
+   [left-refact~4] initial commit
=====> git log --pretty=oneline --name-status left-refact
81fba4e28d8b18bfcc4b139479ce547017a25dce left-refact: changed left
M   left/left.txt
4866710cda33fcf563486f94883550e6e41eedc1 changed both
M   left/left.txt
M   right/right.txt
4c0decd9458301b474fa16be8344a436aaf4e97f changed right
M   right/right.txt
352e43c705fcdac0abeaae78a814820146130cb3 changed left
M   left/left.txt
525c08c8fdc51ef81aae40f26423259b1f394e61 initial commit
A   left/left.txt
A   right/right.txt
=====> git log --pretty=oneline --name-status right-refact
55f1c2a693e7447ae8f5cb3b9b4994c815a5c2b7 right-refact: changed right
M   right.txt
9a16605e9650d82abdf64edd102c9824d4468c71 changed both
M   right.txt
b5ebdf2d5027ca9372a0811636604a9670b762dd changed right
M   right.txt
56f5e5c2ad98cc1597bbb5b97e291452fd3b9fd9 initial commit
A   right.txt
=====> git checkout left-refact
Switched to branch "left-refact"
=====> ls *
left:
left.txt

right:
right.txt
=====>
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux