This is an archive of the discontinued LLVM Phabricator instance.

[clang-diff] Add option to compare files across git revisions
Needs ReviewPublic

Authored by johannes on Aug 14 2017, 9:03 AM.

Details

Reviewers
arphaman
Summary

This adds a command line option "-git-rev=<commit[..commit]>". When it is
used, only one filename is accepted. The file in its version in the specified
revision is compared against the current version (or the one in the second
revision if given). Note that this calls git checkout in the current
directory.

Event Timeline

johannes created this revision.Aug 14 2017, 9:03 AM
arphaman edited edge metadata.Aug 14 2017, 9:13 AM

It might be useful to have both source and destination in a different revision. Maybe something like -src-git-rev and -dst-git-rev?

It might be useful to have both source and destination in a different revision. Maybe something like -src-git-rev and -dst-git-rev?

Then I'd rather have a revision range such as -git-revs <commit>..<commit>
and if there is only one specified, then <commit>..HEAD is implied
maybe a different name for the argument

The whole thing is a bit of a hack - if the HEAD is dirty then the checkout fails and the program exits.

I want to change it so it does not interfere with the state of the repository. I can checkout the revisions in a temporary repository and then patch the paths in the compilation database.

That would be nice. Temporary checkouts are a way to solve the problem. But they might not work for all projects, like when some translation unit includes a file that's not in git using a relative path.

Another solution is to use virtual file systems. A custom vfs could load the files that are in a particular git revision. Then, an overlay fs can be used to combine both the git vfs and the real fs. That overlay should be somehow passed into the AST producer. I don't think it's worth doing this right now because of time constraints, so temporary checkouts is probably the better solution for the time being.

johannes updated this revision to Diff 111328.Aug 16 2017, 5:24 AM
johannes edited the summary of this revision. (Show Details)

accept a commit range