@matheusbsbs / matheus-bagliano / commits / 4d924528d8
Fork 0

Revert "Merge branch 'ra/rebase-i-more-options'"

This reverts commit 5d9324e0f4210bb7d52bcb79efe3935703083f72, reversing changes made to c58ae96fc4bb11916b62a96940bb70bb85ea5992. The topic turns out to be too buggy for real use. cf. <f2fe7437-8a48-3315-4d3f-8d51fe4bb8f1@gmail.com>

Junio C Hamano committed Jan 12, 2020 at 12:27 UTC 4d924528d8bfe947abfc54ee9bd3892ab509c8cd
7 files changed +28 -327
Documentation/RelNotes/2.25.0.txt
-3
@@ -53,9 +53,6 @@ UI, Workflows & Features
53 or a named file, instead of taking it as the command line
54 arguments, with the "--pathspec-from-file" option.
55
56 - * "git rebase -i" learned a few options that are known by "git
57 - rebase" proper.
58 -
56 * "git submodule" learned a subcommand "set-url".
57
58 * "git log" family learned "--pretty=reference" that gives the name
Documentation/git-rebase.txt
+6 -21
@@ -393,31 +393,16 @@ your branch contains commits which were dropped, this option can be used
393 with `--keep-base` in order to drop those commits from your branch.
394
395 --ignore-whitespace::
396 - Behaves differently depending on which backend is selected.
397 -+
398 -'am' backend: When applying a patch, ignore changes in whitespace in
399 -context lines if necessary.
400 -+
401 -'interactive' backend: Treat lines with only whitespace changes as
402 -unchanged for the sake of a three-way merge.
403 -
396 --whitespace=<option>::
405 - This flag is passed to the 'git apply' program
397 + These flag are passed to the 'git apply' program
398 (see linkgit:git-apply[1]) that applies the patch.
399 +
400 See also INCOMPATIBLE OPTIONS below.
401
402 --committer-date-is-author-date::
411 - Instead of recording the time the rebased commits are
412 - created as the committer date, reuse the author date
413 - as the committer date. This implies --force-rebase.
414 -
403 --ignore-date::
416 ---reset-author-date::
417 - By default, the author date of the original commit is used
418 - as the author date for the resulting commit. This option
419 - tells Git to use the current timestamp instead and implies
420 - `--force-rebase`.
404 + These flags are passed to 'git am' to easily change the dates
405 + of the rebased commits (see linkgit:git-am[1]).
406 +
407 See also INCOMPATIBLE OPTIONS below.
408
@@ -554,7 +539,10 @@ INCOMPATIBLE OPTIONS
539
540 The following options:
541
542 + * --committer-date-is-author-date
543 + * --ignore-date
544 * --whitespace
545 + * --ignore-whitespace
546 * -C
547
548 are incompatible with the following options:
@@ -577,9 +565,6 @@ In addition, the following pairs of options are incompatible:
565 * --preserve-merges and --interactive
566 * --preserve-merges and --signoff
567 * --preserve-merges and --rebase-merges
580 - * --preserve-merges and --ignore-whitespace
581 - * --preserve-merges and --committer-date-is-author-date
582 - * --preserve-merges and --ignore-date
568 * --keep-base and --onto
569 * --keep-base and --root
570
builtin/rebase.c
+12 -37
@@ -79,11 +79,8 @@ struct rebase_options {
79 int allow_rerere_autoupdate;
80 int keep_empty;
81 int autosquash;
82 - int ignore_whitespace;
82 char *gpg_sign_opt;
83 int autostash;
85 - int committer_date_is_author_date;
86 - int ignore_date;
84 char *cmd;
85 int allow_empty_message;
86 int rebase_merges, rebase_cousins;
@@ -102,7 +99,6 @@ struct rebase_options {
99
100 static struct replay_opts get_replay_opts(const struct rebase_options *opts)
101 {
105 - struct strbuf strategy_buf = STRBUF_INIT;
102 struct replay_opts replay = REPLAY_OPTS_INIT;
103
104 replay.action = REPLAY_INTERACTIVE_REBASE;
@@ -116,20 +112,10 @@ static struct replay_opts get_replay_opts(const struct rebase_options *opts)
112 replay.allow_empty_message = opts->allow_empty_message;
113 replay.verbose = opts->flags & REBASE_VERBOSE;
114 replay.reschedule_failed_exec = opts->reschedule_failed_exec;
119 - replay.committer_date_is_author_date =
120 - opts->committer_date_is_author_date;
121 - replay.ignore_date = opts->ignore_date;
115 replay.gpg_sign = xstrdup_or_null(opts->gpg_sign_opt);
116 replay.strategy = opts->strategy;
124 -
117 if (opts->strategy_opts)
126 - strbuf_addstr(&strategy_buf, opts->strategy_opts);
127 - if (opts->ignore_whitespace)
128 - strbuf_addstr(&strategy_buf, " --ignore-space-change");
129 - if (strategy_buf.len)
130 - parse_strategy_opts(&replay, strategy_buf.buf);
131 -
132 - strbuf_release(&strategy_buf);
118 + parse_strategy_opts(&replay, opts->strategy_opts);
119
120 if (opts->squash_onto) {
121 oidcpy(&replay.squash_onto, opts->squash_onto);
@@ -531,8 +517,6 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)
517 argc = parse_options(argc, argv, prefix, options,
518 builtin_rebase_interactive_usage, PARSE_OPT_KEEP_ARGV0);
519
534 - opts.strategy_opts = xstrdup_or_null(opts.strategy_opts);
535 -
520 if (!is_null_oid(&squash_onto))
521 opts.squash_onto = &squash_onto;
522
@@ -986,12 +970,6 @@ static int run_am(struct rebase_options *opts)
970 am.git_cmd = 1;
971 argv_array_push(&am.args, "am");
972
989 - if (opts->ignore_whitespace)
990 - argv_array_push(&am.args, "--ignore-whitespace");
991 - if (opts->committer_date_is_author_date)
992 - argv_array_push(&opts->git_am_opts, "--committer-date-is-author-date");
993 - if (opts->ignore_date)
994 - argv_array_push(&opts->git_am_opts, "--ignore-date");
973 if (opts->action && !strcmp("continue", opts->action)) {
974 argv_array_push(&am.args, "--resolved");
975 argv_array_pushf(&am.args, "--resolvemsg=%s", resolvemsg);
@@ -1459,17 +1437,16 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1437 PARSE_OPT_NOARG, NULL, REBASE_DIFFSTAT },
1438 OPT_BOOL(0, "signoff", &options.signoff,
1439 N_("add a Signed-off-by: line to each commit")),
1462 - OPT_BOOL(0, "committer-date-is-author-date",
1463 - &options.committer_date_is_author_date,
1464 - N_("make committer date match author date")),
1465 - OPT_BOOL(0, "reset-author-date", &options.ignore_date,
1466 - N_("ignore author date and use current date")),
1467 - OPT_HIDDEN_BOOL(0, "ignore-date", &options.ignore_date,
1468 - N_("synonym of --reset-author-date")),
1440 + OPT_PASSTHRU_ARGV(0, "ignore-whitespace", &options.git_am_opts,
1441 + NULL, N_("passed to 'git am'"),
1442 + PARSE_OPT_NOARG),
1443 + OPT_PASSTHRU_ARGV(0, "committer-date-is-author-date",
1444 + &options.git_am_opts, NULL,
1445 + N_("passed to 'git am'"), PARSE_OPT_NOARG),
1446 + OPT_PASSTHRU_ARGV(0, "ignore-date", &options.git_am_opts, NULL,
1447 + N_("passed to 'git am'"), PARSE_OPT_NOARG),
1448 OPT_PASSTHRU_ARGV('C', NULL, &options.git_am_opts, N_("n"),
1449 N_("passed to 'git apply'"), 0),
1471 - OPT_BOOL(0, "ignore-whitespace", &options.ignore_whitespace,
1472 - N_("ignore changes in whitespace")),
1450 OPT_PASSTHRU_ARGV(0, "whitespace", &options.git_am_opts,
1451 N_("action"), N_("passed to 'git apply'"), 0),
1452 OPT_BIT('f', "force-rebase", &options.flags,
@@ -1742,13 +1719,11 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1719 state_dir_base, cmd_live_rebase, buf.buf);
1720 }
1721
1745 - if (options.committer_date_is_author_date ||
1746 - options.ignore_date)
1747 - options.flags |= REBASE_FORCE;
1748 -
1722 for (i = 0; i < options.git_am_opts.argc; i++) {
1723 const char *option = options.git_am_opts.argv[i], *p;
1751 - if (!strcmp(option, "--whitespace=fix") ||
1724 + if (!strcmp(option, "--committer-date-is-author-date") ||
1725 + !strcmp(option, "--ignore-date") ||
1726 + !strcmp(option, "--whitespace=fix") ||
1727 !strcmp(option, "--whitespace=strip"))
1728 options.flags |= REBASE_FORCE;
1729 else if (skip_prefix(option, "-C", &p)) {
sequencer.c
+8 -133
@@ -147,8 +147,6 @@ static GIT_PATH_FUNC(rebase_path_refs_to_delete, "rebase-merge/refs-to-delete")
147 * command-line.
148 */
149 static GIT_PATH_FUNC(rebase_path_gpg_sign_opt, "rebase-merge/gpg_sign_opt")
150 -static GIT_PATH_FUNC(rebase_path_cdate_is_adate, "rebase-merge/cdate_is_adate")
151 -static GIT_PATH_FUNC(rebase_path_ignore_date, "rebase-merge/ignore_date")
150 static GIT_PATH_FUNC(rebase_path_orig_head, "rebase-merge/orig-head")
151 static GIT_PATH_FUNC(rebase_path_verbose, "rebase-merge/verbose")
152 static GIT_PATH_FUNC(rebase_path_quiet, "rebase-merge/quiet")
@@ -825,19 +823,9 @@ int read_author_script(const char *path, char **name, char **email, char **date,
823 error(_("missing 'GIT_AUTHOR_DATE'"));
824 if (date_i < 0 || email_i < 0 || date_i < 0 || err)
825 goto finish;
828 -
829 - if (name)
830 - *name = kv.items[name_i].util;
831 - else
832 - free(kv.items[name_i].util);
833 - if (email)
834 - *email = kv.items[email_i].util;
835 - else
836 - free(kv.items[email_i].util);
837 - if (date)
838 - *date = kv.items[date_i].util;
839 - else
840 - free(kv.items[date_i].util);
826 + *name = kv.items[name_i].util;
827 + *email = kv.items[email_i].util;
828 + *date = kv.items[date_i].util;
829 retval = 0;
830 finish:
831 string_list_clear(&kv, !!retval);
@@ -880,47 +868,6 @@ static char *get_author(const char *message)
868 return NULL;
869 }
870
883 -/* Returns a "date" string that needs to be free()'d by the caller */
884 -static char *read_author_date_or_null(void)
885 -{
886 - char *date;
887 -
888 - if (read_author_script(rebase_path_author_script(),
889 - NULL, NULL, &date, 0))
890 - return NULL;
891 - return date;
892 -}
893 -
894 -/* Construct a free()able author string with current time as the author date */
895 -static char *ignore_author_date(const char *author)
896 -{
897 - int len = strlen(author);
898 - struct ident_split ident;
899 - struct strbuf new_author = STRBUF_INIT;
900 -
901 - if (split_ident_line(&ident, author, len) < 0) {
902 - error(_("malformed ident line"));
903 - return NULL;
904 - }
905 - len = ident.mail_end - ident.name_begin + 1;
906 -
907 - strbuf_addf(&new_author, "%.*s ", len, ident.name_begin);
908 - datestamp(&new_author);
909 - return strbuf_detach(&new_author, NULL);
910 -}
911 -
912 -static void push_dates(struct child_process *child, int change_committer_date)
913 -{
914 - time_t now = time(NULL);
915 - struct strbuf date = STRBUF_INIT;
916 -
917 - strbuf_addf(&date, "@%"PRIuMAX, (uintmax_t)now);
918 - argv_array_pushf(&child->env_array, "GIT_AUTHOR_DATE=%s", date.buf);
919 - if (change_committer_date)
920 - argv_array_pushf(&child->env_array, "GIT_COMMITTER_DATE=%s", date.buf);
921 - strbuf_release(&date);
922 -}
923 -
871 static const char staged_changes_advice[] =
872 N_("you have staged changes in your working tree\n"
873 "If these changes are meant to be squashed into the previous commit, run:\n"
@@ -980,25 +927,6 @@ static int run_git_commit(struct repository *r,
927
928 cmd.git_cmd = 1;
929
983 - if (opts->committer_date_is_author_date) {
984 - int res = -1;
985 - struct strbuf datebuf = STRBUF_INIT;
986 - char *date = read_author_date_or_null();
987 -
988 - if (!date)
989 - return -1;
990 -
991 - strbuf_addf(&datebuf, "@%s", date);
992 - res = setenv("GIT_COMMITTER_DATE",
993 - opts->ignore_date ? "" : datebuf.buf, 1);
994 -
995 - strbuf_release(&datebuf);
996 - free(date);
997 -
998 - if (res)
999 - return -1;
1000 - }
1001 -
930 if (is_rebase_i(opts) && read_env_script(&cmd.env_array)) {
931 const char *gpg_opt = gpg_sign_opt_quoted(opts);
932
@@ -1014,8 +942,6 @@ static int run_git_commit(struct repository *r,
942 argv_array_push(&cmd.args, "--amend");
943 if (opts->gpg_sign)
944 argv_array_pushf(&cmd.args, "-S%s", opts->gpg_sign);
1017 - if (opts->ignore_date)
1018 - push_dates(&cmd, opts->committer_date_is_author_date);
945 if (defmsg)
946 argv_array_pushl(&cmd.args, "-F", defmsg, NULL);
947 else if (!(flags & EDIT_MSG))
@@ -1384,13 +1310,14 @@ static int try_to_commit(struct repository *r,
1310 struct commit_extra_header *extra = NULL;
1311 struct strbuf err = STRBUF_INIT;
1312 struct strbuf commit_msg = STRBUF_INIT;
1387 - char *author_to_free = NULL;
1313 + char *amend_author = NULL;
1314 const char *hook_commit = NULL;
1315 enum commit_msg_cleanup_mode cleanup;
1316 int res = 0;
1317
1318 if (parse_head(r, &current_head))
1319 return -1;
1320 +
1321 if (flags & AMEND_MSG) {
1322 const char *exclude_gpgsig[] = { "gpgsig", NULL };
1323 const char *out_enc = get_commit_output_encoding();
@@ -1405,7 +1332,7 @@ static int try_to_commit(struct repository *r,
1332 strbuf_addstr(msg, orig_message);
1333 hook_commit = "HEAD";
1334 }
1408 - author = author_to_free = get_author(message);
1335 + author = amend_author = get_author(message);
1336 unuse_commit_buffer(current_head, message);
1337 if (!author) {
1338 res = error(_("unable to parse commit author"));
@@ -1418,31 +1345,6 @@ static int try_to_commit(struct repository *r,
1345 commit_list_insert(current_head, &parents);
1346 }
1347
1421 - if (opts->committer_date_is_author_date) {
1422 - int len = strlen(author);
1423 - struct ident_split ident;
1424 - struct strbuf date = STRBUF_INIT;
1425 -
1426 - if (split_ident_line(&ident, author, len) < 0) {
1427 - res = error(_("malformed ident line"));
1428 - goto out;
1429 - }
1430 - if (!ident.date_begin) {
1431 - res = error(_("corrupted author without date information"));
1432 - goto out;
1433 - }
1434 -
1435 - strbuf_addf(&date, "@%.*s %.*s",
1436 - (int)(ident.date_end - ident.date_begin), ident.date_begin,
1437 - (int)(ident.tz_end - ident.tz_begin), ident.tz_begin);
1438 - res = setenv("GIT_COMMITTER_DATE",
1439 - opts->ignore_date ? "" : date.buf, 1);
1440 - strbuf_release(&date);
1441 -
1442 - if (res)
1443 - goto out;
1444 - }
1445 -
1348 if (write_index_as_tree(&tree, r->index, r->index_file, 0, NULL)) {
1349 res = error(_("git write-tree failed to write a tree"));
1350 goto out;
@@ -1502,15 +1404,6 @@ static int try_to_commit(struct repository *r,
1404
1405 reset_ident_date();
1406
1505 - if (opts->ignore_date) {
1506 - author = ignore_author_date(author);
1507 - if (!author) {
1508 - res = -1;
1509 - goto out;
1510 - }
1511 - free(author_to_free);
1512 - author_to_free = (char *)author;
1513 - }
1407 if (commit_tree_extended(msg->buf, msg->len, &tree, parents,
1408 oid, author, opts->gpg_sign, extra)) {
1409 res = error(_("failed to write commit object"));
@@ -1531,7 +1424,7 @@ out:
1424 free_commit_extra_headers(extra);
1425 strbuf_release(&err);
1426 strbuf_release(&commit_msg);
1534 - free(author_to_free);
1427 + free(amend_author);
1428
1429 return res;
1430 }
@@ -2599,16 +2492,6 @@ static int read_populate_opts(struct replay_opts *opts)
2492 opts->signoff = 1;
2493 }
2494
2602 - if (file_exists(rebase_path_cdate_is_adate())) {
2603 - opts->allow_ff = 0;
2604 - opts->committer_date_is_author_date = 1;
2605 - }
2606 -
2607 - if (file_exists(rebase_path_ignore_date())) {
2608 - opts->allow_ff = 0;
2609 - opts->ignore_date = 1;
2610 - }
2611 -
2495 if (file_exists(rebase_path_reschedule_failed_exec()))
2496 opts->reschedule_failed_exec = 1;
2497
@@ -2691,10 +2574,6 @@ int write_basic_state(struct replay_opts *opts, const char *head_name,
2574 write_file(rebase_path_gpg_sign_opt(), "-S%s\n", opts->gpg_sign);
2575 if (opts->signoff)
2576 write_file(rebase_path_signoff(), "--signoff\n");
2694 - if (opts->committer_date_is_author_date)
2695 - write_file(rebase_path_cdate_is_adate(), "%s", "");
2696 - if (opts->ignore_date)
2697 - write_file(rebase_path_ignore_date(), "%s", "");
2577 if (opts->reschedule_failed_exec)
2578 write_file(rebase_path_reschedule_failed_exec(), "%s", "");
2579
@@ -3635,8 +3514,6 @@ static int do_merge(struct repository *r,
3514 argv_array_push(&cmd.args, git_path_merge_msg(r));
3515 if (opts->gpg_sign)
3516 argv_array_push(&cmd.args, opts->gpg_sign);
3638 - if (opts->ignore_date)
3639 - push_dates(&cmd, opts->committer_date_is_author_date);
3517
3518 /* Add the tips to be merged */
3519 for (j = to_merge; j; j = j->next)
@@ -3909,9 +3786,7 @@ static int pick_commits(struct repository *r,
3786 setenv(GIT_REFLOG_ACTION, action_name(opts), 0);
3787 if (opts->allow_ff)
3788 assert(!(opts->signoff || opts->no_commit ||
3912 - opts->record_origin || opts->edit ||
3913 - opts->committer_date_is_author_date ||
3914 - opts->ignore_date));
3789 + opts->record_origin || opts->edit));
3790 if (read_and_refresh_cache(r, opts))
3791 return -1;
3792
sequencer.h
-2
@@ -43,8 +43,6 @@ struct replay_opts {
43 int verbose;
44 int quiet;
45 int reschedule_failed_exec;
46 - int committer_date_is_author_date;
47 - int ignore_date;
46
47 int mainline;
48
t/t3422-rebase-incompatible-options.sh
+2
@@ -61,6 +61,8 @@ test_rebase_am_only () {
61 }
62
63 test_rebase_am_only --whitespace=fix
64 +test_rebase_am_only --ignore-whitespace
65 +test_rebase_am_only --committer-date-is-author-date
66 test_rebase_am_only -C4
67
68 test_expect_success REBASE_P '--preserve-merges incompatible with --signoff' '
t/t3433-rebase-options-compatibility.sh deleted
-131
@@ -1,131 +0,0 @@
1 -#!/bin/sh
2 -#
3 -# Copyright (c) 2019 Rohit Ashiwal
4 -#
5 -
6 -test_description='tests to ensure compatibility between am and interactive backends'
7 -
8 -. ./test-lib.sh
9 -
10 -GIT_AUTHOR_DATE="1999-04-02T08:03:20+05:30"
11 -export GIT_AUTHOR_DATE
12 -
13 -# This is a special case in which both am and interactive backends
14 -# provide the same output. It was done intentionally because
15 -# both the backends fall short of optimal behaviour.
16 -test_expect_success 'setup' '
17 - git checkout -b topic &&
18 - q_to_tab >file <<-\EOF &&
19 - line 1
20 - Qline 2
21 - line 3
22 - EOF
23 - git add file &&
24 - git commit -m "add file" &&
25 - cat >file <<-\EOF &&
26 - line 1
27 - new line 2
28 - line 3
29 - EOF
30 - git commit -am "update file" &&
31 - git tag side &&
32 - test_commit commit1 foo foo1 &&
33 - test_commit commit2 foo foo2 &&
34 - test_commit commit3 foo foo3 &&
35 -
36 - git checkout --orphan master &&
37 - git rm --cached foo &&
38 - rm foo &&
39 - sed -e "s/^|//" >file <<-\EOF &&
40 - |line 1
41 - | line 2
42 - |line 3
43 - EOF
44 - git add file &&
45 - git commit -m "add file" &&
46 - git tag main
47 -'
48 -
49 -test_expect_success '--ignore-whitespace works with am backend' '
50 - cat >expect <<-\EOF &&
51 - line 1
52 - new line 2
53 - line 3
54 - EOF
55 - test_must_fail git rebase main side &&
56 - git rebase --abort &&
57 - git rebase --ignore-whitespace main side &&
58 - test_cmp expect file
59 -'
60 -
61 -test_expect_success '--ignore-whitespace works with interactive backend' '
62 - cat >expect <<-\EOF &&
63 - line 1
64 - new line 2
65 - line 3
66 - EOF
67 - test_must_fail git rebase --merge main side &&
68 - git rebase --abort &&
69 - git rebase --merge --ignore-whitespace main side &&
70 - test_cmp expect file
71 -'
72 -
73 -test_expect_success '--committer-date-is-author-date works with am backend' '
74 - git commit --amend &&
75 - git rebase --committer-date-is-author-date HEAD^ &&
76 - git show HEAD --pretty="format:%ai" >authortime &&
77 - git show HEAD --pretty="format:%ci" >committertime &&
78 - test_cmp authortime committertime
79 -'
80 -
81 -test_expect_success '--committer-date-is-author-date works with interactive backend' '
82 - git commit --amend &&
83 - git rebase -i --committer-date-is-author-date HEAD^ &&
84 - git show HEAD --pretty="format:%ai" >authortime &&
85 - git show HEAD --pretty="format:%ci" >committertime &&
86 - test_cmp authortime committertime
87 -'
88 -
89 -test_expect_success '--committer-date-is-author-date works with rebase -r' '
90 - git checkout side &&
91 - git merge --no-ff commit3 &&
92 - git rebase -r --root --committer-date-is-author-date &&
93 - git rev-list HEAD >rev_list &&
94 - while read HASH
95 - do
96 - git show $HASH --pretty="format:%ai" >authortime
97 - git show $HASH --pretty="format:%ci" >committertime
98 - test_cmp authortime committertime
99 - done <rev_list
100 -'
101 -
102 -# Checking for +0000 in author time is enough since default
103 -# timezone is UTC, but the timezone used while committing
104 -# sets to +0530.
105 -test_expect_success '--ignore-date works with am backend' '
106 - git commit --amend --date="$GIT_AUTHOR_DATE" &&
107 - git rebase --ignore-date HEAD^ &&
108 - git show HEAD --pretty="format:%ai" >authortime &&
109 - grep "+0000" authortime
110 -'
111 -
112 -test_expect_success '--ignore-date works with interactive backend' '
113 - git commit --amend --date="$GIT_AUTHOR_DATE" &&
114 - git rebase --ignore-date -i HEAD^ &&
115 - git show HEAD --pretty="format:%ai" >authortime &&
116 - grep "+0000" authortime
117 -'
118 -
119 -test_expect_success '--ignore-date works with rebase -r' '
120 - git checkout side &&
121 - git merge --no-ff commit3 &&
122 - git rebase -r --root --ignore-date &&
123 - git rev-list HEAD >rev_list &&
124 - while read HASH
125 - do
126 - git show $HASH --pretty="format:%ai" >authortime
127 - grep "+0000" authortime
128 - done <rev_list
129 -'
130 -
131 -test_done