Merge branch 'sg/rebase-progress' into maint
authorJunio C Hamano <gitster@pobox.com>
Mon, 29 Jul 2019 19:38:19 +0000 (12:38 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 29 Jul 2019 19:38:19 +0000 (12:38 -0700)
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

1  2 
cache.h
t/t3404-rebase-interactive.sh
t/t5541-http-push-smart.sh
diff --combined cache.h
index bf20337ef435234acf171f76137e683e66fb22d2,5b2cd32bad89b691646fa1be58fe8a1ed12f327b..3e7cd0b4bc5528d00f3ec01d46db9e8a16d770e3
+++ 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);
index 46d971b4efe647d48cb8c771b07e794065992b0b,0b8267c97cb7e2d53d157ae9114f47eeb90a15b4..461dd539ffd4803c62d54e22e8921fbefa2c0786
@@@ -75,11 -75,10 +75,10 @@@ test_expect_success 'rebase --keep-empt
        test_line_count = 6 actual
  '
  
- cat > expect <<EOF
- error: nothing to do
- EOF
  test_expect_success 'rebase -i with empty HEAD' '
+       cat >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 <<EOF
- an earlier note
- a note
- EOF
  test_expect_success 'rebase -i can copy notes over a fixup' '
+       cat >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 <<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.
- Use 'git config rebase.missingCommitsCheck' to change the level of warnings.
- The possible behaviours are: ignore, warn, error.
- Rebasing (1/4)
- Rebasing (2/4)
- Rebasing (3/4)
- Rebasing (4/4)
- Successfully rebased and updated refs/heads/missing-commit.
- EOF
- cr_to_nl () {
-       tr '\015' '\012'
- }
  test_expect_success 'rebase -i respects rebase.missingCommitsCheck = warn' '
+       cat >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.2 >actual &&
+       head -n4 actual.2 >actual &&
        test_i18ncmp expect actual &&
        test D = $(git cat-file commit HEAD | sed -ne \$p)
  '
  
- cat >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_expect_success 'rebase -i respects rebase.missingCommitsCheck = error' '
+       cat >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 &&
index 92bac4325733e270133b270095f213c9db0a0108,2e4802e2063b87bc6c36d2e728195036e47d8edc..b86ddb60f2ea6ec1c177b8be5d056d064a1d7697
@@@ -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' '
        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' '