FreeBSD/contrib/subversion/subversion/svnlook/svnlook.c
/* Print some diff-y stuff in a TBD way. :-) */
Print some diff-y stuff in a TBD way.
Print some diff - y stuff in a TBD way .
static svn_error_t *
do_diff(svnlook_ctxt_t *c, apr_pool_t *pool)
{
  svn_fs_root_t *root, *base_root;
  svn_revnum_t base_rev_id;
  svn_repos_node_t *tree;
  SVN_ERR(get_root(&root, c, pool));
  SVN_ERR(get_base_rev(&base_rev_id, c, pool));
  if (base_rev_id == SVN_INVALID_REVNUM)
    return SVN_NO_ERROR;
  SVN_ERR(generate_delta_tree(&tree, c->repos, root, base_rev_id, pool));
  if (tree)
    {
      svn_stream_t *out_stream;
      const char *encoding = svn_cmdline_output_encoding(pool);
      SVN_ERR(svn_fs_revision_root(&base_root, c->fs, base_rev_id, pool));
      SVN_ERR(svn_cmdline_fflush(stdout));
      SVN_ERR(svn_stream_for_stdout(&out_stream, pool));
      SVN_ERR(print_diff_tree(out_stream, encoding, root, base_root, tree,
                              "", "", c, pool));
    }
  return SVN_NO_ERROR;
}
static svn_error_t * do_diff ( svnlook_ctxt_t * c , apr_pool_t * pool ) { svn_fs_root_t * root , * base_root ; svn_revnum_t base_rev_id ; svn_repos_node_t * tree ; SVN_ERR ( get_root ( & root , c , pool ) ) ; SVN_ERR ( get_base_rev ( & base_rev_id , c , pool ) ) ; if ( base_rev_id == SVN_INVALID_REVNUM ) return SVN_NO_ERROR ; SVN_ERR ( generate_delta_tree ( & tree , c -> repos , root , base_rev_id , pool ) ) ; if ( tree ) { svn_stream_t * out_stream ; const char * encoding = svn_cmdline_output_encoding ( pool ) ; SVN_ERR ( svn_fs_revision_root ( & base_root , c -> fs , base_rev_id , pool ) ) ; SVN_ERR ( svn_cmdline_fflush ( stdout ) ) ; SVN_ERR ( svn_stream_for_stdout ( & out_stream , pool ) ) ; SVN_ERR ( print_diff_tree ( out_stream , encoding , root , base_root , tree , " " , " " , c , pool ) ) ; } return SVN_NO_ERROR ; }
Print some diff-y stuff in a TBD way.
Print some diff - y stuff in a TBD way .
/* This fflush() might seem odd, but it was added to deal
         with this bug report:

         http://subversion.tigris.org/servlets/ReadMsg?\
         list=dev&msgNo=140782

         From: "Steve Hay" <SteveHay{_AT_}planit.com>
         To: <dev@subversion.tigris.org>
         Subject: svnlook diff output in wrong order when redirected
         Date: Fri, 4 Jul 2008 16:34:15 +0100
         Message-ID: <1B32FF956ABF414C9BCE5E487A1497E702014F62@\
                     ukmail02.planit.group>

         Adding the fflush() fixed the bug (not everyone could
         reproduce it, but those who could confirmed the fix).
         Later in the thread, Daniel Shahaf speculated as to
         why the fix works:

         "Because svn_cmdline_printf() uses the standard
         'FILE *stdout' to write to stdout, while
         svn_stream_for_stdout() uses (through
         apr_file_open_stdout()) Windows API's to get a
         handle for stdout?" */