首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >404未找到-缺少一个blob diff参数

404未找到-缺少一个blob diff参数
EN

Stack Overflow用户
提问于 2012-03-29 19:32:54
回答 1查看 608关注 0票数 3

在本地的ikiwiki上,我使用gitweb浏览文件历史记录。如果我在ikiwiki中单击history,然后在gitweb中单击diff to current,它将指向一个URL,如下所示:

代码语言:javascript
复制
http://localhost/gitweb/gitweb.cgi?p=.git;a=blobdiff;f=index.mdwn;h=0622da9b56b6a4f79388f3dc539d4c7d603ae4e9;hp=619d6d14eaf36b6bff80f7b68ce4f139fa0de9b2;hpb=000825c005ffc4c62279509119d80f1262023338

并显示错误消息:

404未找到-缺少一个blob diff参数

然而,blob和commitdiff是有效的。

有什么办法解决这个问题吗?

EN

回答 1

Stack Overflow用户

发布于 2012-07-12 09:27:11

下面是来自最新源代码root/gitweb/gitweb.perl的代码片段

代码语言:javascript
复制
# preparing $fd and %diffinfo for git_patchset_body
# new style URI
if (defined $hash_base && defined $hash_parent_base) {
    if (defined $file_name) {
        # read raw output
        open $fd, "-|", git_cmd(), "diff-tree", '-r', @diff_opts,
            $hash_parent_base, $hash_base,
            "--", (defined $file_parent ? $file_parent : ()), $file_name
            or die_error(500, "Open git-diff-tree failed");
        @difftree = map { chomp; $_ } <$fd>;
        close $fd
            or die_error(404, "Reading git-diff-tree failed");
        @difftree
            or die_error(404, "Blob diff not found");

    } elsif (defined $hash &&
             $hash =~ /[0-9a-fA-F]{40}/) {
        # try to find filename from $hash

        # read filtered raw output
        open $fd, "-|", git_cmd(), "diff-tree", '-r', @diff_opts,
            $hash_parent_base, $hash_base, "--"
            or die_error(500, "Open git-diff-tree failed");
        @difftree =
            # ':100644 100644 03b21826... 3b93d5e7... M    ls-files.c'
            # $hash == to_id
            grep { /^:[0-7]{6} [0-7]{6} [0-9a-fA-F]{40} $hash/ }
            map { chomp; $_ } <$fd>;
        close $fd
            or die_error(404, "Reading git-diff-tree failed");
        @difftree
            or die_error(404, "Blob diff not found");

    } else {
        die_error(400, "Missing one of the blob diff parameters");
    }

    if (@difftree > 1) {
        die_error(400, "Ambiguous blob diff specification");
    }

    %diffinfo = parse_difftree_raw_line($difftree[0]);
    $file_parent ||= $diffinfo{'from_file'} || $file_name;
    $file_name   ||= $diffinfo{'to_file'};

    $hash_parent ||= $diffinfo{'from_id'};
    $hash        ||= $diffinfo{'to_id'};

    # non-textual hash id's can be cached
    if ($hash_base =~ m/^[0-9a-fA-F]{40}$/ &&
        $hash_parent_base =~ m/^[0-9a-fA-F]{40}$/) {
        $expires = '+1d';
    }

    # open patch output
    open $fd, "-|", git_cmd(), "diff-tree", '-r', @diff_opts,
        '-p', ($format eq 'html' ? "--full-index" : ()),
        $hash_parent_base, $hash_base,
        "--", (defined $file_parent ? $file_parent : ()), $file_name
        or die_error(500, "Open git-diff-tree failed");
}

# old/legacy style URI
if (!%diffinfo && # if new style URI failed
    defined $hash && defined $hash_parent) {
    # fake git-diff-tree raw output
    $diffinfo{'from_mode'} = $diffinfo{'to_mode'} = "blob";
    $diffinfo{'from_id'} = $hash_parent;
    $diffinfo{'to_id'}   = $hash;
    if (defined $file_name) {
        if (defined $file_parent) {
            $diffinfo{'status'} = '2';
            $diffinfo{'from_file'} = $file_parent;
            $diffinfo{'to_file'}   = $file_name;
        } else { # assume not renamed
            $diffinfo{'status'} = '1';
            $diffinfo{'from_file'} = $file_name;
            $diffinfo{'to_file'}   = $file_name;
        }
    } else { # no filename given
        $diffinfo{'status'} = '2';
        $diffinfo{'from_file'} = $hash_parent;
        $diffinfo{'to_file'}   = $hash;
    }

    # non-textual hash id's can be cached
    if ($hash =~ m/^[0-9a-fA-F]{40}$/ &&
        $hash_parent =~ m/^[0-9a-fA-F]{40}$/) {
        $expires = '+1d';
    }

    # open patch output
    open $fd, "-|", git_cmd(), "diff", @diff_opts,
        '-p', ($format eq 'html' ? "--full-index" : ()),
        $hash_parent, $hash, "--"
        or die_error(500, "Open git-diff failed");
} else  {
    die_error(400, "Missing one of the blob diff parameters")
        unless %diffinfo;
}

下面还有其他代码片段(省略了无关代码)用于参数解析:

代码语言:javascript
复制
our $file_name = $cgi->param('f');
our $hash = $cgi->param('h');
our $hash_parent = $cgi->param('hp');
our $hash_base = $cgi->param('hb');
our $hash_parent_base = $cgi->param('hpb');

因此,以下内容是假的:

代码语言:javascript
复制
defined $hash_base 

不幸的是,这些是我的全部。

根据上述代码,预计不会出现例外情况。

然而,你的gitweb可能不是最新的。我建议你查查你的消息来源。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9932198

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档