commit 3cbbd752fbb743b19cc6954d6256fed51c1eaf30 from: Stefan Sperling date: Tue Feb 19 11:55:43 2019 UTC fix get_file_status() for files larger than blob read buffer size commit - af54ae4ac103d1529bb5e06bfd22ed88d78fed29 commit + 3cbbd752fbb743b19cc6954d6256fed51c1eaf30 blob - 1e6da727f7787dd70ee6ecadf0cc83c45400d0fe blob + 4eccffd610b224983a5ebcaf1cdc065830d8c882 --- lib/worktree.c +++ lib/worktree.c @@ -900,7 +900,8 @@ get_file_status(unsigned char *status, struct stat *sb err = got_object_blob_read_block(&blen, blob); if (err) break; - flen = fread(fbuf, 1, sizeof(fbuf), f); + /* Skip length of blob object header first time around. */ + flen = fread(fbuf, 1, sizeof(fbuf) - hdrlen, f); if (blen == 0) { if (flen != 0) *status = GOT_STATUS_MODIFY; blob - da1fdaef160970e7af9e50319de23d9026bce53a blob + 72eb5ceab648e97bb44c7724ab30d699eb1327eb --- regress/cmdline/status.sh +++ regress/cmdline/status.sh @@ -267,7 +267,60 @@ function test_status_ignores_symlink { fi ln -s /usr/obj/distrib/i386/ramdisk $testroot/wt/ramdisk/obj + + echo -n > $testroot/stdout.expected + + (cd $testroot/wt && got status > $testroot/stdout) + + cmp $testroot/stdout.expected $testroot/stdout + ret="$?" + if [ "$ret" != "0" ]; then + diff -u $testroot/stdout.expected $testroot/stdout + fi + test_done "$testroot" "$ret" +} + +function test_status_shows_no_mods_after_complete_merge { + local testroot=`test_init status_shows_no_mods_after_complete_merge 1` + + # make this file larger than the usual blob buffer size of 8192 + echo -n > $testroot/repo/numbers + for i in `jot 16384`; do + echo "$i" >> $testroot/repo/numbers + done + + (cd $testroot/repo && git add numbers) + git_commit $testroot/repo -m "added numbers file" + + got checkout $testroot/repo $testroot/wt > /dev/null + ret="$?" + if [ "$ret" != "0" ]; then + test_done "$testroot" "$ret" + return 1 + fi + sed -i 's/2/22/' $testroot/repo/numbers + git_commit $testroot/repo -m "modified line 2" + + sleep 1 + # modify line 2 again; no local changes are left after merge + sed -i 's/2/22/' $testroot/wt/numbers + + echo "G numbers" > $testroot/stdout.expected + echo -n "Updated to commit " >> $testroot/stdout.expected + git_show_head $testroot/repo >> $testroot/stdout.expected + echo >> $testroot/stdout.expected + + (cd $testroot/wt && got update > $testroot/stdout) + + cmp $testroot/stdout.expected $testroot/stdout + ret="$?" + if [ "$ret" != "0" ]; then + diff -u $testroot/stdout.expected $testroot/stdout + test_done "$testroot" "$ret" + return 1 + fi + echo -n > $testroot/stdout.expected (cd $testroot/wt && got status > $testroot/stdout) @@ -287,3 +340,4 @@ run_test test_status_obstructed run_test test_status_shows_local_mods_after_update run_test test_status_unversioned_subdirs run_test test_status_ignores_symlink +run_test test_status_shows_no_mods_after_complete_merge