All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Robin <stephen.robin@gmail.com>
To: pyokagan@gmail.com
Cc: git@vger.kernel.org
Subject: [PATCH 5/6] pull: allow interactive rebase
Date: Wed,  6 May 2015 01:00:52 +0100	[thread overview]
Message-ID: <1430870453-5408-6-git-send-email-stephen.robin@gmail.com> (raw)
In-Reply-To: <1430870453-5408-1-git-send-email-stephen.robin@gmail.com>

THIS PATCH SERIES IS NOT CODE-COMPLETE OR FULLY TESTED.
See code comments beginning TODO for work remaining.

Teach 'git pull' the option --rebase=interactive
Teach 'git remote' that the value for config variable branch.<name>.rebase
can be 'interactive'

Based-on-patch-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Stephen Robin <stephen.robin@gmail.com>
---

Notes:
    This feature is already present in msysgit.  This patch can be used
    either to bring the feature into standard git, or to resolve the
    conflict that will occur in the next rebase of msysgit.

 Documentation/config.txt   |  1 +
 Documentation/git-pull.txt |  4 +++-
 builtin/pull.c             | 19 ++++++++++++++++---
 builtin/remote.c           |  8 ++++++--
 4 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 2e5ceaf..91314ef 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -849,6 +849,7 @@ branch.<name>.rebase::
 	instead of merging the default branch from the default remote when
 	"git pull" is run. See "pull.rebase" for doing this in a non
 	branch-specific manner.
+	When the value is `interactive`, the rebase is run in interactive mode.
 +
 	When preserve, also pass `--preserve-merges` along to 'git rebase'
 	so that locally committed merge commits will not be flattened
diff --git a/Documentation/git-pull.txt b/Documentation/git-pull.txt
index 712ab4b..8014908 100644
--- a/Documentation/git-pull.txt
+++ b/Documentation/git-pull.txt
@@ -104,7 +104,7 @@ Options related to merging
 include::merge-options.txt[]
 
 -r::
---rebase[=false|true|preserve]::
+--rebase[=false|true|preserve|interactive]::
 	When true, rebase the current branch on top of the upstream
 	branch after fetching. If there is a remote-tracking branch
 	corresponding to the upstream branch and the upstream branch
@@ -116,6 +116,8 @@ to `git rebase` so that locally created merge commits will not be flattened.
 +
 When false, merge the current branch into the upstream branch.
 +
+When `interactive`, enable the interactive mode of rebase.
++
 See `pull.rebase`, `branch.<name>.rebase` and `branch.autoSetupRebase` in
 linkgit:git-config[1] if you want to make `git pull` always use
 `--rebase` instead of merging.
diff --git a/builtin/pull.c b/builtin/pull.c
index f420b4a..76c2f72 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -26,7 +26,8 @@ enum pull_mode {
 	PULL_NOT_SET = -1,
 	PULL_MERGE,
 	PULL_REBASE,
-	PULL_PRESERVE_MERGES_REBASE
+	PULL_PRESERVE_MERGES_REBASE,
+	PULL_INTERACTIVE_REBASE
 };
 
 static const char * const builtin_pull_usage[] = {
@@ -85,12 +86,22 @@ static int parse_pull_mode(const char *name, const char* arg,
 		return 0;
 	}
 
+	if (!strcmp(arg, "interactive")) {
+		*option_rebase = PULL_INTERACTIVE_REBASE;
+		return 0;
+	}
+
+	if (!strcmp(arg, "i")) {
+		*option_rebase = PULL_INTERACTIVE_REBASE;
+		return 0;
+	}
+
 	if (!strcmp(arg, "preserve")) {
 		*option_rebase = PULL_PRESERVE_MERGES_REBASE;
 		return 0;
 	}
 
-	error(_("Invalid value for %s, should be 'true', 'false' or 'preserve'."), name);
+	error(_("Invalid value for %s, should be 'true', 'false', 'interactive' or 'preserve'."), name);
 	return -1;
 }
 
@@ -197,7 +208,7 @@ static int option_parse_x(const struct option *opt,
 }
 
 static struct option builtin_pull_options[] = {
-	{ OPTION_CALLBACK, 0, "rebase", NULL, N_("true|false|preserve"),
+	{ OPTION_CALLBACK, 0, "rebase", NULL, N_("true|false|interactive|preserve"),
 		N_("incorporate changes by rebasing rather than merging"),
 		PARSE_OPT_OPTARG, option_parse_rebase },
 	OPT_BOOL(0, "progress", &progress,
@@ -527,6 +538,8 @@ static int run_rebase(const struct string_list merge_head, const char *fork_poin
 
 	if (pull_mode == PULL_PRESERVE_MERGES_REBASE)
 		argv_array_push(&argv, "--preserve-merges");
+	else if (pull_mode == PULL_INTERACTIVE_REBASE)
+		argv_array_push(&argv, "-i");
 
 	for (v = verbosity; v > 0; v--)
 		argv_array_push(&argv, "-v");
diff --git a/builtin/remote.c b/builtin/remote.c
index 5d3ab90..af6b21d 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -245,7 +245,7 @@ static int add(int argc, const char **argv)
 struct branch_info {
 	char *remote_name;
 	struct string_list merge;
-	int rebase;
+	enum { NO_REBASE, NORMAL_REBASE, INTERACTIVE_REBASE } rebase;
 };
 
 static struct string_list branch_list;
@@ -306,6 +306,8 @@ static int config_read_branches(const char *key, const char *value, void *cb)
 				info->rebase = v;
 			else if (!strcmp(value, "preserve"))
 				info->rebase = 1;
+			else if (!strcmp(value, "interactive"))
+				info->rebase = INTERACTIVE_REBASE;
 		}
 	}
 	return 0;
@@ -1000,7 +1002,9 @@ static int show_local_info_item(struct string_list_item *item, void *cb_data)
 
 	printf("    %-*s ", show_info->width, item->string);
 	if (branch_info->rebase) {
-		printf_ln(_("rebases onto remote %s"), merge->items[0].string);
+		printf_ln(_(branch_info->rebase == INTERACTIVE_REBASE ?
+			"rebases interactively onto remote %s" :
+			"rebases onto remote %s"), merge->items[0].string);
 		return 0;
 	} else if (show_info->any_rebase) {
 		printf_ln(_(" merges with remote %s"), merge->items[0].string);
-- 
2.4.0.7.gf20f26f

  parent reply	other threads:[~2015-05-06  0:01 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-27 19:50 GSoC 2015: 2 accepted proposals Matthieu Moy
2015-04-28  8:58 ` Paul Tan
2015-04-29 15:27   ` Johannes Schindelin
2015-05-06  0:00   ` [PATCH 0/6] Make pull a builtin Stephen Robin
2015-05-06  0:00     ` [PATCH 1/6] merge: tidy up options Stephen Robin
2015-05-06  0:00     ` [PATCH 2/6] merge: move error message given when a merge needs committing to advice.c Stephen Robin
2015-05-06  0:00     ` [PATCH 3/6] merge-base: split handle_fork_point to make reuse easier Stephen Robin
2015-05-06  0:00     ` [PATCH 4/6] pull: reimplement as a builtin in C Stephen Robin
2015-05-06  0:00     ` Stephen Robin [this message]
2015-05-06  5:43       ` [PATCH 5/6] pull: allow interactive rebase Johannes Schindelin
2015-05-06  0:00     ` [PATCH 6/6] parse-remote: dismantle git-parse-remote.sh Stephen Robin
2015-05-06  4:27     ` [PATCH 0/6] Make pull a builtin Paul Tan
2015-04-28 12:17 ` GSoC 2015: 2 accepted proposals karthik nayak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1430870453-5408-6-git-send-email-stephen.robin@gmail.com \
    --to=stephen.robin@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=pyokagan@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.