commit d52bac284bc87b2e54ff8afd22886a7260f68b26 from: Stefan Sperling via: Thomas Adam date: Fri Oct 08 12:21:31 2021 UTC ignore unversioned files while aborting rebase, histedit, merge or operations ok jrick commit - ac93b2c5ff1f2b9d2c10aaf6b385b22b9da35056 commit + d52bac284bc87b2e54ff8afd22886a7260f68b26 blob - b375b79361d8973852cd690a8972093ca55267d0 blob + 369d7d7369f7a373f6eef08f611035ae2b846fe5 --- 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 - ec9e48a654c56cc96e8bb36e57a8690cc98c76c0 blob + f14adcf25cb320760718529e3959ffa220540131 --- 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 - 6685635eca33a2a5aab0ef38cd5416ca47853bca blob + ad935fbf9a8d899be794504190115e1b649c0f16 --- 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