commit 41f061b2f459318f3738f59d7676efccc4beb344 from: Stefan Sperling date: Tue Oct 05 14:06:02 2021 UTC ignore unversioned files while aborting rebase, histedit, merge or operations ok jrick commit - 90e6e6204014e47bc38fb5bcaf041cfdad190718 commit + 41f061b2f459318f3738f59d7676efccc4beb344 blob - f3b944325b2e9e0dfa3fa707d7d370eeef408780 blob + 9e7130922e1c3dcbe4a75396503fe9120671cb84 --- got/got.c +++ got/got.c @@ -8792,6 +8792,19 @@ done: } static const struct got_error * +abort_progress(void *arg, unsigned char status, const char *path) +{ + /* + * Unversioned files should not clutter progress output when + * an operation is aborted. + */ + if (status == GOT_STATUS_UNVERSIONED) + return NULL; + + return update_progress(arg, status, path); +} + +static const struct got_error * cmd_rebase(int argc, char *argv[]) { const struct got_error *error = NULL; @@ -8944,7 +8957,7 @@ cmd_rebase(int argc, char *argv[]) printf("Switching work tree to %s\n", got_ref_get_symref_target(new_base_branch)); error = got_worktree_rebase_abort(worktree, fileindex, repo, - new_base_branch, update_progress, &upa); + new_base_branch, abort_progress, &upa); if (error) goto done; printf("Rebase of %s aborted\n", got_ref_get_name(branch)); @@ -9029,7 +9042,7 @@ cmd_rebase(int argc, char *argv[]) if (pid == NULL) { if (!continue_rebase) { error = got_worktree_rebase_abort(worktree, fileindex, - repo, new_base_branch, update_progress, &upa); + repo, new_base_branch, abort_progress, &upa); if (error) goto done; printf("Rebase of %s aborted\n", @@ -10217,7 +10230,7 @@ cmd_histedit(int argc, char *argv[]) printf("Switching work tree to %s\n", got_ref_get_symref_target(branch)); error = got_worktree_histedit_abort(worktree, fileindex, repo, - branch, base_commit_id, update_progress, &upa); + branch, base_commit_id, abort_progress, &upa); if (error) goto done; printf("Histedit of %s aborted\n", @@ -10332,7 +10345,7 @@ cmd_histedit(int argc, char *argv[]) if (error) { got_worktree_histedit_abort(worktree, fileindex, repo, branch, base_commit_id, - update_progress, &upa); + abort_progress, &upa); print_merge_progress_stats(&upa); goto done; } @@ -10347,7 +10360,7 @@ cmd_histedit(int argc, char *argv[]) if (error) { got_worktree_histedit_abort(worktree, fileindex, repo, branch, base_commit_id, - update_progress, &upa); + abort_progress, &upa); print_merge_progress_stats(&upa); goto done; } @@ -10359,7 +10372,7 @@ cmd_histedit(int argc, char *argv[]) if (error) { got_worktree_histedit_abort(worktree, fileindex, repo, branch, base_commit_id, - update_progress, &upa); + abort_progress, &upa); print_merge_progress_stats(&upa); goto done; } @@ -10785,7 +10798,7 @@ cmd_merge(int argc, char *argv[]) if (error) goto done; error = got_worktree_merge_abort(worktree, fileindex, repo, - update_progress, &upa); + abort_progress, &upa); if (error) goto done; printf("Merge of %s aborted\n", branch_name); @@ -10870,7 +10883,7 @@ cmd_merge(int argc, char *argv[]) print_merge_progress_stats(&upa); if (!upa.did_something) { error = got_worktree_merge_abort(worktree, fileindex, - repo, update_progress, &upa); + repo, abort_progress, &upa); if (error) goto done; printf("Already up-to-date\n"); blob - 65ef292945ab5a14c0c1674cbd8aec70fc5e9418 blob + 051f0bedccbe45d193bdeb08943bd0f9767a2f04 --- regress/cmdline/histedit.sh +++ regress/cmdline/histedit.sh @@ -832,6 +832,9 @@ test_histedit_abort() { test_done "$testroot" "$ret" return 1 fi + + # unrelated unversioned file in work tree + touch $testroot/wt/unversioned-file echo "edit $old_commit1" > $testroot/histedit-script echo "mesg committing changes" >> $testroot/histedit-script @@ -904,6 +907,7 @@ test_histedit_abort() { (cd $testroot/wt && got status > $testroot/stdout) echo "? epsilon/new" > $testroot/stdout.expected + echo "? unversioned-file" >> $testroot/stdout.expected cmp -s $testroot/stdout.expected $testroot/stdout ret="$?" if [ "$ret" != "0" ]; then blob - be7e58787cda7e3de992a5142542bebcf76ab385 blob + 7531c5533c9965ff12fa5f05ece3f43ddbe40b15 --- regress/cmdline/merge.sh +++ regress/cmdline/merge.sh @@ -621,6 +621,9 @@ test_merge_abort() { test_done "$testroot" "$ret" return 1 fi + + # unrelated unversioned file in work tree + touch $testroot/wt/unversioned-file # create a conflicting commit (cd $testroot/repo && git checkout -q master) @@ -677,6 +680,7 @@ test_merge_abort() { echo "A epsilon/new" >> $testroot/stdout.expected echo "M gamma/delta" >> $testroot/stdout.expected echo "A symlink" >> $testroot/stdout.expected + echo "? unversioned-file" >> $testroot/stdout.expected cmp -s $testroot/stdout.expected $testroot/stdout ret="$?" if [ "$ret" != "0" ]; then @@ -753,7 +757,7 @@ test_merge_abort() { (cd $testroot/wt && got status > $testroot/stdout) - echo -n "" > $testroot/stdout.expected + echo "? unversioned-file" > $testroot/stdout.expected cmp -s $testroot/stdout.expected $testroot/stdout ret="$?" if [ "$ret" != "0" ]; then blob - 8ca3370f2ac372e3923bb4199f6774b6159e3ec5 blob + b17666eaf0ae899543adfa66236bdfd3eb49e92d --- regress/cmdline/rebase.sh +++ regress/cmdline/rebase.sh @@ -423,6 +423,9 @@ test_rebase_abort() { test_done "$testroot" "$ret" return 1 fi + + # unrelated unversioned file in work tree + touch $testroot/wt/unversioned-file (cd $testroot/wt && got rebase newbranch > $testroot/stdout \ 2> $testroot/stderr) @@ -471,6 +474,7 @@ test_rebase_abort() { (cd $testroot/wt && got status > $testroot/stdout) echo "C alpha" > $testroot/stdout.expected + echo "? unversioned-file" >> $testroot/stdout.expected cmp -s $testroot/stdout.expected $testroot/stdout ret="$?" if [ "$ret" != "0" ]; then