Directory renames without breaking git log.

Previous thread: none

Next thread: Are more and more patches getting lost lately? by Nanako Shiraishi on Wednesday, September 3, 2008 - 7:33 pm. (7 messages)
To: <git@...>
Date: Wednesday, September 3, 2008 - 5:38 pm

Hi folks,

in an effort to make Samba development easier, we're trying to merge the=20
Samba3 and Samba4 branches into a single branch. In order to do so, we need=
=20
to rename the "source" directories both Samba 3 and Samba 4 have (we're=20
planning to use source3 and source4).

Unfortunately, the directories are big enough that git log stops to track t=
he=20
renamed files, so e.g. git log ./samba3 does not show the samba3 history. T=
he=20
history is not lost, of course, but it's way less intuitive to get it.

Here's how we merged the two branches:

$ mkdir samba-merged
$ cd samba-merged
$ git init
=2E.. (create COPYING, README and other top-level files, git add them)
$ git commit -m "Initial commit of merged samba"
$ git remote add git://git.samba.org/samba.git samba
$ git remote update
$ cp -a ~/samba3/source source3
$ cp -a ~/samba4/source source4
$ git add source3 source4
$ git write-tree
$ echo "merge branches" | git commit-tree <sha1 git write-tree retured> \
-p <sha1 of the initial commit> \
-p <sha1 of the current samba3 head> \
-p <sha1 of the current samba4 head>
$ git reset --hard <sha1 returned by git commit-tree>
$ git log
=2E.. history is there as expected
$ git log samba3
=2E.. history is just the merge commit
$ git log samba4
=2E.. history is just the merge commit

Is there any way to fix this that doesn't involve changing the history with=
=20
git-filter-branch?

Cheers,
Kai

=2D-=20
Kai Blin
WorldForge developer http://www.worldforge.org/
Wine developer http://wiki.winehq.org/KaiBlin
Samba team member http://www.samba.org/samba/team/
=2D-
Will code for cotton.

To: Kai Blin <kai@...>
Cc: <git@...>
Date: Wednesday, September 3, 2008 - 8:16 pm

You can try setting diff.renamelimit to 0 in your ~/.gitconfig. See
Linus's email here for a similar situation in the kernel:
http://lwn.net/Articles/292948/

Thanks,
Tarmigan
--

To: <git@...>
Date: Thursday, September 4, 2008 - 3:45 pm

That doesn't seem to fix "git log path/to/file" cases. The really interesti=
ng=20
part is that if I try git log --follow -M -C path/to/file, I don't get any=
=20
history at all. (--follow is the culprit, if I remove that I at least get t=
he=20
merge commit)

git blame still works, and git log --sparse path/to/file works, of=20
course. --sparse makes giving a path a bit pointless, of course, but we=20
probably can live with that for time being. I'm still open for suggestions,=
=20
of course. :)

Cheers,
Kai

=2D-=20
Kai Blin
WorldForge developer http://www.worldforge.org/
Wine developer http://wiki.winehq.org/KaiBlin
Samba team member http://www.samba.org/samba/team/
=2D-
Will code for cotton.

To: Kai Blin <kai@...>
Cc: <git@...>
Date: Thursday, September 4, 2008 - 4:41 pm

Unfortunately "git log --follow <filename>" works correctly only
on relative simple histories. You are of course welcome to improve
this part of git.

Simple workaround is to use "git log <file>" (optionally using
--diff-filter) to get when file vanished, check using "git show" or
"git whatchanged" on boundary commit, then use
"git log -C -C -- <old name> <new name>"
--
Jakub Narebski
Poland
ShadeHawk on #git
--

To: Kai Blin <kai@...>
Cc: <git@...>
Date: Thursday, September 4, 2008 - 3:49 pm

Give both directories, like:

"git log -- newdir olddir"

perhaps?
--

To: Junio C Hamano <gitster@...>
Cc: <git@...>
Date: Thursday, September 4, 2008 - 4:52 pm

Better, but really ugly, as we'll have to keep doing this for the rest of t=
he=20
project's life to get the full history. And while it's all nice and fun for=
=20
git log -- source3/configure.in source/configure.in, it's less fun for deep=
er=20
paths.

We'll probably end up just doing a git-filter-branch renaming the samba3=20
source dir source3 from the beginning and the samba4 source dir source4 fro=
m=20
the beginning, and then do the octopus merge. Without any paths changing,=20
that should probably work. It's a bit annoying to break all external=20
branches, but we only need to do this once, and people will only need to=20
git-format-patch and git-am once, and we can provide a step-by-step guide f=
or=20
this as well.

Thanks for the feedback, though. :)

Cheers,
Kai

=2D-=20
Kai Blin
WorldForge developer http://www.worldforge.org/
Wine developer http://wiki.winehq.org/KaiBlin
Samba team member http://www.samba.org/samba/team/
=2D-
Will code for cotton.

Previous thread: none

Next thread: Are more and more patches getting lost lately? by Nanako Shiraishi on Wednesday, September 3, 2008 - 7:33 pm. (7 messages)