def diff_for_untracked_file(filename):
    # Start "diff" text
    diff_text = 'New file: %s\n' % filename

    # Detect whether file is binary
    if is_binary_file(filename):
        diff_text += "@@ File is binary.\n\n"
    else:
        # Text file => show lines
        newfile_text = ''
        try:
            f = open(filename, 'r')
            lines = f.readlines()
            f.close()

            newfile_text += '@@ -1,0 +1,%d @@\n' % len(lines)

            for line in lines:
                newfile_text += '+ ' + line

            diff_text += newfile_text
        except __HOLE__:
            diff_text += '@@ Error: Cannot open file\n\n'

    return diff_text
dataset/ETHPy150Open gyim/stupidgit/stupidgit_gui/git.py/diff_for_untracked_file