Boost logo

Boost :

Subject: Re: [boost] [git] The any library does not pull cleanly because of a forced update on develop and master.
From: Ahmed Charles (acharles_at_[hidden])
Date: 2013-12-10 23:42:39


> To: boost_at_[hidden]
> From: eldiener_at_[hidden]
> Date: Tue, 10 Dec 2013 22:19:30 -0500
> Subject: Re: [boost] [git] The any library does not pull cleanly because of a forced update on develop and master.
>
> It sounded like in git one must continuously specify --follow after the
> move with each commit in order to preserve history, or was the person
> who said that mistaken ?
>
> Intuitively to me once one uses a command to tell git that a file in a
> repository is being moved/renamed to something else in the repository
> and that the previous history should follow that file, then one should
> always be able to see the full history of that file both before ane
> after the move/rename.
>
> >
> > It's just as painful in SVN to view the contents of a past file through
> > a copy/move/delete, until you get experienced with peg revisions or you
> > use an interactive repository browser to view the whole tree as it
> > appeared in the past.
> >
> > (And, once you know a commit hash prior to the move, you can use "gitk
> > 5a0d9820ac6bd4068a1fa3075d45904ed5341675" to view that revision and its
> > history, just like you can with SVN.)
>
> I do not think that one should ever have to know some abstruse commit
> number in order to see the history of a file in a repository.

There seems to be some amount of misinformation/confusion in this thread, so here's an example:

== Create the repository.
~ $ mkdir file
~ $ cd file/
~/file $ git init
Initialized empty Git repository in ~/file/.git/
~/file (master #) $ git status
# On branch master
#
# Initial commit
#
nothing to commit (create/copy files and use "git add" to track)

== Add a file and make a series of commits with changes to it.
~/file (master #) $ echo "line 1" >> file.txt
~/file (master #%) $ git add file.txt
~/file (master #) $ git ci -m "line 1"
[master (root-commit) d29d848] line 1
 1 file changed, 1 insertion(+)
 create mode 100644 file.txt
~/file (master) $ echo "line 2" >> file.txt
~/file (master *) $ git ci -a -m "line 2"
[master 7c0ee29] line 2
 1 file changed, 1 insertion(+)
~/file (master) $ echo "line 3" >> file.txt
~/file (master *) $ git ci -a -m "line 3"
[master c7b1f4c] line 3
 1 file changed, 1 insertion(+)

== Move the file to a new name.
~/file (master) $ git mv file.txt other.txt
~/file (master +) $ git st
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# renamed: file.txt -> other.txt
#
~/file (master +) $ git ci -m "move file.txt to other.txt"
[master 5e581f3] move file.txt to other.txt
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename file.txt => other.txt (100%)

== Add another change to the file under it's new name.
~/file (master) $ echo "line 4" >> other.txt
~/file (master *) $ git ci -a -m "line 4"
[master c4a8b48] line 4
 1 file changed, 1 insertion(+)

== Run git log, which shows all of the commits.
~/file (master) $ git log
commit c4a8b48fbf38a9b06376b30a36a76b6a674384a9
Author: Ahmed Charles <ahmedcharles_at_[hidden]>
Date: Tue Dec 10 20:19:41 2013 -0800

    line 4

commit 5e581f3b61a759b8e572e7fe4f1a2081bcb7aed8
Author: Ahmed Charles <ahmedcharles_at_[hidden]>
Date: Tue Dec 10 20:19:19 2013 -0800

    move file.txt to other.txt

commit c7b1f4ce30b199794e29a151642267d84842d03b
Author: Ahmed Charles <ahmedcharles_at_[hidden]>
Date: Tue Dec 10 20:18:31 2013 -0800

    line 3

commit 7c0ee297b1f76c73badbc07b5bf426f5cb521e35
Author: Ahmed Charles <ahmedcharles_at_[hidden]>
Date: Tue Dec 10 20:17:54 2013 -0800

    line 2

commit d29d848569c0d620e45d6e18d10650da1c0cf1d4
Author: Ahmed Charles <ahmedcharles_at_[hidden]>
Date: Tue Dec 10 20:17:25 2013 -0800

    line 1

== Run git log <file>, which shows commits to that file, note, it only shows the last two.
~/file (master) $ git log other.txt
commit c4a8b48fbf38a9b06376b30a36a76b6a674384a9
Author: Ahmed Charles <ahmedcharles_at_[hidden]>
Date: Tue Dec 10 20:19:41 2013 -0800

    line 4

commit 5e581f3b61a759b8e572e7fe4f1a2081bcb7aed8
Author: Ahmed Charles <ahmedcharles_at_[hidden]>
Date: Tue Dec 10 20:19:19 2013 -0800

    move file.txt to other.txt

== Run git log --follow <file>, which shows commits to that file and follows the file through moves.
~/file (master) $ git log --follow other.txt
commit c4a8b48fbf38a9b06376b30a36a76b6a674384a9
Author: Ahmed Charles <ahmedcharles_at_[hidden]>
Date: Tue Dec 10 20:19:41 2013 -0800

    line 4

commit 5e581f3b61a759b8e572e7fe4f1a2081bcb7aed8
Author: Ahmed Charles <ahmedcharles_at_[hidden]>
Date: Tue Dec 10 20:19:19 2013 -0800

    move file.txt to other.txt

commit c7b1f4ce30b199794e29a151642267d84842d03b
Author: Ahmed Charles <ahmedcharles_at_[hidden]>
Date: Tue Dec 10 20:18:31 2013 -0800

    line 3

commit 7c0ee297b1f76c73badbc07b5bf426f5cb521e35
Author: Ahmed Charles <ahmedcharles_at_[hidden]>
Date: Tue Dec 10 20:17:54 2013 -0800

    line 2

commit d29d848569c0d620e45d6e18d10650da1c0cf1d4
Author: Ahmed Charles <ahmedcharles_at_[hidden]>
Date: Tue Dec 10 20:17:25 2013 -0800

    line 1

So, to be accurate, the complaint is that '--follow' is required when running git log on a file which has been moved at some point in it's history.

The point about gitk would simply be that you need to copy/paste a sha1 from the output of git log and using it, for example, 'gitk c7b1f4ce30b199794e29a151642267d84842d03b'. Note, I don't have gitk, so I haven't tested this part.

I don't find either of these aspects of git to be a compelling reason to modify history, which is generally considered to be poor form in any git community and boost should be no different. Making everyone who is using boost through git deal with a non-fast-forward merge is too high a cost for simply getting to avoid typing 8 extra characters, especially when you can just do:

git config --global alias.logf 'log --follow'

And then whenever you do 'git logf file.txt' it will follow that file for you (and if you make the alias lf, it's less typing than before).

I second the request to have boost policy changed to disallow modifying history without really good reasons to do so, where really good means that there is some form of consensus on the list before the change is made.

                                               


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk