Merge branch 'js/configurable-tab'
authorJunio C Hamano <gitster@pobox.com>
Mon, 13 Dec 2010 05:49:52 +0000 (21:49 -0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 13 Dec 2010 05:49:52 +0000 (21:49 -0800)
* js/configurable-tab:
Make the tab width used for whitespace checks configurable
apply --whitespace=fix: fix tab-in-indent

1  2 
Documentation/config.txt
cache.h
t/t4019-diff-wserror.sh
diff --combined Documentation/config.txt
index 0f8579331ed6b9324823f01c3a3cdf32c1e9e674,7aff5ce2c8fd65c3b845383d70f17f39525a3d28..3f01bd929f4cffe71eb8de1366ef6065cbf711fc
@@@ -374,15 -374,6 +374,15 @@@ core.warnAmbiguousRefs:
        If true, git will warn you if the ref name you passed it is ambiguous
        and might match multiple refs in the .git/refs/ tree. True by default.
  
 +core.abbrevguard::
 +      Even though git makes sure that it uses enough hexdigits to show
 +      an abbreviated object name unambiguously, as more objects are
 +      added to the repository over time, a short name that used to be
 +      unique will stop being unique.  Git uses this many extra hexdigits
 +      that are more than necessary to make the object name currently
 +      unique, in the hope that its output will stay unique a bit longer.
 +      Defaults to 0.
 +
  core.compression::
        An integer -1..9, indicating a default compression level.
        -1 is the zlib default. 0 means no compression,
@@@ -522,6 -513,9 +522,9 @@@ core.whitespace:
    part of the line terminator, i.e. with it, `trailing-space`
    does not trigger if the character before such a carriage-return
    is not a whitespace (not enabled by default).
+ * `tabwidth=<n>` tells how many character positions a tab occupies; this
+   is relevant for `indent-with-non-tab` and when git fixes `tab-in-indent`
+   errors. The default tab width is 8. Allowed values are 1 to 63.
  
  core.fsyncobjectfiles::
        This boolean will enable 'fsync()' when writing object files.
@@@ -563,13 -557,9 +566,13 @@@ core.sparseCheckout:
        linkgit:git-read-tree[1] for more information.
  
  add.ignore-errors::
 +add.ignoreErrors::
        Tells 'git add' to continue adding files when some files cannot be
        added due to indexing errors. Equivalent to the '--ignore-errors'
 -      option of linkgit:git-add[1].
 +      option of linkgit:git-add[1].  Older versions of git accept only
 +      `add.ignore-errors`, which does not follow the usual naming
 +      convention for configuration variables.  Newer versions of git
 +      honor `add.ignoreErrors` as well.
  
  alias.*::
        Command aliases for the linkgit:git[1] command wrapper - e.g.
@@@ -1545,13 -1535,11 +1548,13 @@@ pack.packSizeLimit:
        supported.
  
  pager.<cmd>::
 -      Allows turning on or off pagination of the output of a
 -      particular git subcommand when writing to a tty.  If
 -      `\--paginate` or `\--no-pager` is specified on the command line,
 -      it takes precedence over this option.  To disable pagination for
 -      all commands, set `core.pager` or `GIT_PAGER` to `cat`.
 +      If the value is boolean, turns on or off pagination of the
 +      output of a particular git subcommand when writing to a tty.
 +      Otherwise, turns on pagination for the subcommand using the
 +      pager specified by the value of `pager.<cmd>`.  If `\--paginate`
 +      or `\--no-pager` is specified on the command line, it takes
 +      precedence over this option.  To disable pagination for all
 +      commands, set `core.pager` or `GIT_PAGER` to `cat`.
  
  pretty.<name>::
        Alias for a --pretty= format string, as specified in
diff --combined cache.h
index e83bc2d3bb20287b42be06edd56dfd525ddfbaa9,8e8c9d4b35310c43cbb9677f23baf3cb05e259b5..909b1f6e9a7c45614522866aa4f20fb41e4628ec
+++ b/cache.h
@@@ -545,7 -545,6 +545,7 @@@ extern int assume_unchanged
  extern int prefer_symlink_refs;
  extern int log_all_ref_updates;
  extern int warn_ambiguous_refs;
 +extern int unique_abbrev_extra_length;
  extern int shared_repository;
  extern const char *apply_default_whitespace;
  extern const char *apply_default_ignorewhitespace;
@@@ -860,7 -859,7 +860,7 @@@ struct cache_def 
  
  extern int has_symlink_leading_path(const char *name, int len);
  extern int threaded_has_symlink_leading_path(struct cache_def *, const char *, int);
 -extern int has_symlink_or_noent_leading_path(const char *name, int len);
 +extern int check_leading_path(const char *name, int len);
  extern int has_dirs_only_path(const char *name, int len, int prefix_len);
  extern void schedule_dir_for_removal(const char *name, int len);
  extern void remove_scheduled_dirs(void);
@@@ -1004,9 -1003,6 +1004,9 @@@ extern int git_env_bool(const char *, i
  extern int git_config_system(void);
  extern int git_config_global(void);
  extern int config_error_nonbool(const char *);
 +extern const char *get_log_output_encoding(void);
 +extern const char *get_commit_output_encoding(void);
 +
  extern const char *config_exclusive_filename;
  
  #define MAX_GITNAME (1000)
@@@ -1091,15 -1087,17 +1091,17 @@@ void shift_tree_by(const unsigned char 
  /*
   * whitespace rules.
   * used by both diff and apply
+  * last two digits are tab width
   */
- #define WS_BLANK_AT_EOL         01
- #define WS_SPACE_BEFORE_TAB   02
- #define WS_INDENT_WITH_NON_TAB        04
- #define WS_CR_AT_EOL           010
- #define WS_BLANK_AT_EOF        020
- #define WS_TAB_IN_INDENT       040
+ #define WS_BLANK_AT_EOL         0100
+ #define WS_SPACE_BEFORE_TAB     0200
+ #define WS_INDENT_WITH_NON_TAB  0400
+ #define WS_CR_AT_EOL           01000
+ #define WS_BLANK_AT_EOF        02000
+ #define WS_TAB_IN_INDENT       04000
  #define WS_TRAILING_SPACE      (WS_BLANK_AT_EOL|WS_BLANK_AT_EOF)
- #define WS_DEFAULT_RULE (WS_TRAILING_SPACE|WS_SPACE_BEFORE_TAB)
+ #define WS_DEFAULT_RULE (WS_TRAILING_SPACE|WS_SPACE_BEFORE_TAB|8)
+ #define WS_TAB_WIDTH_MASK        077
  extern unsigned whitespace_rule_cfg;
  extern unsigned whitespace_rule(const char *);
  extern unsigned parse_whitespace_rule(const char *);
@@@ -1108,6 -1106,7 +1110,7 @@@ extern void ws_check_emit(const char *l
  extern char *whitespace_error_string(unsigned ws);
  extern void ws_fix_copy(struct strbuf *, const char *, int, unsigned, int *);
  extern int ws_blank_line(const char *line, int len, unsigned ws_rule);
+ #define ws_tab_width(rule)     ((rule) & WS_TAB_WIDTH_MASK)
  
  /* ls-files */
  int report_path_error(const char *ps_matched, const char **pathspec, int prefix_offset);
diff --combined t/t4019-diff-wserror.sh
index 3fa836f9d3c19f351ce5451049eb191776cbd4a5,6f992c88eb7cb6986834512bc97f9d88d628707d..a5019759bc7593cf8affd8625f61bbd7ab1b9655
@@@ -51,8 -51,65 +51,65 @@@ test_expect_success default 
  
  '
  
+ test_expect_success 'default (attribute)' '
+       test_might_fail git config --unset core.whitespace &&
+       echo "F whitespace" >.gitattributes &&
+       prepare_output &&
+       grep Eight error >/dev/null &&
+       grep HT error >/dev/null &&
+       grep With error >/dev/null &&
+       grep Return error >/dev/null &&
+       grep No normal >/dev/null
+ '
+ test_expect_success 'default, tabwidth=10 (attribute)' '
+       git config core.whitespace "tabwidth=10" &&
+       echo "F whitespace" >.gitattributes &&
+       prepare_output &&
+       grep Eight normal >/dev/null &&
+       grep HT error >/dev/null &&
+       grep With error >/dev/null &&
+       grep Return error >/dev/null &&
+       grep No normal >/dev/null
+ '
+ test_expect_success 'no check (attribute)' '
+       test_might_fail git config --unset core.whitespace &&
+       echo "F -whitespace" >.gitattributes &&
+       prepare_output &&
+       grep Eight normal >/dev/null &&
+       grep HT normal >/dev/null &&
+       grep With normal >/dev/null &&
+       grep Return normal >/dev/null &&
+       grep No normal >/dev/null
+ '
+ test_expect_success 'no check, tabwidth=10 (attribute), must be irrelevant' '
+       git config core.whitespace "tabwidth=10" &&
+       echo "F -whitespace" >.gitattributes &&
+       prepare_output &&
+       grep Eight normal >/dev/null &&
+       grep HT normal >/dev/null &&
+       grep With normal >/dev/null &&
+       grep Return normal >/dev/null &&
+       grep No normal >/dev/null
+ '
  test_expect_success 'without -trail' '
  
+       rm -f .gitattributes &&
        git config core.whitespace -trail &&
        prepare_output &&
  
@@@ -134,6 -191,34 +191,34 @@@ test_expect_success 'with indent-non-ta
  
  '
  
+ test_expect_success 'with indent-non-tab only, tabwidth=10' '
+       rm -f .gitattributes &&
+       git config core.whitespace indent,tabwidth=10,-trailing,-space &&
+       prepare_output &&
+       grep Eight normal >/dev/null &&
+       grep HT normal >/dev/null &&
+       grep With normal >/dev/null &&
+       grep Return normal >/dev/null &&
+       grep No normal >/dev/null
+ '
+ test_expect_success 'with indent-non-tab only, tabwidth=10 (attribute)' '
+       test_might_fail git config --unset core.whitespace &&
+       echo "F whitespace=indent,-trailing,-space,tabwidth=10" >.gitattributes &&
+       prepare_output &&
+       grep Eight normal >/dev/null &&
+       grep HT normal >/dev/null &&
+       grep With normal >/dev/null &&
+       grep Return normal >/dev/null &&
+       grep No normal >/dev/null
+ '
  test_expect_success 'with cr-at-eol' '
  
        rm -f .gitattributes &&
@@@ -179,15 -264,6 +264,15 @@@ test_expect_success 'trailing empty lin
  
  '
  
 +test_expect_success 'checkdiff shows correct line number for trailing blank lines' '
 +
 +      printf "a\nb\n" > G &&
 +      git add G &&
 +      printf "x\nx\nx\na\nb\nc\n\n" > G &&
 +      [ "$(git diff --check -- G)" = "G:7: new blank line at EOF." ]
 +
 +'
 +
  test_expect_success 'do not color trailing cr in context' '
        test_might_fail git config --unset core.whitespace &&
        rm -f .gitattributes &&