Merge branch 'jc/apply-3way'
authorJunio C Hamano <gitster@pobox.com>
Mon, 16 Jul 2012 04:38:51 +0000 (21:38 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 16 Jul 2012 04:38:51 +0000 (21:38 -0700)
"git apply" learned to wiggle the base version and perform three-way
merge when a patch does not exactly apply to the version you have.

* jc/apply-3way:
  apply: tests for the --3way option
  apply: document --3way option
  apply: allow rerere() to work on --3way results
  apply: register conflicted stages to the index
  apply: --3way with add/add conflict
  apply: move verify_index_match() higher
  apply: plug the three-way merge logic in
  apply: fall back on three-way merge
  apply: accept -3/--3way command line option
  apply: move "already exists" logic to check_to_create()
  apply: move check_to_create_blob() closer to its sole caller
  apply: further split load_preimage()
  apply: refactor "previous patch" logic
  apply: split load_preimage() helper function out
  apply: factor out checkout_target() helper function
  apply: refactor read_file_or_gitlink()
  apply: clear_image() clears things a bit more
  apply: a bit more comments on PATH_TO_BE_DELETED
  apply: fix an incomplete comment in check_patch()

1  2 
builtin/apply.c

diff --cc builtin/apply.c
index b4428ea34f53d94e3733796777866e73531f06b5,cd68862aa888c37453f386c2f1231335c6c4bf96..ace04c453be447b62b4907c45247f82ef4344033
@@@ -3983,50 -4280,52 +4295,52 @@@ int cmd_apply(int argc, const char **ar
                OPT_NOOP_NOARG(0, "allow-binary-replacement"),
                OPT_NOOP_NOARG(0, "binary"),
                OPT_BOOLEAN(0, "numstat", &numstat,
 -                      "shows number of added and deleted lines in decimal notation"),
 +                      N_("shows number of added and deleted lines in decimal notation")),
                OPT_BOOLEAN(0, "summary", &summary,
 -                      "instead of applying the patch, output a summary for the input"),
 +                      N_("instead of applying the patch, output a summary for the input")),
                OPT_BOOLEAN(0, "check", &check,
 -                      "instead of applying the patch, see if the patch is applicable"),
 +                      N_("instead of applying the patch, see if the patch is applicable")),
                OPT_BOOLEAN(0, "index", &check_index,
 -                      "make sure the patch is applicable to the current index"),
 +                      N_("make sure the patch is applicable to the current index")),
                OPT_BOOLEAN(0, "cached", &cached,
 -                      "apply a patch without touching the working tree"),
 +                      N_("apply a patch without touching the working tree")),
                OPT_BOOLEAN(0, "apply", &force_apply,
 -                      "also apply the patch (use with --stat/--summary/--check)"),
 +                      N_("also apply the patch (use with --stat/--summary/--check)")),
+               OPT_BOOL('3', "3way", &threeway,
 -                       "attempt three-way merge if a patch does not apply"),
++                       N_( "attempt three-way merge if a patch does not apply")),
                OPT_FILENAME(0, "build-fake-ancestor", &fake_ancestor,
 -                      "build a temporary index based on embedded index information"),
 +                      N_("build a temporary index based on embedded index information")),
                { OPTION_CALLBACK, 'z', NULL, NULL, NULL,
 -                      "paths are separated with NUL character",
 +                      N_("paths are separated with NUL character"),
                        PARSE_OPT_NOARG, option_parse_z },
                OPT_INTEGER('C', NULL, &p_context,
 -                              "ensure at least <n> lines of context match"),
 -              { OPTION_CALLBACK, 0, "whitespace", &whitespace_option, "action",
 -                      "detect new or modified lines that have whitespace errors",
 +                              N_("ensure at least <n> lines of context match")),
 +              { OPTION_CALLBACK, 0, "whitespace", &whitespace_option, N_("action"),
 +                      N_("detect new or modified lines that have whitespace errors"),
                        0, option_parse_whitespace },
                { OPTION_CALLBACK, 0, "ignore-space-change", NULL, NULL,
 -                      "ignore changes in whitespace when finding context",
 +                      N_("ignore changes in whitespace when finding context"),
                        PARSE_OPT_NOARG, option_parse_space_change },
                { OPTION_CALLBACK, 0, "ignore-whitespace", NULL, NULL,
 -                      "ignore changes in whitespace when finding context",
 +                      N_("ignore changes in whitespace when finding context"),
                        PARSE_OPT_NOARG, option_parse_space_change },
                OPT_BOOLEAN('R', "reverse", &apply_in_reverse,
 -                      "apply the patch in reverse"),
 +                      N_("apply the patch in reverse")),
                OPT_BOOLEAN(0, "unidiff-zero", &unidiff_zero,
 -                      "don't expect at least one line of context"),
 +                      N_("don't expect at least one line of context")),
                OPT_BOOLEAN(0, "reject", &apply_with_reject,
 -                      "leave the rejected hunks in corresponding *.rej files"),
 +                      N_("leave the rejected hunks in corresponding *.rej files")),
                OPT_BOOLEAN(0, "allow-overlap", &allow_overlap,
 -                      "allow overlapping hunks"),
 -              OPT__VERBOSE(&apply_verbosely, "be verbose"),
 +                      N_("allow overlapping hunks")),
 +              OPT__VERBOSE(&apply_verbosely, N_("be verbose")),
                OPT_BIT(0, "inaccurate-eof", &options,
 -                      "tolerate incorrectly detected missing new-line at the end of file",
 +                      N_("tolerate incorrectly detected missing new-line at the end of file"),
                        INACCURATE_EOF),
                OPT_BIT(0, "recount", &options,
 -                      "do not trust the line counts in the hunk headers",
 +                      N_("do not trust the line counts in the hunk headers"),
                        RECOUNT),
 -              { OPTION_CALLBACK, 0, "directory", NULL, "root",
 -                      "prepend <root> to all filenames",
 +              { OPTION_CALLBACK, 0, "directory", NULL, N_("root"),
 +                      N_("prepend <root> to all filenames"),
                        0, option_parse_directory },
                OPT_END()
        };