git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marc Branchaud <marcnarc@xiplink.com>
To: git@vger.kernel.org
Subject: [PATCH] Make 'remote show' distinguish between merged and rebased remote branches
Date: Tue, 10 Feb 2009 12:08:58 -0500	[thread overview]
Message-ID: <20090210202046.8EBEC3360AC@rincewind> (raw)

Prints "rebased" instead of "merged" if branch.<name>.rebase is true.

Signed-off-by: Marc Branchaud <marcnarc@xiplink.com>
---

I'd like to be able to tell if my "git pull" is going to merge or rebase...

 builtin-remote.c  |   13 ++++++++++---
 t/t5505-remote.sh |    5 +++++
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/builtin-remote.c b/builtin-remote.c
index abc8dd8..ac3a88e 100644
--- a/builtin-remote.c
+++ b/builtin-remote.c
@@ -145,6 +145,7 @@ static int add(int argc, const char **argv)
 struct branch_info {
 	char *remote;
 	struct string_list merge;
+	int rebase;
 };
 
 static struct string_list branch_list;
@@ -164,7 +165,7 @@ static int config_read_branches(const char *key, const char *value, void *cb)
 		char *name;
 		struct string_list_item *item;
 		struct branch_info *info;
-		enum { REMOTE, MERGE } type;
+		enum { REMOTE, MERGE, REBASE } type;
 
 		key += 7;
 		if (!postfixcmp(key, ".remote")) {
@@ -173,6 +174,9 @@ static int config_read_branches(const char *key, const char *value, void *cb)
 		} else if (!postfixcmp(key, ".merge")) {
 			name = xstrndup(key, strlen(key) - 6);
 			type = MERGE;
+		} else if (!postfixcmp(key, ".rebase")) {
+			name = xstrndup(key, strlen(key) - 7);
+			type = REBASE;
 		} else
 			return 0;
 
@@ -185,7 +189,7 @@ static int config_read_branches(const char *key, const char *value, void *cb)
 			if (info->remote)
 				warning("more than one branch.%s", key);
 			info->remote = xstrdup(value);
-		} else {
+		} else if (type == MERGE) {
 			char *space = strchr(value, ' ');
 			value = abbrev_branch(value);
 			while (space) {
@@ -196,6 +200,8 @@ static int config_read_branches(const char *key, const char *value, void *cb)
 				space = strchr(value, ' ');
 			}
 			string_list_append(xstrdup(value), &info->merge);
+		} else {
+			info->rebase = 1;
 		}
 	}
 	return 0;
@@ -678,9 +684,10 @@ static int show(int argc, const char **argv)
 
 			if (!info->merge.nr || strcmp(*argv, info->remote))
 				continue;
-			printf("  Remote branch%s merged with 'git pull' "
+			printf("  Remote branch%s %s with 'git pull' "
 				"while on branch %s\n   ",
 				info->merge.nr > 1 ? "es" : "",
+				info->rebase ? "rebased" : "merged",
 				branch->string);
 			for (j = 0; j < info->merge.nr; j++)
 				printf(" %s", info->merge.items[j].string);
diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
index 1f59960..be0316a 100755
--- a/t/t5505-remote.sh
+++ b/t/t5505-remote.sh
@@ -112,6 +112,8 @@ cat > test/expect << EOF
   URL: $(pwd)/one
   Remote branch merged with 'git pull' while on branch master
     master
+  Remote branch rebased with 'git pull' while on branch rebaser
+    side
   New remote branch (next fetch will store in remotes/origin)
     master
   Tracked remote branches
@@ -136,7 +138,10 @@ test_expect_success 'show' '
 		refs/heads/master:refs/heads/upstream &&
 	 git config --add remote.origin.push \
 		+refs/tags/lastbackup &&
+	 git branch --track rebaser origin/side &&
+	 git config --add branch.rebaser.rebase true &&
 	 git remote show origin > output &&
+	 git branch -D rebaser &&
 	 test_cmp expect output)
 '
 
-- 
1.6.1.2.390.gba743

             reply	other threads:[~2009-02-10 20:22 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-10 17:08 Marc Branchaud [this message]
2009-02-10 21:17 ` [PATCH] Make 'remote show' distinguish between merged and rebased remote branches Junio C Hamano
2009-02-10 22:05   ` Marc Branchaud
2009-02-10 23:13     ` Jay Soffian
2009-02-11 16:59       ` Marc Branchaud
2009-02-11 17:12         ` Johannes Sixt
2009-02-11 17:35           ` Junio C Hamano
2009-02-11 21:35       ` Marc Branchaud
2009-02-10 21:22 ` Johannes Schindelin

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=20090210202046.8EBEC3360AC@rincewind \
    --to=marcnarc@xiplink.com \
    --cc=git@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).