# [PATCH] pull: mention "pull", not "fetch" in the error message.

7 messages from 2010-03-26 to 2010-03-28. Participants: Matthieu Moy, Michael J Gruber, Alex Riesen, Junio C Hamano.
Thread: https://gitlist.dev/t/23184

## Matthieu Moy, 2010-03-26 13:38

Subject: [PATCH] pull: mention "pull", not "fetch" in the error message.
Message-ID: <1269610699-13176-1-git-send-email-Matthieu.Moy@imag.fr>
URL: https://gitlist.dev/e/1269610699-13176-1-git-send-email-Matthieu.Moy%40imag.fr

```
For newbies who've just been taught "git push", the error message
"Where do you want to fetch from today?" is indeed confusing. Change it
to "Where do you want to pull from today?" in case fetch was called from
pull.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
 builtin/fetch.c |    6 +++++-
 git-pull.sh     |    3 ++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/builtin/fetch.c b/builtin/fetch.c
index 957be9f..f3246f5 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -842,8 +842,12 @@ static int fetch_one(struct remote *remote, int argc, const char **argv)
 	int ref_nr = 0;
 	int exit_code;
 
+	char *cmd = getenv("GIT_USER_COMMAND");
+	if (cmd == NULL || cmd[0] == '\0')
+		cmd = "fetch";
+
 	if (!remote)
-		die("Where do you want to fetch from today?");
+		die("Where do you want to %s from today?", cmd);
 
 	transport = transport_get(remote, NULL);
 	transport_set_verbosity(transport, verbosity, progress);
diff --git a/git-pull.sh b/git-pull.sh
index 1a4729f..abc233b 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -216,7 +216,8 @@ test true = "$rebase" && {
 	done
 }
 orig_head=$(git rev-parse -q --verify HEAD)
-git fetch $verbosity $progress --update-head-ok "$@" || exit 1
+GIT_USER_COMMAND=pull \
+    git fetch $verbosity $progress --update-head-ok "$@" || exit 1
 
 curr_head=$(git rev-parse -q --verify HEAD)
 if test -n "$orig_head" && test "$curr_head" != "$orig_head"
-- 
1.7.0.2.204.g8940d.dirty

```

## Michael J Gruber, 2010-03-26 14:18

Subject: Re: [PATCH] pull: mention "pull", not "fetch" in the error message.
Message-ID: <4BACC241.4010608@drmicha.warpmail.net>
URL: https://gitlist.dev/e/4BACC241.4010608%40drmicha.warpmail.net
In-Reply-To: <1269610699-13176-1-git-send-email-Matthieu.Moy@imag.fr>

```
Matthieu Moy venit, vidit, dixit 26.03.2010 14:38:
> For newbies who've just been taught "git push", the error message

Even though newbies don't read git.git's commit messages, you may want
to say "pull" here ;)

One way or the other, nothing beats the error messages in ident.c ;)

> "Where do you want to fetch from today?" is indeed confusing. Change it
> to "Where do you want to pull from today?" in case fetch was called from
> pull.
> 
> Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
> ---
>  builtin/fetch.c |    6 +++++-
>  git-pull.sh     |    3 ++-
>  2 files changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/builtin/fetch.c b/builtin/fetch.c
> index 957be9f..f3246f5 100644
> --- a/builtin/fetch.c
> +++ b/builtin/fetch.c
> @@ -842,8 +842,12 @@ static int fetch_one(struct remote *remote, int argc, const char **argv)
>  	int ref_nr = 0;
>  	int exit_code;
>  
> +	char *cmd = getenv("GIT_USER_COMMAND");
> +	if (cmd == NULL || cmd[0] == '\0')
> +		cmd = "fetch";
> +
>  	if (!remote)
> -		die("Where do you want to fetch from today?");
> +		die("Where do you want to %s from today?", cmd);
>  
>  	transport = transport_get(remote, NULL);
>  	transport_set_verbosity(transport, verbosity, progress);
> diff --git a/git-pull.sh b/git-pull.sh
> index 1a4729f..abc233b 100755
> --- a/git-pull.sh
> +++ b/git-pull.sh
> @@ -216,7 +216,8 @@ test true = "$rebase" && {
>  	done
>  }
>  orig_head=$(git rev-parse -q --verify HEAD)
> -git fetch $verbosity $progress --update-head-ok "$@" || exit 1
> +GIT_USER_COMMAND=pull \
> +    git fetch $verbosity $progress --update-head-ok "$@" || exit 1
>  
>  curr_head=$(git rev-parse -q --verify HEAD)
>  if test -n "$orig_head" && test "$curr_head" != "$orig_head"

```

## Matthieu Moy, 2010-03-26 15:02

Subject: Re: [PATCH] pull: mention "pull", not "fetch" in the error message.
Message-ID: <vpqfx3nunvt.fsf@bauges.imag.fr>
URL: https://gitlist.dev/e/vpqfx3nunvt.fsf%40bauges.imag.fr
In-Reply-To: <4BACC241.4010608@drmicha.warpmail.net>

```
Michael J Gruber <git@drmicha.warpmail.net> writes:

> Matthieu Moy venit, vidit, dixit 26.03.2010 14:38:
>> For newbies who've just been taught "git push", the error message
>
> Even though newbies don't read git.git's commit messages, you may want
> to say "pull" here ;)

Right. I was just two letters away from the right message ;-).

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

```

## Matthieu Moy, 2010-03-26 15:03

Subject: [PATCH v2] pull: mention "pull", not "fetch" in the error message.
Message-ID: <1269615836-13995-1-git-send-email-Matthieu.Moy@imag.fr>
URL: https://gitlist.dev/e/1269615836-13995-1-git-send-email-Matthieu.Moy%40imag.fr
In-Reply-To: <4BACC241.4010608@drmicha.warpmail.net>

```
For newbies who've just been taught "git pull", the error message
"Where do you want to fetch from today?" is indeed confusing. Change it
to "Where do you want to pull from today?" in case fetch was called from
pull.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
Just fixed a typo in commit message since v1.

 builtin/fetch.c |    6 +++++-
 git-pull.sh     |    3 ++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/builtin/fetch.c b/builtin/fetch.c
index 957be9f..f3246f5 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -842,8 +842,12 @@ static int fetch_one(struct remote *remote, int argc, const char **argv)
 	int ref_nr = 0;
 	int exit_code;
 
+	char *cmd = getenv("GIT_USER_COMMAND");
+	if (cmd == NULL || cmd[0] == '\0')
+		cmd = "fetch";
+
 	if (!remote)
-		die("Where do you want to fetch from today?");
+		die("Where do you want to %s from today?", cmd);
 
 	transport = transport_get(remote, NULL);
 	transport_set_verbosity(transport, verbosity, progress);
diff --git a/git-pull.sh b/git-pull.sh
index 1a4729f..abc233b 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -216,7 +216,8 @@ test true = "$rebase" && {
 	done
 }
 orig_head=$(git rev-parse -q --verify HEAD)
-git fetch $verbosity $progress --update-head-ok "$@" || exit 1
+GIT_USER_COMMAND=pull \
+    git fetch $verbosity $progress --update-head-ok "$@" || exit 1
 
 curr_head=$(git rev-parse -q --verify HEAD)
 if test -n "$orig_head" && test "$curr_head" != "$orig_head"
-- 
1.7.0.2.204.g8940d.dirty

```

## Alex Riesen, 2010-03-26 23:12

Subject: Re: [PATCH v2] pull: mention "pull", not "fetch" in the error message.
Message-ID: <20100326231209.GB6797@blimp.localdomain>
URL: https://gitlist.dev/e/20100326231209.GB6797%40blimp.localdomain
In-Reply-To: <1269615836-13995-1-git-send-email-Matthieu.Moy@imag.fr>

```
Matthieu Moy, Fri, Mar 26, 2010 16:03:56 +0100:
> For newbies who've just been taught "git pull", the error message
> "Where do you want to fetch from today?" is indeed confusing. Change it
> to "Where do you want to pull from today?" in case fetch was called from
> pull.
...
> @@ -842,8 +842,12 @@ static int fetch_one(struct remote *remote, int argc, const char **argv)
>  	int ref_nr = 0;
>  	int exit_code;
>  
> +	char *cmd = getenv("GIT_USER_COMMAND");

Isn't the variable name a little too generic? USER_COMMAND doesn't make it
clear that its only purpose is to pass a string "pull" to an error message
which is never even seen under normal circumstances.

```

## Matthieu Moy, 2010-03-27 08:52

Subject: Re: [PATCH v2] pull: mention "pull", not "fetch" in the error message.
Message-ID: <vpqy6hep2ns.fsf@bauges.imag.fr>
URL: https://gitlist.dev/e/vpqy6hep2ns.fsf%40bauges.imag.fr
In-Reply-To: <20100326231209.GB6797@blimp.localdomain>

```
Alex Riesen <raa.lkml@gmail.com> writes:

> Matthieu Moy, Fri, Mar 26, 2010 16:03:56 +0100:
>> For newbies who've just been taught "git pull", the error message
>> "Where do you want to fetch from today?" is indeed confusing. Change it
>> to "Where do you want to pull from today?" in case fetch was called from
>> pull.
> ...
>> @@ -842,8 +842,12 @@ static int fetch_one(struct remote *remote, int argc, const char **argv)
>>  	int ref_nr = 0;
>>  	int exit_code;
>>
>> +	char *cmd = getenv("GIT_USER_COMMAND");
>
> Isn't the variable name a little too generic? USER_COMMAND doesn't make it
> clear that its only purpose is to pass a string "pull"

It is generic, so that the same variable can be reused elsewhere if
needed. When a command "git foo" calls internally "git bar", the
instance of "git bar" thinks it's executing the command "bar", but the
user thinks he just ran the command "foo". This variable lets git know
that and adapt its error message accordingly.

> to an error message which is never even seen under normal
> circumstances.

For some definition of "never ever" and/or "normal circumstances"
only, then:

/tmp/test$ git init
Initialized empty Git repository in /tmp/test/.git/
/tmp/test$ git pull
fatal: Where do you want to pull from today?

(the confused newbie scenario isn't imaginary, it just happened to a
colleague of mine)

--
Matthieu Moy
http://www-verimag.imag.fr/~moy/

```

## Junio C Hamano, 2010-03-28 17:14

Subject: Re: [PATCH v2] pull: mention "pull", not "fetch" in the error message.
Message-ID: <7vmxxs4bd0.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vmxxs4bd0.fsf%40alter.siamese.dyndns.org
In-Reply-To: <1269615836-13995-1-git-send-email-Matthieu.Moy@imag.fr>

```
Matthieu Moy <Matthieu.Moy@imag.fr> writes:

> For newbies who've just been taught "git pull", the error message
> "Where do you want to fetch from today?" is indeed confusing. Change it
> to "Where do you want to pull from today?" in case fetch was called from
> pull.
>
> Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
> ---
> Just fixed a typo in commit message since v1.
>
>  builtin/fetch.c |    6 +++++-
>  git-pull.sh     |    3 ++-
>  2 files changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/builtin/fetch.c b/builtin/fetch.c
> index 957be9f..f3246f5 100644
> --- a/builtin/fetch.c
> +++ b/builtin/fetch.c
> @@ -842,8 +842,12 @@ static int fetch_one(struct remote *remote, int argc, const char **argv)
>  	int ref_nr = 0;
>  	int exit_code;
>  
> +	char *cmd = getenv("GIT_USER_COMMAND");
> +	if (cmd == NULL || cmd[0] == '\0')
> +		cmd = "fetch";
> +
>  	if (!remote)
> -		die("Where do you want to fetch from today?");
> +		die("Where do you want to %s from today?", cmd);

>  	transport = transport_get(remote, NULL);
>  	transport_set_verbosity(transport, verbosity, progress);
> diff --git a/git-pull.sh b/git-pull.sh
> index 1a4729f..abc233b 100755
> --- a/git-pull.sh
> +++ b/git-pull.sh
> @@ -216,7 +216,8 @@ test true = "$rebase" && {
>  	done
>  }
>  orig_head=$(git rev-parse -q --verify HEAD)
> -git fetch $verbosity $progress --update-head-ok "$@" || exit 1
> +GIT_USER_COMMAND=pull \
> +    git fetch $verbosity $progress --update-head-ok "$@" || exit 1

I personally don't think this is a good change.  When somebody writes a
wrapper around "git pull" to "make it easier", the name of the command
that is given in the message will still be "pull", and you will have 
exactly the same issue again.

It was never the intent of the use of word "fetch" in the original message
to give the name of one among many commands (i.e. the message was not
about "fetch vs pull").  The word was to convey more abstract concept of
getting new changes that are available on the other end.

An alternative that does not introduce layering violation of making the
lower level porcelain aware of what the caller is doing might be to make
it even more bland, "Where do you want to get changes from today?", or
something.

Or we could even make it even more explicit by saying "Where do you want
to go today?", which was what the original meant to mock ;-).

```
