# [PATCH] Make git-blame fail when working tree is needed and we're not in one

7 messages from 2007-11-03 to 2007-11-04. Participants: Mike Hommey, Andreas Ericsson, Junio C Hamano.
Thread: https://gitlist.dev/t/10617

## Mike Hommey, 2007-11-03 12:22

Subject: [PATCH] Delay pager setup in git blame
Message-ID: <1194092575-7133-1-git-send-email-mh@glandium.org>
URL: https://gitlist.dev/e/1194092575-7133-1-git-send-email-mh%40glandium.org

```
This avoids to launch the pager when git blame fails for any reason.

Signed-off-by: Mike Hommey <mh@glandium.org>
---
 builtin-blame.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/builtin-blame.c b/builtin-blame.c
index 8432b82..aedc294 100644
--- a/builtin-blame.c
+++ b/builtin-blame.c
@@ -2215,9 +2215,6 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
 			argv[unk++] = arg;
 	}
 
-	if (!incremental)
-		setup_pager();
-
 	if (!blame_move_score)
 		blame_move_score = BLAME_DEFAULT_MOVE_SCORE;
 	if (!blame_copy_score)
@@ -2411,6 +2408,9 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
 
 	read_mailmap(&mailmap, ".mailmap", NULL);
 
+	if (!incremental)
+		setup_pager();
+
 	assign_blame(&sb, &revs, opt);
 
 	if (incremental)
-- 
1.5.3.5

```

## Mike Hommey, 2007-11-03 12:22

Subject: [PATCH] Allow 'git blame rev path' to work on bare repository
Message-ID: <1194092575-7133-2-git-send-email-mh@glandium.org>
URL: https://gitlist.dev/e/1194092575-7133-2-git-send-email-mh%40glandium.org
In-Reply-To: <1194092575-7133-1-git-send-email-mh@glandium.org>

```
While 'git blame rev -- path' works, 'git blame rev path' didn't.

Signed-off-by: Mike Hommey <mh@glandium.org>
---
 builtin-blame.c |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)

diff --git a/builtin-blame.c b/builtin-blame.c
index aedc294..141287e 100644
--- a/builtin-blame.c
+++ b/builtin-blame.c
@@ -2294,10 +2294,6 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
 			}
 			else if (i != argc - 1)
 				usage(blame_usage); /* garbage at end */
-
-			if (!has_path_in_work_tree(path))
-				die("cannot stat path %s: %s",
-				    path, strerror(errno));
 		}
 	}
 
-- 
1.5.3.5

```

## Mike Hommey, 2007-11-03 12:22

Subject: [PATCH] Make git-blame fail when working tree is needed and we're not in one
Message-ID: <1194092575-7133-3-git-send-email-mh@glandium.org>
URL: https://gitlist.dev/e/1194092575-7133-3-git-send-email-mh%40glandium.org
In-Reply-To: <1194092575-7133-2-git-send-email-mh@glandium.org>

```

Signed-off-by: Mike Hommey <mh@glandium.org>
---
 builtin-blame.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/builtin-blame.c b/builtin-blame.c
index 141287e..500ae77 100644
--- a/builtin-blame.c
+++ b/builtin-blame.c
@@ -2338,6 +2338,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
 		 * do not default to HEAD, but use the working tree
 		 * or "--contents".
 		 */
+		setup_work_tree();
 		sb.final = fake_working_tree_commit(path, contents_from);
 		add_pending_object(&revs, &(sb.final->object), ":");
 	}
-- 
1.5.3.5

```

## Mike Hommey, 2007-11-03 12:30

Subject: Re: [PATCH] Make git-blame fail when working tree is needed and we're not in one
Message-ID: <20071103123031.GA7425@glandium.org>
URL: https://gitlist.dev/e/20071103123031.GA7425%40glandium.org
In-Reply-To: <1194092575-7133-3-git-send-email-mh@glandium.org>

```
Oops, I forgot -n to format-patch. Wasn't there a proposal to have -n
automatically set when outputing several patches ?

Mike

```

## Andreas Ericsson, 2007-11-03 15:01

Subject: Re: [PATCH] Make git-blame fail when working tree is needed and we're not in one
Message-ID: <472C8D60.4070809@op5.se>
URL: https://gitlist.dev/e/472C8D60.4070809%40op5.se
In-Reply-To: <20071103123031.GA7425@glandium.org>

```
Mike Hommey wrote:
> Oops, I forgot -n to format-patch. Wasn't there a proposal to have -n
> automatically set when outputing several patches ?
> 

No. There was a patch to skip numbering when only one patch was created.
I suppose a different implementation of that patch could make the default
to number when multiple patches are created but not when a single one is.

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

```

## Junio C Hamano, 2007-11-04 05:21

Subject: Re: [PATCH] Allow 'git blame rev path' to work on bare repository
Message-ID: <7vabpuvb4e.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vabpuvb4e.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <1194092575-7133-2-git-send-email-mh@glandium.org>

```
Mike Hommey <mh@glandium.org> writes:

> While 'git blame rev -- path' works, 'git blame rev path' didn't.
>
> Signed-off-by: Mike Hommey <mh@glandium.org>
> ---
>  builtin-blame.c |    4 ----
>  1 files changed, 0 insertions(+), 4 deletions(-)
>
> diff --git a/builtin-blame.c b/builtin-blame.c
> index aedc294..141287e 100644
> --- a/builtin-blame.c
> +++ b/builtin-blame.c
> @@ -2294,10 +2294,6 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
>  			}
>  			else if (i != argc - 1)
>  				usage(blame_usage); /* garbage at end */
> -
> -			if (!has_path_in_work_tree(path))
> -				die("cannot stat path %s: %s",
> -				    path, strerror(errno));
>  		}
>  	}
>  

Sorry but a NAK; at least limit the removal of the test only to a bare
repository case.

```

## Mike Hommey, 2007-11-04 08:26

Subject: Re: [PATCH] Allow 'git blame rev path' to work on bare repository
Message-ID: <20071104082623.GA3514@glandium.org>
URL: https://gitlist.dev/e/20071104082623.GA3514%40glandium.org
In-Reply-To: <7vabpuvb4e.fsf@gitster.siamese.dyndns.org>

```
On Sat, Nov 03, 2007 at 10:21:53PM -0700, Junio C Hamano wrote:
> Mike Hommey <mh@glandium.org> writes:
> 
> > While 'git blame rev -- path' works, 'git blame rev path' didn't.
> >
> > Signed-off-by: Mike Hommey <mh@glandium.org>
> > ---
> >  builtin-blame.c |    4 ----
> >  1 files changed, 0 insertions(+), 4 deletions(-)
> >
> > diff --git a/builtin-blame.c b/builtin-blame.c
> > index aedc294..141287e 100644
> > --- a/builtin-blame.c
> > +++ b/builtin-blame.c
> > @@ -2294,10 +2294,6 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
> >  			}
> >  			else if (i != argc - 1)
> >  				usage(blame_usage); /* garbage at end */
> > -
> > -			if (!has_path_in_work_tree(path))
> > -				die("cannot stat path %s: %s",
> > -				    path, strerror(errno));
> >  		}
> >  	}
> >  
> 
> Sorry but a NAK; at least limit the removal of the test only to a bare
> repository case.

I fail to see why this test is necessary here. The lack of file in the
working tree is caught in fake_working_tree_commit() anyways.

Mike

```
