English 中文(简体)
How to Diff Files Directly from the Linux Kernel GIT Repository?
原标题:

I d like to be able to diff files / directories directly from the Linux Kernel GIT repository without having to download full source.

Specifically, I m interested in two potential solutions:

  1. The ability to do diff s via a web browser ( firefox )
  2. A GUI utility for Ubuntu that can do remote diffs.
  3. A tutorial how to setup option #2

Edit

As an example of what I m looking for, I used to use CrossVC for the above tasks on a CVS repo.

问题回答

Gitweb at kernel.org allows to view diff between arbitrary commits, see for example the following link for diff between v2.6.32-rc6 and v2.6.32-rc7:
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;hp=refs/tags/v2.6.32-rc6;h=refs/tags/v2.6.32-rc7 (use patch link to get plain patch that you can apply), and between arbitrary versions of file / between arbitrary versions of arbitrary files, e.g.: diff to current link in history view.

Unfortunately neither official gitweb version (distributed together with Git itself), nor the fork used by kernel.org generates links between arbitrary commits, so you would have to handcraft (create by hand) URLs to give to gitweb. In the case of commitdiff view (action) the iparameters you need are h (hash) and hp (hash parent); in the case of blobdiff view they are hb (hash base) and hpb (hash parent base), and also f (filename) and fp (file parent).

Templates

Note that core gitweb (but not the fork used by kernel.org, currently) you can use path_info version, e.g.:
http://repo.or.cz/w/git.git/blobdiff/A..B:/<filename>


How to find it

  1. Find in a web interface a commit which is a merge commit, for example
    https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=1c5aefb5b12a90e29866c960a57c1f8f75def617

  2. Find a link to diff between a commit and a second parent, for example
    https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/diff/?id=1c5aefb5b12a90e29866c960a57c1f8f75def617&id2=54a217887a7b658e2650c3feff22756ab80c7339

  3. Replace SHA-1 of compared commits with revision names or revision identifiers you want to compare, for example to generate diff between v3.15-rc8 and v3.15-rc7
    https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/diff/?id=v3.15-rc8&id2=v3.15-rc7

    or to generate patch (rawdiff)
    https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/rawdiff/?id=v3.15-rc8&id2=v3.15-rc7

The system which creates the diff (whether that might be your webserver or your local system) must have a full copy (clone) of the git repo.

So you cannot do "remote diffs".

So, if you want to avoid doing a git clone of the whole kernel, why not just point your web browser to http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=summary?

Since 2013, the reworked kernel.org website uses cgit to browse repositories.

As an example of cgit URL for a diff between two tags:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/diff/?id=v3.19-rc2&id2=v3.19-rc1&dt=2


That is also why Git 2.38 (Q3 2022) modified gitweb: gitweb had legacy URL shortener that is specific to the way projects hosted on kernel.org. It used to (but no longer) work, and has been removed.

See commit 75707da (26 Jul 2022) by Julien Rouhaud (rjuju).
(Merged by Junio C Hamano -- gitster -- in commit dcdcc37, 05 Aug 2022)

gitweb: remove title shortening heuristics

Signed-off-by: Julien Rouhaud

Those heuristics are way outdated and too specific to the kernel project to be useful outside of kernel.org.
Since kernel.org doesn t use gitweb anymore and at least one project complained about incorrect behavior, entirely remove them.





相关问题
git confusion - cloning a repo is returning a past version

Im having some confusion with my git usage. I cloned a repo from one comp to the other, and the new clone is the state of the original that was active some time ago. So its cloning a past version. ...

Appropriate strategy for tagging and hotfixing with git

I was wondering if the strategy I m using for tagging and hotfixing tags (which then I use for deploying rails applications) with git is appropriate. For tagging I just tag a commit of the master ...

Tips on upgrading CVS to git/hg?

We still use CVS, I use git and hg for my personal use though I m still a novice at both, but I realize they re much more modern and better, faster, distributed, etc. It s just everyone is so ...

Using Git in a TFS shop

Using Git at home has spoiled me - I now find using TFS at work to be a bit of a drag and want to explore the possibility of using Git locally and syncing somehow with TFS. I figure there are a few ...

热门标签