# [PATCH] Add suggestion to hard-to-understand error message

7 messages from 2005-12-21 to 2005-12-23. Participants: Johannes Schindelin, Junio C Hamano, Andreas Ericsson.
Thread: https://gitlist.dev/t/2903

## Johannes Schindelin, 2005-12-21 23:49

Subject: [PATCH] Add suggestion to hard-to-understand error message
Message-ID: <Pine.LNX.4.63.0512220048360.13453@wbgn013.biozentrum.uni-wuerzburg.de>
URL: https://gitlist.dev/e/Pine.LNX.4.63.0512220048360.13453%40wbgn013.biozentrum.uni-wuerzburg.de

```

Dummies like me do not understand readily that "remote object abcdef...
does not exist on local" means: "Hey, you did not pull this, did you?".
So, add "(pull first?)" to that message.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>

---

	Wow, my commit messages get longer, while the patches get shorter.
	Odd.

 send-pack.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

af2d86726fe961043d0c69c4fb727689a5903b63
diff --git a/send-pack.c b/send-pack.c
index 5bc2f01..643662a 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -233,7 +233,7 @@ static int send_pack(int in, int out, in
 		    !ref->force) {
 			if (!has_sha1_file(ref->old_sha1)) {
 				error("remote '%s' object %s does not "
-				      "exist on local",
+				      "exist on local (pull first?)",
 				      ref->name, sha1_to_hex(ref->old_sha1));
 				ret = -2;
 				continue;
-- 
0.99.9.GIT

```

## Junio C Hamano, 2005-12-22 01:15

Subject: Re: [PATCH] Add suggestion to hard-to-understand error message
Message-ID: <7vd5jqvsn1.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vd5jqvsn1.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <Pine.LNX.4.63.0512220048360.13453@wbgn013.biozentrum.uni-wuerzburg.de>

```
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> Dummies like me do not understand readily that "remote object abcdef...
> does not exist on local" means: "Hey, you did not pull this, did you?".
> So, add "(pull first?)" to that message.

I am ambivalent about this one.  It is a special case of "remote
is not a strict subset of local" situation, so we might be
better if we just said the same as the other error message and
be done with it.  On the other hand, the code does know the
difference of the two situations at this point, and it could be
argued that giving the same error is losing information.

Earlier I once rewound the "master" branch head by one commit
too much by mistake.  The next push to the public server would
have given me a different error message, depending on whether I
pruned my private repository or not in between.  For example,
after this sequence:

    $ git commit -m 'initial'
    $ git commit -m 'next'
    $ git push remote master
    $ git reset --hard HEAD^
    $ git commit -m 'third but second'

If you do not prune at this point, then the remote commit "next"
still exists in the local repository (but not reachable).  Then

    $ git push remote master

would not say "pull first?".  But if you prune local repository
before pushing, it would now say "pull first?".

In a sense, both are "pull first?" situation, and it probably is
more confusing to give different messages to the user in these
two cases.  From the end-user point of view they are the same
"remote is not strict subset.".

```

## Andreas Ericsson, 2005-12-22 10:03

Subject: Re: [PATCH] Add suggestion to hard-to-understand error message
Message-ID: <43AA79EB.6040800@op5.se>
URL: https://gitlist.dev/e/43AA79EB.6040800%40op5.se
In-Reply-To: <7vd5jqvsn1.fsf@assigned-by-dhcp.cox.net>

```
Junio C Hamano wrote:
> In a sense, both are "pull first?" situation, and it probably is
> more confusing to give different messages to the user in these
> two cases.  From the end-user point of view they are the same
> "remote is not strict subset.".
> 

In non-git'ish, does this mean "you're not up to date, so pull before 
pushing" ? If so, why not say so? I'm sure it could prevent a fair few 
problems for users (not least those new to scm's).

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

```

## Junio C Hamano, 2005-12-22 19:27

Subject: Re: [PATCH] Add suggestion to hard-to-understand error message
Message-ID: <7vek45lyor.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vek45lyor.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <43AA79EB.6040800@op5.se>

```
Andreas Ericsson <ae@op5.se> writes:

> Junio C Hamano wrote:
>> In a sense, both are "pull first?" situation, and it probably is
>> more confusing to give different messages to the user in these
>> two cases.  From the end-user point of view they are the same
>> "remote is not strict subset.".
>
> In non-git'ish, does this mean "you're not up to date, so pull before 
> pushing" ? If so, why not say so? I'm sure it could prevent a fair few 
> problems for users (not least those new to scm's).

Perhaps.  I was suggesting to say that in *both* places, not
just one.

```

## Junio C Hamano, 2005-12-22 20:41

Subject: [PATCH] send-pack: reword non-fast-forward error message.
Message-ID: <7vu0d0j24z.fsf_-_@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vu0d0j24z.fsf_-_%40assigned-by-dhcp.cox.net
In-Reply-To: <7vek45lyor.fsf@assigned-by-dhcp.cox.net>

```
Junio C Hamano <junkio@cox.net> writes:

> Andreas Ericsson <ae@op5.se> writes:
>
>> Junio C Hamano wrote:
>>> In a sense, both are "pull first?" situation, and it probably is
>>> more confusing to give different messages to the user in these
>>> two cases.  From the end-user point of view they are the same
>>> "remote is not strict subset.".
>>
>> In non-git'ish, does this mean "you're not up to date, so pull before 
>> pushing" ? If so, why not say so? I'm sure it could prevent a fair few 
>> problems for users (not least those new to scm's).

That is reasonable.  How about this?

-- >8 --
Wnen refusing to push a head, we said cryptic "remote 'branch'
object X does not exist on local" or "remote ref 'branch' is not
a strict subset of local ref 'branch'".  That was gittish.

Since the most likely reason this happens is because the pushed
head was not up-to-date, clarify the error message to say that
straight, and suggest pulling first.

First noticed by Johannes and seconded by Andreas.

Signed-off-by: Junio C Hamano <junkio@cox.net>

---

 send-pack.c |   30 ++++++++++++++----------------
 1 files changed, 14 insertions(+), 16 deletions(-)

69310a34cb6dcca32b08cf3ea9e91ab19354a874
diff --git a/send-pack.c b/send-pack.c
index 5bc2f01..0d41f9a 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -231,23 +231,21 @@ static int send_pack(int in, int out, in
 		if (!force_update &&
 		    !is_zero_sha1(ref->old_sha1) &&
 		    !ref->force) {
-			if (!has_sha1_file(ref->old_sha1)) {
-				error("remote '%s' object %s does not "
-				      "exist on local",
-				      ref->name, sha1_to_hex(ref->old_sha1));
-				ret = -2;
-				continue;
-			}
-
-			/* We assume that local is fsck-clean.  Otherwise
-			 * you _could_ have an old tag which points at
-			 * something you do not have, which may or may not
-			 * be a commit.
-			 */
-			if (!ref_newer(ref->peer_ref->new_sha1,
+			if (!has_sha1_file(ref->old_sha1) ||
+			    !ref_newer(ref->peer_ref->new_sha1,
 				       ref->old_sha1)) {
-				error("remote ref '%s' is not a strict "
-				      "subset of local ref '%s'.", ref->name,
+				/* We do not have the remote ref, or
+				 * we know that the remote ref is not
+				 * an ancestor of what we are trying to
+				 * push.  Either way this can be losing
+				 * commits at the remote end and likely
+				 * we were not up to date to begin with.
+				 */
+				error("remote '%s' is not a strict "
+				      "subset of local ref '%s'. "
+				      "maybe you are not up-to-date and "
+				      "need to pull first?",
+				      ref->name,
 				      ref->peer_ref->name);
 				ret = -2;
 				continue;
-- 
1.0.GIT

```

## Johannes Schindelin, 2005-12-22 20:53

Subject: Re: [PATCH] send-pack: reword non-fast-forward error message.
Message-ID: <Pine.LNX.4.63.0512222152550.5677@wbgn013.biozentrum.uni-wuerzburg.de>
URL: https://gitlist.dev/e/Pine.LNX.4.63.0512222152550.5677%40wbgn013.biozentrum.uni-wuerzburg.de
In-Reply-To: <7vu0d0j24z.fsf_-_@assigned-by-dhcp.cox.net>

```
Hi,

On Thu, 22 Dec 2005, Junio C Hamano wrote:

> That is reasonable.  How about this?

I like it.

Ciao,
Dscho

```

## Andreas Ericsson, 2005-12-23 12:13

Subject: Re: [PATCH] send-pack: reword non-fast-forward error message.
Message-ID: <43ABE9FA.4010604@op5.se>
URL: https://gitlist.dev/e/43ABE9FA.4010604%40op5.se
In-Reply-To: <7vu0d0j24z.fsf_-_@assigned-by-dhcp.cox.net>

```
Junio C Hamano wrote:
> Junio C Hamano <junkio@cox.net> writes:
> 
> 
>>Andreas Ericsson <ae@op5.se> writes:
>>
>>
>>>Junio C Hamano wrote:
>>>
>>>>In a sense, both are "pull first?" situation, and it probably is
>>>>more confusing to give different messages to the user in these
>>>>two cases.  From the end-user point of view they are the same
>>>>"remote is not strict subset.".
>>>
>>>In non-git'ish, does this mean "you're not up to date, so pull before 
>>>pushing" ? If so, why not say so? I'm sure it could prevent a fair few 
>>>problems for users (not least those new to scm's).
> 
> 
> That is reasonable.  How about this?
> 

Me likes.

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

```
