(CommandList
  children: [
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:test_description)
          op: Equal
          rhs: {(SQ <"push with --set-upstream">)}
          spids: [4]
        )
      ]
      spids: [4]
    )
    (C {(.)} {(./test-lib.sh)})
    (C {(.)} {(DQ ($ VSub_Name "$TEST_DIRECTORY")) (/lib-terminal.sh)})
    (FuncDef
      name: ensure_fresh_upstream
      body: 
        (BraceGroup
          children: [
            (AndOr
              children: [(C {(rm)} {(-rf)} {(parent)}) (C {(git)} {(init)} {(--bare)} {(parent)})]
              op_id: Op_DAmp
            )
          ]
          spids: [25]
        )
      spids: [21 24]
    )
    (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">)}
    )
    (FuncDef
      name: check_config
      body: 
        (BraceGroup
          children: [
            (Subshell
              child: 
                (CommandList
                  children: [
                    (Sentence
                      child: (C {(echo)} {($ VSub_Number "$2")})
                      terminator: <Op_Semi ";">
                    )
                    (C {(echo)} {($ VSub_Number "$3")})
                  ]
                )
              redirects: [
                (Redir
                  op_id: Redir_Great
                  fd: -1
                  arg_word: {(expect.) ($ VSub_Number "$1")}
                  spids: [92]
                )
              ]
              spids: [81 90]
            )
            (Subshell
              child: 
                (CommandList
                  children: [
                    (C {(git)} {(config)} {(branch.) ($ VSub_Number "$1") (.remote)})
                    (C {(git)} {(config)} {(branch.) ($ VSub_Number "$1") (.merge)})
                  ]
                )
              redirects: [
                (Redir
                  op_id: Redir_Great
                  fd: -1
                  arg_word: {(actual.) ($ VSub_Number "$1")}
                  spids: [116]
                )
              ]
              spids: [97 114]
            )
            (C {(test_cmp)} {(expect.) ($ VSub_Number "$1")} {(actual.) ($ VSub_Number "$1")})
          ]
          spids: [78]
        )
      spids: [74 77]
    )
    (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)})
  ]
)