From: Junio C Hamano Date: Mon, 29 Jul 2019 19:38:19 +0000 (-0700) Subject: Merge branch 'sg/rebase-progress' into maint X-Git-Tag: v2.23.0-rc0~1^2~12 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/3e06e74e4cc221d0b602622a5a8d472cfa3efa2d?ds=inline;hp=-c Merge branch 'sg/rebase-progress' into maint Use "Erase in Line" CSI sequence that is already used in the editor support to clear cruft in the progress output. * sg/rebase-progress: progress: use term_clear_line() rebase: fix garbled progress display with '-x' pager: add a helper function to clear the last line in the terminal t3404: make the 'rebase.missingCommitsCheck=ignore' test more focused t3404: modernize here doc style --- 3e06e74e4cc221d0b602622a5a8d472cfa3efa2d diff --combined cache.h index bf20337ef4,5b2cd32bad..3e7cd0b4bc --- a/cache.h +++ b/cache.h @@@ -826,7 -826,7 +826,7 @@@ int match_stat_data(const struct stat_d int match_stat_data_racy(const struct index_state *istate, const struct stat_data *sd, struct stat *st); -void fill_stat_cache_info(struct cache_entry *ce, struct stat *st); +void fill_stat_cache_info(struct index_state *istate, struct cache_entry *ce, struct stat *st); #define REFRESH_REALLY 0x0001 /* ignore_valid */ #define REFRESH_UNMERGED 0x0002 /* allow unmerged */ @@@ -1759,6 -1759,7 +1759,7 @@@ void setup_pager(void) int pager_in_use(void); extern int pager_use_color; int term_columns(void); + void term_clear_line(void); int decimal_width(uintmax_t); int check_pager_config(const char *cmd); void prepare_pager_args(struct child_process *, const char *pager); diff --combined t/t3404-rebase-interactive.sh index 46d971b4ef,0b8267c97c..461dd539ff --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@@ -75,11 -75,10 +75,10 @@@ test_expect_success 'rebase --keep-empt test_line_count = 6 actual ' - cat > expect <expect <<-\EOF && + error: nothing to do + EOF set_fake_editor && test_must_fail env FAKE_LINES="1 exec_true" git rebase -i HEAD^ >actual 2>&1 && test_i18ncmp expect actual @@@ -237,25 -236,23 +236,23 @@@ test_expect_success 'exchange two commi test G = $(git cat-file commit HEAD | sed -ne \$p) ' - cat > expect << EOF - diff --git a/file1 b/file1 - index f70f10e..fd79235 100644 - --- a/file1 - +++ b/file1 - @@ -1 +1 @@ - -A - +G - EOF - - cat > expect2 << EOF - <<<<<<< HEAD - D - ======= - G - >>>>>>> 5d18e54... G - EOF - test_expect_success 'stop on conflicting pick' ' + cat >expect <<-\EOF && + diff --git a/file1 b/file1 + index f70f10e..fd79235 100644 + --- a/file1 + +++ b/file1 + @@ -1 +1 @@ + -A + +G + EOF + cat >expect2 <<-\EOF && + <<<<<<< HEAD + D + ======= + G + >>>>>>> 5d18e54... G + EOF git tag new-branch1 && set_fake_editor && test_must_fail git rebase -i master && @@@ -495,15 -492,14 +492,14 @@@ test_expect_success 'commit message ret git branch -D conflict-squash ' - cat > expect-squash-fixup << EOF - B - - D + test_expect_success C_LOCALE_OUTPUT 'squash and fixup generate correct log messages' ' + cat >expect-squash-fixup <<-\EOF && + B - ONCE - EOF + D - test_expect_success C_LOCALE_OUTPUT 'squash and fixup generate correct log messages' ' + ONCE + EOF git checkout -b squash-fixup E && base=$(git rev-parse HEAD~4) && set_fake_editor && @@@ -799,13 -795,12 +795,12 @@@ test_expect_success 'rebase -i can cop test "a note" = "$(git notes show HEAD)" ' - cat >expect <expect <<-\EOF && + an earlier note + + a note + EOF git reset --hard n3 && git notes add -m"an earlier note" n2 && set_fake_editor && @@@ -1031,7 -1026,7 +1026,7 @@@ test_expect_success 'rebase -i --root r test -z "$(git show -s --format=%p HEAD^)" ' -test_expect_success 'rebase -i --root when root has untracked file confilct' ' +test_expect_success 'rebase -i --root when root has untracked file conflict' ' test_when_finished "reset_rebase" && git checkout -b failing-root-pick A && echo x >file2 && @@@ -1304,52 -1299,37 +1299,37 @@@ test_expect_success 'rebase -i respect actual ' - cat >expect <expect <<-EOF && + Warning: some commits may have been dropped accidentally. + Dropped commits (newer to older): + - $(git rev-list --pretty=oneline --abbrev-commit -1 master) + To avoid this message, use "drop" to explicitly remove a commit. + EOF test_config rebase.missingCommitsCheck warn && rebase_setup_and_clean missing-commit && set_fake_editor && FAKE_LINES="1 2 3 4" \ git rebase -i --root 2>actual.2 && - cr_to_nl actual && + head -n4 actual.2 >actual && test_i18ncmp expect actual && test D = $(git cat-file commit HEAD | sed -ne \$p) ' - cat >expect <expect <<-EOF && + Warning: some commits may have been dropped accidentally. + Dropped commits (newer to older): + - $(git rev-list --pretty=oneline --abbrev-commit -1 master) + - $(git rev-list --pretty=oneline --abbrev-commit -1 master~2) + To avoid this message, use "drop" to explicitly remove a commit. + + Use '\''git config rebase.missingCommitsCheck'\'' to change the level of warnings. + The possible behaviours are: ignore, warn, error. + + You can fix this with '\''git rebase --edit-todo'\'' and then run '\''git rebase --continue'\''. + Or you can abort the rebase with '\''git rebase --abort'\''. + EOF test_config rebase.missingCommitsCheck error && rebase_setup_and_clean missing-commit && set_fake_editor && diff --combined t/t5541-http-push-smart.sh index 92bac43257,2e4802e206..b86ddb60f2 --- a/t/t5541-http-push-smart.sh +++ b/t/t5541-http-push-smart.sh @@@ -177,55 -177,6 +177,55 @@@ test_expect_success 'push (chunked)' test $HEAD = $(git rev-parse --verify HEAD)) ' +test_expect_success 'push --atomic also prevents branch creation, reports collateral' ' + # Setup upstream repo - empty for now + d=$HTTPD_DOCUMENT_ROOT_PATH/atomic-branches.git && + git init --bare "$d" && + test_config -C "$d" http.receivepack true && + up="$HTTPD_URL"/smart/atomic-branches.git && + + # Tell "$up" about two branches for now + test_commit atomic1 && + test_commit atomic2 && + git branch collateral && + git push "$up" master collateral && + + # collateral is a valid push, but should be failed by atomic push + git checkout collateral && + test_commit collateral1 && + + # Make master incompatible with upstream to provoke atomic + git checkout master && + git reset --hard HEAD^ && + + # Add a new branch which should be failed by atomic push. This is a + # regression case. + git branch atomic && + + # --atomic should cause entire push to be rejected + test_must_fail git push --atomic "$up" master atomic collateral 2>output && + + # the new branch should not have been created upstream + test_must_fail git -C "$d" show-ref --verify refs/heads/atomic && + + # upstream should still reflect atomic2, the last thing we pushed + # successfully + git rev-parse atomic2 >expected && + # on master... + git -C "$d" rev-parse refs/heads/master >actual && + test_cmp expected actual && + # ...and collateral. + git -C "$d" rev-parse refs/heads/collateral >actual && + test_cmp expected actual && + + # the failed refs should be indicated to the user + grep "^ ! .*rejected.* master -> master" output && + + # the collateral failure refs should be indicated to the user + grep "^ ! .*rejected.* atomic -> atomic .*atomic push failed" output && + grep "^ ! .*rejected.* collateral -> collateral .*atomic push failed" output +' + test_expect_success 'push --all can push to empty repo' ' d=$HTTPD_DOCUMENT_ROOT_PATH/empty-all.git && git init --bare "$d" && @@@ -262,7 -213,7 +262,7 @@@ test_expect_success TTY 'push shows pro cd "$ROOT_PATH"/test_repo_clone && test_commit noisy && test_terminal git push >output 2>&1 && - test_i18ngrep "^Writing objects" output + test_i18ngrep "Writing objects" output ' test_expect_success TTY 'push --quiet silences status and progress' ' @@@ -277,7 -228,7 +277,7 @@@ test_expect_success TTY 'push --no-prog test_commit no-progress && test_terminal git push --no-progress >output 2>&1 && test_i18ngrep "^To http" output && - test_i18ngrep ! "^Writing objects" output + test_i18ngrep ! "Writing objects" output ' test_expect_success 'push --progress shows progress to non-tty' ' @@@ -285,7 -236,7 +285,7 @@@ test_commit progress && git push --progress >output 2>&1 && test_i18ngrep "^To http" output && - test_i18ngrep "^Writing objects" output + test_i18ngrep "Writing objects" output ' test_expect_success 'http push gives sane defaults to reflog' '