开发者

How to Diff Files Directly from the Linux Kernel GIT Repository?

开发者 https://www.devze.com 2022-12-11 17:17 出处:网络
I\'d like to be able to diff files / directories directly from the Linux Kernel GIT repository without having to download full source.

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
  4. 开发者_运维技巧

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

  • For diff between two arbitrary commits (equivalent of git diff A B from command line) http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;hp=A;h=B

  • For diff between two versions of the same file (equivalent of git diff A B <filename>). http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blobdiff;f=<filename>;hpb=A;hp=B

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消