# [PATCH] Make 'remote show' distinguish between merged and rebased remote branches

9 messages from 2009-02-10 to 2009-02-11. Participants: Marc Branchaud, Junio C Hamano, Johannes Schindelin, Jay Soffian, Johannes Sixt.
Thread: https://gitlist.dev/t/17706

## Marc Branchaud, 2009-02-10 17:08

Subject: [PATCH] Make 'remote show' distinguish between merged and rebased remote branches
Message-ID: <20090210202046.8EBEC3360AC@rincewind>
URL: https://gitlist.dev/e/20090210202046.8EBEC3360AC%40rincewind

```
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

```

## Junio C Hamano, 2009-02-10 21:17

Subject: Re: [PATCH] Make 'remote show' distinguish between merged and rebased remote branches
Message-ID: <7v3aemm1po.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v3aemm1po.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <20090210202046.8EBEC3360AC@rincewind>

```
Marc Branchaud <marcnarc@xiplink.com> writes:

> Prints "rebased" instead of "merged" if branch.<name>.rebase is true.
>
> Signed-off-by: Marc Branchaud <marcnarc@xiplink.com>
> ...
> 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

I sympathize with what you are trying to do but I do not think this is
correct.  You will *never* rebase remote on top of your changes; rather
you will replay your changes on top of what the updated remote has.

It is more like "if you start git pull while on branch rebaser, it will
rebased on top of this branch from the remote".

```

## Johannes Schindelin, 2009-02-10 21:22

Subject: Re: [PATCH] Make 'remote show' distinguish between merged and rebased remote branches
Message-ID: <alpine.DEB.1.00.0902102220550.10279@pacific.mpi-cbg.de>
URL: https://gitlist.dev/e/alpine.DEB.1.00.0902102220550.10279%40pacific.mpi-cbg.de
In-Reply-To: <20090210202046.8EBEC3360AC@rincewind>

```
Hi,

On Tue, 10 Feb 2009, Marc Branchaud wrote:

> 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

I'm not a native speaker... but "rebased with" sounds wrong, but so does 
"Remote branch rebased onto with 'git pull' while on branch rebaser"...

Otherwise, the patch looks good to me.

Thanks,
Dscho

```

## Marc Branchaud, 2009-02-10 22:05

Subject: Re: [PATCH] Make 'remote show' distinguish between merged and rebased remote branches
Message-ID: <4991FA18.1040200@xiplink.com>
URL: https://gitlist.dev/e/4991FA18.1040200%40xiplink.com
In-Reply-To: <7v3aemm1po.fsf@gitster.siamese.dyndns.org>

```
Junio C Hamano wrote:
> 
> I sympathize with what you are trying to do but I do not think this is
> correct.  You will *never* rebase remote on top of your changes; rather
> you will replay your changes on top of what the updated remote has.
> 
> It is more like "if you start git pull while on branch rebaser, it will
> rebased on top of this branch from the remote".
> 

I'm happy to use more accurate phrasing -- I was just going for a minimal change.

How about the following, consistent for both cases:

'git pull' merges branch master with remote branch
  master
'git pull' rebases branch rebaser on top of remote branch
  side

?

I like the above because the keywords & branch names are in consistent locations, making it easier to parse the output.

		Marc

```

## Jay Soffian, 2009-02-10 23:13

Subject: Re: [PATCH] Make 'remote show' distinguish between merged and rebased remote branches
Message-ID: <76718490902101513i504e515ocb4a2d789ba520f0@mail.gmail.com>
URL: https://gitlist.dev/e/76718490902101513i504e515ocb4a2d789ba520f0%40mail.gmail.com
In-Reply-To: <4991FA18.1040200@xiplink.com>

```
On Tue, Feb 10, 2009 at 5:05 PM, Marc Branchaud <marcnarc@xiplink.com> wrote:
> I'm happy to use more accurate phrasing -- I was just going for a minimal change.
>
> How about the following, consistent for both cases:
>
> 'git pull' merges branch master with remote branch
>  master
> 'git pull' rebases branch rebaser on top of remote branch
>  side
>
> ?
>
> I like the above because the keywords & branch names are in consistent locations, making it easier to parse the output.

The output of git remote show seems much too verbose for the
information it provides. Something like this, I think, provides the
same information in much less space:

* remote origin
  URL: git://git.kernel.org/pub/scm/git/git.git
  Remote branches:
    html      Not tracked
    maint     Tracked
    man       Tracked
    master    Tracked
    next      Tracked
    pu        Tracked
    todo      Not tracked
    old-next  Stale (would prune)
  Local branches configured to pull from this remote:
    master           upstream is master (merges)
    wip/remote-HEAD  upstream is next   (rebases)

When run with "-n" the status column would be blank or say "Status not
available with -n".

$0.02. :-)

j.

```

## Marc Branchaud, 2009-02-11 16:59

Subject: Re: [PATCH] Make 'remote show' distinguish between merged and rebased remote branches
Message-ID: <499303E8.6030000@xiplink.com>
URL: https://gitlist.dev/e/499303E8.6030000%40xiplink.com
In-Reply-To: <76718490902101513i504e515ocb4a2d789ba520f0@mail.gmail.com>

```
Jay Soffian wrote:
> 
> The output of git remote show seems much too verbose for the
> information it provides.

I agree.

I'm happy to hammer out and implement new output for 'remote show', but is there any chance that such a change would be accepted?

Junio, Dscho, (others) -- any opposition to this?

> Something like this, I think, provides the
> same information in much less space:
> 
> * remote origin
>   URL: git://git.kernel.org/pub/scm/git/git.git
>   Remote branches:
>     html      Not tracked
>     maint     Tracked
>     man       Tracked
>     master    Tracked
>     next      Tracked
>     pu        Tracked
>     todo      Not tracked
>     old-next  Stale (would prune)
>   Local branches configured to pull from this remote:
>     master           upstream is master (merges)
>     wip/remote-HEAD  upstream is next   (rebases)

How about something a bit tighter, merging the local branch list with the remote branch list:

* remote origin
  URL: git://git.kernel.org/pub/scm/git/git.git
  Remote branches:
    html      Not tracked
    master    Tracked by local branches:
                master (merges)
                mywork (rebases)
    next      Tracked by local branch:
                wip/remote-HEAD (rebases)
    pu        Tracked by local branch:
                pu (merges)
    todo      Not tracked
    old-next  Stale (would prune)

?

		M.

```

## Johannes Sixt, 2009-02-11 17:12

Subject: Re: [PATCH] Make 'remote show' distinguish between merged and rebased remote branches
Message-ID: <499306F7.8050404@viscovery.net>
URL: https://gitlist.dev/e/499306F7.8050404%40viscovery.net
In-Reply-To: <499303E8.6030000@xiplink.com>

```
Marc Branchaud schrieb:
> Jay Soffian wrote:
>> * remote origin
>>   URL: git://git.kernel.org/pub/scm/git/git.git
>>   Remote branches:
>>     html      Not tracked
>>     maint     Tracked
>>     man       Tracked
>>     master    Tracked
>>     next      Tracked
>>     pu        Tracked
>>     todo      Not tracked
>>     old-next  Stale (would prune)
>>   Local branches configured to pull from this remote:
>>     master           upstream is master (merges)
>>     wip/remote-HEAD  upstream is next   (rebases)

I find this form more useful than the one below because of the clear
separation into remote an local branchs.

> How about something a bit tighter, merging the local branch list with the remote branch list:
> 
> * remote origin
>   URL: git://git.kernel.org/pub/scm/git/git.git
>   Remote branches:
>     html      Not tracked
>     master    Tracked by local branches:
>                 master (merges)
>                 mywork (rebases)
>     next      Tracked by local branch:
>                 wip/remote-HEAD (rebases)
>     pu        Tracked by local branch:
>                 pu (merges)
>     todo      Not tracked
>     old-next  Stale (would prune)

-- Hannes

```

## Junio C Hamano, 2009-02-11 17:35

Subject: Re: [PATCH] Make 'remote show' distinguish between merged and rebased remote branches
Message-ID: <7vab8sg9m6.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vab8sg9m6.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <499306F7.8050404@viscovery.net>

```
Johannes Sixt <j.sixt@viscovery.net> writes:

> Marc Branchaud schrieb:
>> Jay Soffian wrote:
>>> * remote origin
>>>   URL: git://git.kernel.org/pub/scm/git/git.git
>>>   Remote branches:
>>>     html      Not tracked
>>>     maint     Tracked
>>>     man       Tracked
>>>     master    Tracked
>>>     next      Tracked
>>>     pu        Tracked
>>>     todo      Not tracked
>>>     old-next  Stale (would prune)
>>>   Local branches configured to pull from this remote:
>>>     master           upstream is master (merges)
>>>     wip/remote-HEAD  upstream is next   (rebases)
>
> I find this form more useful than the one below because of the clear
> separation into remote an local branchs.

Good point.

```

## Marc Branchaud, 2009-02-11 21:35

Subject: Re: [PATCH] Make 'remote show' distinguish between merged and rebased remote branches
Message-ID: <4993449B.2040401@xiplink.com>
URL: https://gitlist.dev/e/4993449B.2040401%40xiplink.com
In-Reply-To: <76718490902101513i504e515ocb4a2d789ba520f0@mail.gmail.com>

```
Jay Soffian wrote:
> 
> The output of git remote show seems much too verbose for the
> information it provides. Something like this, I think, provides the
> same information in much less space:
> 
> * remote origin
>   URL: git://git.kernel.org/pub/scm/git/git.git
>   Remote branches:
>     html      Not tracked
>     maint     Tracked
>     man       Tracked
>     master    Tracked
>     next      Tracked
>     pu        Tracked
>     todo      Not tracked
>     old-next  Stale (would prune)
>   Local branches configured to pull from this remote:
>     master           upstream is master (merges)
>     wip/remote-HEAD  upstream is next   (rebases)

The current test case for 'remote show' (without my rebase patch) is:

* remote origin
  URL: $(pwd)/one
  Remote branch merged with 'git pull' while on branch master
    master
  New remote branch (next fetch will store in remotes/origin)
    master
  Tracked remote branches
    side
    master
  Local branches pushed with 'git push'
    master:upstream
    +refs/tags/lastbackup

Should that last bit about 'git push' change as well (I admit I don't really understand what that part is saying)?  Or should we just be consistent?  Maybe something like:

* remote origin
  URL: $(pwd)/one
  Remote branches:
    master  Tracked
    side    Not tracked
    flip    Tracked
  New remote branch (next fetch will store in remotes/origin)
    master
  Local branches tracking this remote:
    master   upstream is master (merges)
    rebaser  upstream is flip   (rebases)
  Local branches pushed with 'git push'
    master:upstream
    +refs/tags/lastbackup

		M.

```
