(command.CommandList
  children: [
    (command.Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (lhs_expr.LhsName name:test_description spids:[12])
          op: Equal
          rhs: {(SQ <'push with --set-upstream'>)}
          spids: [12]
        )
      ]
      spids: [12]
    )
    (C {(.)} {(./test-lib.sh)})
    (C {(.)} {(DQ ($ VSub_Name '$TEST_DIRECTORY')) (/lib-terminal.sh)})
    (command.FuncDef
      name: ensure_fresh_upstream
      body: 
        (command.BraceGroup
          children: [
            (command.AndOr
              ops: [Op_DAmp]
              children: [(C {(rm)} {(-rf)} {(parent)}) (C {(git)} {(init)} {(--bare)} {(parent)})]
            )
          ]
          spids: [33]
        )
      spids: [29 32]
    )
    (C {(test_expect_success)} {(SQ <'setup bare parent'>)} 
      {(SQ <'\n'> <'\tensure_fresh_upstream &&\n'> <'\tgit remote add upstream parent\n'>)}
    )
    (C {(test_expect_success)} {(SQ <'setup local commit'>)} 
      {(SQ <'\n'> <'\techo content >file &&\n'> <'\tgit add file &&\n'> <'\tgit commit -m one\n'>)}
    )
    (command.FuncDef
      name: check_config
      body: 
        (command.BraceGroup
          children: [
            (command.Subshell
              child: 
                (command.CommandList
                  children: [
                    (command.Sentence
                      child: (C {(echo)} {($ VSub_Number '$2')})
                      terminator: <Op_Semi ';'>
                    )
                    (C {(echo)} {($ VSub_Number '$3')})
                  ]
                )
              redirects: [
                (redir.Redir
                  op: <Redir_Great '>'>
                  fd: 16777215
                  arg_word: {(expect.) ($ VSub_Number '$1')}
                )
              ]
              spids: [89 98]
            )
            (command.Subshell
              child: 
                (command.CommandList
                  children: [
                    (C {(git)} {(config)} {(branch.) ($ VSub_Number '$1') (.remote)})
                    (C {(git)} {(config)} {(branch.) ($ VSub_Number '$1') (.merge)})
                  ]
                )
              redirects: [
                (redir.Redir
                  op: <Redir_Great '>'>
                  fd: 16777215
                  arg_word: {(actual.) ($ VSub_Number '$1')}
                )
              ]
              spids: [105 122]
            )
            (C {(test_cmp)} {(expect.) ($ VSub_Number '$1')} {(actual.) ($ VSub_Number '$1')})
          ]
          spids: [86]
        )
      spids: [82 85]
    )
    (C {(test_expect_success)} {(SQ <'push -u master:master'>)} 
      {
        (SQ <'\n'> <'\tgit push -u upstream master:master &&\n'> 
          <'\tcheck_config master upstream refs/heads/master\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'push -u master:other'>)} 
      {
        (SQ <'\n'> <'\tgit push -u upstream master:other &&\n'> 
          <'\tcheck_config master upstream refs/heads/other\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'push -u --dry-run master:otherX'>)} 
      {
        (SQ <'\n'> <'\tgit push -u --dry-run upstream master:otherX &&\n'> 
          <'\tcheck_config master upstream refs/heads/other\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'push -u master2:master2'>)} 
      {
        (SQ <'\n'> <'\tgit branch master2 &&\n'> <'\tgit push -u upstream master2:master2 &&\n'> 
          <'\tcheck_config master2 upstream refs/heads/master2\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'push -u master2:other2'>)} 
      {
        (SQ <'\n'> <'\tgit push -u upstream master2:other2 &&\n'> 
          <'\tcheck_config master2 upstream refs/heads/other2\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'push -u :master2'>)} 
      {
        (SQ <'\n'> <'\tgit push -u upstream :master2 &&\n'> 
          <'\tcheck_config master2 upstream refs/heads/other2\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'push -u --all'>)} 
      {
        (SQ <'\n'> <'\tgit branch all1 &&\n'> <'\tgit branch all2 &&\n'> <'\tgit push -u --all &&\n'> 
          <'\tcheck_config all1 upstream refs/heads/all1 &&\n'> <'\tcheck_config all2 upstream refs/heads/all2\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'push -u HEAD'>)} 
      {
        (SQ <'\n'> <'\tgit checkout -b headbranch &&\n'> <'\tgit push -u upstream HEAD &&\n'> 
          <'\tcheck_config headbranch upstream refs/heads/headbranch\n'>
        )
      }
    )
    (C {(test_expect_success)} {(TTY)} {(SQ <'progress messages go to tty'>)} 
      {
        (SQ <'\n'> <'\tensure_fresh_upstream &&\n'> <'\n'> 
          <'\ttest_terminal git push -u upstream master >out 2>err &&\n'> <'\ttest_i18ngrep "Writing objects" err\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'progress messages do not go to non-tty'>)} 
      {
        (SQ <'\n'> <'\tensure_fresh_upstream &&\n'> <'\n'> 
          <'\t# skip progress messages, since stderr is non-tty\n'> <'\tgit push -u upstream master >out 2>err &&\n'> <'\ttest_i18ngrep ! "Writing objects" err\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'progress messages go to non-tty (forced)'>)} 
      {
        (SQ <'\n'> <'\tensure_fresh_upstream &&\n'> <'\n'> 
          <'\t# force progress messages to stderr, even though it is non-tty\n'> <'\tgit push -u --progress upstream master >out 2>err &&\n'> 
          <'\ttest_i18ngrep "Writing objects" err\n'>
        )
      }
    )
    (C {(test_expect_success)} {(TTY)} {(SQ <'push -q suppresses progress'>)} 
      {
        (SQ <'\n'> <'\tensure_fresh_upstream &&\n'> <'\n'> 
          <'\ttest_terminal git push -u -q upstream master >out 2>err &&\n'> <'\ttest_i18ngrep ! "Writing objects" err\n'>
        )
      }
    )
    (C {(test_expect_success)} {(TTY)} {(SQ <'push --no-progress suppresses progress'>)} 
      {
        (SQ <'\n'> <'\tensure_fresh_upstream &&\n'> <'\n'> 
          <'\ttest_terminal git push -u --no-progress upstream master >out 2>err &&\n'> <'\ttest_i18ngrep ! "Unpacking objects" err &&\n'> <'\ttest_i18ngrep ! "Writing objects" err\n'>
        )
      }
    )
    (C {(test_expect_success)} {(TTY)} {(SQ <'quiet push'>)} 
      {
        (SQ <'\n'> <'\tensure_fresh_upstream &&\n'> <'\n'> 
          <'\ttest_terminal git push --quiet --no-progress upstream master 2>&1 | tee output &&\n'> <'\ttest_cmp /dev/null output\n'>
        )
      }
    )
    (C {(test_done)})
  ]
)