author | Junio C Hamano <gitster@pobox.com> | |
Mon, 29 Aug 2011 04:19:16 +0000 (21:19 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 29 Aug 2011 04:19:16 +0000 (21:19 -0700) |
* jk/color-and-pager:
want_color: automatically fallback to color.ui
diff: don't load color config in plumbing
config: refactor get_colorbool function
color: delay auto-color decision until point of use
git_config_colorbool: refactor stdout_is_tty handling
diff: refactor COLOR_DIFF from a flag into an int
setup_pager: set GIT_PAGER_IN_USE
t7006: use test_config helpers
test-lib: add helper functions for config
t7006: modernize calls to unset
Conflicts:
builtin/commit.c
parse-options.c
want_color: automatically fallback to color.ui
diff: don't load color config in plumbing
config: refactor get_colorbool function
color: delay auto-color decision until point of use
git_config_colorbool: refactor stdout_is_tty handling
diff: refactor COLOR_DIFF from a flag into an int
setup_pager: set GIT_PAGER_IN_USE
t7006: use test_config helpers
test-lib: add helper functions for config
t7006: modernize calls to unset
Conflicts:
builtin/commit.c
parse-options.c
1 | 2 | |||
---|---|---|---|---|
builtin/branch.c | patch | | diff1 | | diff2 | | blob | history |
builtin/commit.c | patch | | diff1 | | diff2 | | blob | history |
builtin/grep.c | patch | | diff1 | | diff2 | | blob | history |
builtin/merge.c | patch | | diff1 | | diff2 | | blob | history |
combine-diff.c | patch | | diff1 | | diff2 | | blob | history |
diff.c | patch | | diff1 | | diff2 | | blob | history |
diff.h | patch | | diff1 | | diff2 | | blob | history |
grep.c | patch | | diff1 | | diff2 | | blob | history |
parse-options-cb.c | patch | | diff1 | | | | blob | history |
t/test-lib.sh | patch | | diff1 | | diff2 | | blob | history |
wt-status.c | patch | | diff1 | | diff2 | | blob | history |
diff --cc builtin/branch.c
Simple merge
diff --cc builtin/commit.c
index 05029d40d1279b9a92ba22f6826f644ce82f5b7a,9763146b6f224b32e56d3d67b0750b56a989b6cf..cbc9613ec661bc2cef8274cd66efb06b9cab55b6
--- 1/builtin/commit.c
--- 2/builtin/commit.c
+++ b/builtin/commit.c
git_config(git_commit_config, &s);
determine_whence(&s);
- if (s.use_color == -1)
- s.use_color = git_use_color_default;
+ if (get_sha1("HEAD", sha1))
+ current_head = NULL;
+ else {
+ current_head = lookup_commit(sha1);
+ if (!current_head || parse_commit(current_head))
+ die(_("could not parse HEAD commit"));
+ }
argc = parse_and_validate_options(argc, argv, builtin_commit_usage,
- prefix, &s);
+ prefix, current_head, &s);
- if (dry_run) {
- if (diff_use_color_default == -1)
- diff_use_color_default = git_use_color_default;
+ if (dry_run)
- return dry_run_commit(argc, argv, prefix, &s);
- index_file = prepare_index(argc, argv, prefix, 0);
+ return dry_run_commit(argc, argv, prefix, current_head, &s);
- }
+ index_file = prepare_index(argc, argv, prefix, current_head, 0);
/* Set up everything for writing the commit object. This includes
running hooks, writing the trees, and interacting with the user. */
diff --cc builtin/grep.c
Simple merge
diff --cc builtin/merge.c
Simple merge
diff --cc combine-diff.c
Simple merge
diff --cc diff.c
Simple merge
diff --cc diff.h
Simple merge
diff --cc grep.c
Simple merge
diff --cc parse-options-cb.c
index c248f667c1cc48075fb278a3309f74c7122502eb,0000000000000000000000000000000000000000..6db0921fc1fde3b5fbf829577bdd019ae95462e0
mode 100644,000000..100644
mode 100644,000000..100644
--- 1/parse-options-cb.c
--- /dev/null
+++ b/parse-options-cb.c
- value = git_config_colorbool(NULL, arg, -1);
+#include "git-compat-util.h"
+#include "parse-options.h"
+#include "cache.h"
+#include "commit.h"
+#include "color.h"
+#include "string-list.h"
+
+/*----- some often used options -----*/
+
+int parse_opt_abbrev_cb(const struct option *opt, const char *arg, int unset)
+{
+ int v;
+
+ if (!arg) {
+ v = unset ? 0 : DEFAULT_ABBREV;
+ } else {
+ v = strtol(arg, (char **)&arg, 10);
+ if (*arg)
+ return opterror(opt, "expects a numerical value", 0);
+ if (v && v < MINIMUM_ABBREV)
+ v = MINIMUM_ABBREV;
+ else if (v > 40)
+ v = 40;
+ }
+ *(int *)(opt->value) = v;
+ return 0;
+}
+
+int parse_opt_approxidate_cb(const struct option *opt, const char *arg,
+ int unset)
+{
+ *(unsigned long *)(opt->value) = approxidate(arg);
+ return 0;
+}
+
+int parse_opt_color_flag_cb(const struct option *opt, const char *arg,
+ int unset)
+{
+ int value;
+
+ if (!arg)
+ arg = unset ? "never" : (const char *)opt->defval;
++ value = git_config_colorbool(NULL, arg);
+ if (value < 0)
+ return opterror(opt,
+ "expects \"always\", \"auto\", or \"never\"", 0);
+ *(int *)opt->value = value;
+ return 0;
+}
+
+int parse_opt_verbosity_cb(const struct option *opt, const char *arg,
+ int unset)
+{
+ int *target = opt->value;
+
+ if (unset)
+ /* --no-quiet, --no-verbose */
+ *target = 0;
+ else if (opt->short_name == 'v') {
+ if (*target >= 0)
+ (*target)++;
+ else
+ *target = 1;
+ } else {
+ if (*target <= 0)
+ (*target)--;
+ else
+ *target = -1;
+ }
+ return 0;
+}
+
+int parse_opt_with_commit(const struct option *opt, const char *arg, int unset)
+{
+ unsigned char sha1[20];
+ struct commit *commit;
+
+ if (!arg)
+ return -1;
+ if (get_sha1(arg, sha1))
+ return error("malformed object name %s", arg);
+ commit = lookup_commit_reference(sha1);
+ if (!commit)
+ return error("no such commit %s", arg);
+ commit_list_insert(commit, opt->value);
+ return 0;
+}
+
+int parse_opt_tertiary(const struct option *opt, const char *arg, int unset)
+{
+ int *target = opt->value;
+ *target = unset ? 2 : 1;
+ return 0;
+}
+
+int parse_options_concat(struct option *dst, size_t dst_size, struct option *src)
+{
+ int i, j;
+
+ for (i = 0; i < dst_size; i++)
+ if (dst[i].type == OPTION_END)
+ break;
+ for (j = 0; i < dst_size; i++, j++) {
+ dst[i] = src[j];
+ if (src[j].type == OPTION_END)
+ return 0;
+ }
+ return -1;
+}
+
+int parse_opt_string_list(const struct option *opt, const char *arg, int unset)
+{
+ struct string_list *v = opt->value;
+
+ if (unset) {
+ string_list_clear(v, 0);
+ return 0;
+ }
+
+ if (!arg)
+ return -1;
+
+ string_list_append(v, xstrdup(arg));
+ return 0;
+}
diff --cc t/test-lib.sh
Simple merge
diff --cc wt-status.c
Simple merge