Download raw body.
got diff vs .gitignore
Hello, I noticed that `got diff' and .gitignore have a strange relationship. I was working in an autotools project, my .gitignore had "**/Makefile" in it; one sub-directory thought has plain Makefile that was properly added to the repository. `got diff' showed the diff for it, but `got diff path/to/Makefile' didn't! Patch below adds a test case and fixes the isuse for me. Regress is passing, but I'm not 100% sure that the patch is correct. got_worktree_status takes a flag `no_ignores'; i'm merely switching it to don't skip ignored files. diff 5a20d08d6546fa260cd5ce2ed01e438f5ec35f41 /home/op/w/got-diff blob - 23e3b35d2df3662ccdf58a8fd4544ed6490c1a3c file + got/got.c --- got/got.c +++ got/got.c @@ -4680,7 +4680,7 @@ cmd_diff(int argc, char *argv[]) arg.ignore_whitespace = ignore_whitespace; arg.force_text_diff = force_text_diff; - error = got_worktree_status(worktree, &paths, repo, 0, + error = got_worktree_status(worktree, &paths, repo, 1, print_diff, &arg, check_cancelled, NULL); free(id_str); goto done; blob - 66d5c86494cc7a9c82ea9071428274079529ae7f file + regress/cmdline/diff.sh --- regress/cmdline/diff.sh +++ regress/cmdline/diff.sh @@ -1182,6 +1182,36 @@ test_diff_commits() { test_done "$testroot" "$ret" } +test_diff_ignored_file() { + local testroot=`test_init diff_ignored_file` + + got checkout $testroot/repo $testroot/wt > /dev/null + ret=$? + if [ $ret != 0 ]; then + test_done "$testroot" "$ret" + return 1 + fi + + echo 1 > $testroot/wt/number + (cd $testroot/wt && got add number >/dev/null) + (cd $testroot/wt && got commit -m 'add number' >/dev/null) + + echo "**/number" > $testroot/wt/.gitignore + + echo 2 > $testroot/wt/number + (cd $testroot/wt && got diff number | sed '1,/^@@/d' > $testroot/stdout) + + echo "-1" > $testroot/stdout.expected + echo "+2" >> $testroot/stdout.expected + + cmp -s $testroot/stdout.expected $testroot/stdout + ret=$? + if [ $ret != 0 ]; then + diff -u $testroot/stdout.expected $testroot/stdout + fi + test_done "$testroot" "$ret" +} + test_parseargs "$@" run_test test_diff_basic run_test test_diff_shows_conflict @@ -1193,3 +1223,4 @@ run_test test_diff_symlinks_in_work_tree run_test test_diff_symlinks_in_repo run_test test_diff_binary_files run_test test_diff_commits +run_test test_diff_ignored_file
got diff vs .gitignore