<commit_before>/*
 * diff-cmd.c -- Display context diff of a file
 *
 * ====================================================================
 * Copyright (c) 2000-2004 CollabNet.  All rights reserved.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution.  The terms
 * are also available at http://subversion.tigris.org/license-1.html.
 * If newer versions of this license are posted there, you may use a
 * newer version instead, at your option.
 *
 * This software consists of voluntary contributions made by many
 * individuals.  For exact contribution history, see the revision
 * history and logs, available at http://subversion.tigris.org/.
 * ====================================================================
 */

/* ==================================================================== */




/*** Includes. ***/

#include "svn_pools.h"
#include "svn_client.h"
#include "svn_string.h"
#include "svn_path.h"
#include "svn_error.h"
#include "svn_types.h"
#include "svn_cmdline.h"
#include "cl.h"

#include "svn_private_config.h"



/*** Code. ***/

/* Convert KIND into a single character for display to the user. */
static char
text_mod_char(svn_client_diff_summarize_kind_t kind)
{
  switch (kind)
    {
      case svn_client_diff_summarize_kind_modified:
        return 'M';

      case svn_client_diff_summarize_kind_added:
        return 'A';

      case svn_client_diff_summarize_kind_deleted:
        return 'D';

      default:
        return ' ';
    }
}

/* Print summary information about a given change, implements the
 * svn_client_diff_summarize_func_t interface. */
static svn_error_t *
summarize_func(const svn_client_diff_summarize_t *summary,
               void *baton,
               apr_pool_t *pool)
{
  const char *path = baton;

  /* Tack on the target path, so we can differentiate between different parts
   * of the output when we're given multiple targets. */
  path = svn_path_join(path, summary->path, pool);

  /* Convert non-urls to local style, so that things like "" show up as "." */
  if (! svn_path_is_url(path))
    path = svn_path_local_style(path, pool);

  /* Note: This output format tries to look like the output of 'svn status',
   *       thus the blank spaces where information that is not relevant to
   *       a diff summary would go. */

  SVN_ERR(svn_cmdline_printf(pool,
                             "%c%c     %s\n",
                             text_mod_char(summary->summarize_kind),
                             summary->prop_changed ? 'M' : ' ',
                             path));

  SVN_ERR(svn_cmdline_fflush(stdout));

  return SVN_NO_ERROR;
}

/* An svn_opt_subcommand_t to handle the 'diff' command.
   This implements the `svn_opt_subcommand_t' interface. */
svn_error_t *
svn_cl__diff(apr_getopt_t *os,
             void *baton,<commit_msg>Call out cause of issue #2765, "'diff --summarize file' displays erroneous output".<commit_after>/*
 * diff-cmd.c -- Display context diff of a file
 *
 * ====================================================================
 * Copyright (c) 2000-2004 CollabNet.  All rights reserved.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution.  The terms
 * are also available at http://subversion.tigris.org/license-1.html.
 * If newer versions of this license are posted there, you may use a
 * newer version instead, at your option.
 *
 * This software consists of voluntary contributions made by many
 * individuals.  For exact contribution history, see the revision
 * history and logs, available at http://subversion.tigris.org/.
 * ====================================================================
 */

/* ==================================================================== */




/*** Includes. ***/

#include "svn_pools.h"
#include "svn_client.h"
#include "svn_string.h"
#include "svn_path.h"
#include "svn_error.h"
#include "svn_types.h"
#include "svn_cmdline.h"
#include "cl.h"

#include "svn_private_config.h"



/*** Code. ***/

/* Convert KIND into a single character for display to the user. */
static char
text_mod_char(svn_client_diff_summarize_kind_t kind)
{
  switch (kind)
    {
      case svn_client_diff_summarize_kind_modified:
        return 'M';

      case svn_client_diff_summarize_kind_added:
        return 'A';

      case svn_client_diff_summarize_kind_deleted:
        return 'D';

      default:
        return ' ';
    }
}

/* Print summary information about a given change, implements the
 * svn_client_diff_summarize_func_t interface. */
static svn_error_t *
summarize_func(const svn_client_diff_summarize_t *summary,
               void *baton,
               apr_pool_t *pool)
{
  const char *path = baton;

  /* Tack on the target path, so we can differentiate between different parts
   * of the output when we're given multiple targets. */
  /* ### FIXME (issue #2765): Only append summary->path to the
     ### original path if the original is of kind svn_node_dir. */
  path = svn_path_join(path, summary->path, pool);

  /* Convert non-urls to local style, so that things like "" show up as "." */
  if (! svn_path_is_url(path))
    path = svn_path_local_style(path, pool);

  /* Note: This output format tries to look like the output of 'svn status',
   *       thus the blank spaces where information that is not relevant to
   *       a diff summary would go. */

  SVN_ERR(svn_cmdline_printf(pool,
                             "%c%c     %s\n",
                             text_mod_char(summary->summarize_kind),
                             summary->prop_changed ? 'M' : ' ',
                             path));

  SVN_ERR(svn_cmdline_fflush(stdout));

  return SVN_NO_ERROR;
}

/* An svn_opt_subcommand_t to handle the 'diff' command.
   This implements the `svn_opt_subcommand_t' interface. */
svn_error_t *
svn_cl__diff(apr_getopt_t *os,
             void *baton,
{'fraction_non_alphanumeric': 0.1592505854800937, 'fraction_numerical': 0.004349280695884911, 'mean_word_length': 3.1262939958592133, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4860984', 'n_tokens_mistral': 1852, 'n_tokens_neox': 1777, 'n_words': 539}