CS61B|关于Merge信息的显示

问题描述

这样的时候合并信息是正常的

private static String getString(Blob curCommitBlob, Blob givenCommitBlob) {  
    byte[] curFileContent = new byte[0];  
    if (curCommitBlob != null) {  
        curFileContent = curCommitBlob.getContent().getBytes(StandardCharsets.UTF_8);  
    } else {  
        curFileContent = new byte[0];  
    }  
    byte[] givenFileContent = null;  
    if (givenCommitBlob != null) {  
        givenFileContent = givenCommitBlob.getContent().getBytes(StandardCharsets.UTF_8);  
    } else {  
        givenFileContent = new byte[0];  
    }  
    byte[] head = "<<<<<<< HEAD\n".getBytes(StandardCharsets.UTF_8);  
    byte[] body = "=======\n".getBytes(StandardCharsets.UTF_8);  
    byte[] feet = ">>>>>>>\n".getBytes(StandardCharsets.UTF_8);  
    ByteArrayOutputStream str = new ByteArrayOutputStream();  
    try {  
        str.write(head);  
        str.write(curFileContent);  
        str.write(body);  
        str.write(givenFileContent);  
        str.write(feet);  
    } catch (IOException e) {  
        throw new RuntimeException(e);  
    }  
    return str.toString();  
}

这样就不正常了

private static String getString(Blob curCommitBlob, Blob givenCommitBlob) {  
    String curFileContent = null;  
    if (curCommitBlob != null) {  
        curFileContent = curCommitBlob.getContent();  
    } else {  
        curFileContent = "";  
    }  
    String givenFileContent = null;  
    if (givenCommitBlob != null) {  
        givenFileContent = givenCommitBlob.getContent();  
    } else {  
        givenFileContent = "";  
    }  
    return "<<<<<<< HEAD\n" +  
            curFileContent + "\n" +  
            "=======\n" +  
            givenFileContent + "\n" +  
            ">>>>>>>";  
}

这样写在我本地是这个格式

96297c947428ccfd651cc8cb446c8780.png

但是在评分机上会变成,多了一行回车!是不是很奇怪

<<<<<<< HEAD
Another wug.
=======
This is not a wug.

>>>>>>>

所以我最终的版本跑起来是这样,到现在依旧困惑

<<<<<<< HEAD
Another wug.
=======
This is not a wug.>>>>>>>
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇